While development and testing many times we need to change the IP addresses manually to a given IP and then switch back to Dynamic IP (DHCP). Doing it every time through GUI especially in Vista (finding the Network Option from Start, Right Click, Selecting Network Connections, then Right Click on the Interface, Choose IPV4, …) is tiresome and waste of time.
For doing it easily Windows exposes a great command called NETSH. NETSH exposes too many options, the help (/?) and online documentation runs for several pages. Because of this, every time I tried I was put off. Today I spent last 5 minutes and cracked this. For changing IP address, we need to use the NETSH INTERFACE IP command.
To display current IP settings (equivalent to your ipconfig command):
C:\>netsh interface ip show addresses Configuration for interface "Local Area Connection" DHCP enabled: No IP Address: 10.10.99.222 Subnet Prefix: 10.10.0.0/16 (mask 255.255.0.0) Default Gateway: 10.10.10.11 Gateway Metric: 256 InterfaceMetric: 20
To change your IP Settings to DHCP:
C:\>netsh interface ip set address name="Local Area Connection" source=dhcp
To set IP to a manual config (replace with your own values):
C:\> netsh interface ip set address "Local Area connection" static 10.10.9.22 255.0.0.0 10.10.10.111 1
Here after static command, the first value is your IP Address, second is NetMask, third is Gateway and fourth is metric.
Similar to set address command in netsh interface ip there is set DNS command that can set the DNS values as well. If you put the above in a batch (.bat) file then you can just double-click on it everytime you want the IP config to be changed.