Change an IP address, Gateway and DNS via CMD

networking box

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

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

To setup a secondary DNS type the following:

interface ip add dns “Local Area Connection”

To Setup WINS, type the following command:

interface ip set wins “Local Area Connection” static

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 1

You may also like...

2 Responses

  1. tim says:

    How would you use this command with a file holding a list of server names and IP addresses.. I want to build a script that checks the file for the current server name and find the new IP address. I can put on several machines and change the IP addresses of the specified machines. they are moving from one subnet to another.

  2. Jo says:

    It doesnt work mfs , i accidently found it its ipconfig /dg to writ the default gateway address

Leave a Reply

Your email address will not be published. Required fields are marked *

two + six =