سلام
این یه نمونه برنامه هست واسه تغییر آی پی سیستم ، میتونی از این استفاده کنی و یه تابع Random بذاری داخلش که هربار که صفحه لود میشه یا ... آی پی رو به صورت Random مقدار دهی کنه یه به هرصورت دیگه ای که خودت میخوای :


usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

//Add This Reference

usingSystem.Management;

namespaceWindowsFormsApplication1

{

publicpartialclassForm1 : Form

{

publicForm1()

{

InitializeComponent();

}

privatevoidbutton1_Click(objectsender, EventArgs e)

{

stringIP = "192.168.137.25";

stringSubnetMask = "255.255.255.0";

stringGateway = "192.168.137.1";

ManagementClass mngCls = newManagementClass("Win32_NetworkAdapterConfiguration ");

ManagementObjectCollection mngObjColc = mngCls.GetInstances();

foreach(ManagementObject objMO inmngObjColc)

{

if(!(bool)objMO.GetPropertyValue("IPEnabled")) continue;

try

{

ManagementBaseObject objNewIP = null;

ManagementBaseObject objSetIP = null;

ManagementBaseObject objNewGate = null;

objNewIP = objMO.GetMethodParameters("EnableStatic");

objNewGate = objMO.GetMethodParameters("SetGateways");

//Set DefaultGateway

objNewGate.SetPropertyValue("DefaultIPGateway", newstring[]{Gateway});

objNewGate.SetPropertyValue("GatewayCostMetric", newint[]{1});

//Set IPAddress and Subnet Mask

objNewIP.SetPropertyValue("IPAddress",newstring[]{IP});

objNewIP.SetPropertyValue("SubnetMask",newstring[]{SubnetMask});

objSetIP = objMO.InvokeMethod("EnableStatic",objNewIP, null);

objSetIP = objMO.InvokeMethod("SetGateways",objNewGate, null);

MessageBox.Show("Updated IPAddress, SubnetMask and DefaultGateway!");

}

catch(Exception ex)

{

MessageBox.Show("Unable to Set IP : "+ex.Message);

}
}
}
}