Site icon WinCert

Change an IP address, Gateway and DNS via CMD

Changing TCP/IP settings using the GUI property is fairly simple. If you have to change IP address settings using CMD to automate the process, here’s how to do it:

To change an IP address and DNS server setting using the built-in utility in Windows called “Netsh” we’ll do the following:

Run Netsh click on start then RUN and type CMD press ENTER.

When the command prompt comes up type Netsh, now you should be ready to execute commands. For a start, type “interface ip show config“ that will show up the TCP/IP network settings.

To change the Local Area Connection TCP/IP settings including an IP address, subnet mask and default gateway, 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, we changed the network properties for “Local Area Connection”.

Changing the DNS IP address is almost identical as 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 a secondary DNS type the following:

interface ip add dns “Local Area Connection” 192.168.1.2

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 want to use the batch script to automate this process you can do the following:

netsh int ip set address “Local Area Connection” static 192.168.0.10 255.255.255.0 192.168.0.1 1

Exit mobile version