Just because it's more fun
Changing the TCP/IP settings via the GUI interface is very easy and simple. But what about if you want to have more fun doing it and change the IP and DNS properties using the Windows command prompt instead? If you are a Linux guru or a batch scripting wizard, this should not be complicated. If you are new to the command prompt, well, today is a good day to start.
We will change the IP address and DNS servers using the built-in utility in Windows called Netsh. Netsh is a nifty utility to change system networking settings, locally or remotely. To run Netsh click on Start, then type CMD and press ENTER.
When the command prompt comes up type netsh and press Enter. Now you should be ready to execute commands. Simple huh. Just to warm up type “interface ip show config“. That command will bring up the TCP/IP network settings.
Now, how you change the IP address and Default Gateway settings? To change the Local Area Connection TCP/IP settings, type the following command:
interface ip set address name="Local Area Connection" static 192.168.10.42 255.255.255.0 192.168.1.1
As you can see, when you use Netsh you need to specify what network properties you need to change. In the example above, we changed the network properties for “Local Area Connection” to use a static IP address of 192.168.10.42, a subnet mask of 255.255.255.0 and a default gateway of 192.168.1.1.
Changing the DNS IP address is almost identical to the procedure above. Type the following command on the Netsh prompt:
interface ip set dns "Local Area Connection" static 192.168.1.1
To setup WINS, type the following command:
interface ip set wins "Local Area Connection" static 192.168.1.1
To set the network properties to obtain the IP address from a DHCP server, type the following command:
interface ip set address "Local Area Connection" dhcp
To set DNS to obtain IP address automatically type the following:
netsh interface ip set dns "Local Area Connection" dhcp
If you go to the network adapter settings via Control Panel, you’ll see that the values have been updated there in the GUI interface also.
There you have it, a useful tool to help you perform network configuration via the command prompt. It’s definitely much faster than the 10 to 15 clicks required to get to the IPv4 Properties dialog above.