Tuesday, March 16, 2010

How to set IP Address, Subnet Mask, Default Gateway and DNS via command prompt batch file

:This is coded by JOHN IAN R. MEDILO
:dated March 17, 2010 05:35am
:Usage: set address[name][[source=]dhcp| static [addr=]IP address[mask=]IP subnet mask][[geteway=]|none [gwmetric=]integer]"
:netsh interface ip show config
cls
@echo Hello World, we will change you IP.
@echo
@echo Please wait....
@echo off

@echo Changing your IP Address, Subnet Mask and Default Gateway
netsh interface ip set address "Local Area Connection" static 192.168.1.2 255.255.255.0 192.168.1.1

@echo Deleting all DNS
netsh interface ip delete dns "Local Area Connection" all

@echo Adding primary DNS = 8.8.8.8 ; NOTE: open DNS
netsh interface ip set dns "Local Area Connection" static 8.8.8.8 primary

@echo Adding Secondary DNS = 8.8.4.4; NOTE: open DNS
netsh interface ip add dns "Local Area Connection" 8.8.4.4 index=2

@echo Adding Secondary DNS = 4.1.1.1; NOTE: open DNS
netsh interface ip add dns "Local Area Connection" 8.8.4.4 index=3

ipconfig /all
netsh interface ip show config

3 comments:

  1. Changing TCP/IP settings using the GUI property 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? 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” is a nifty utility to change system networking settings, locally or remotely. To 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. Simple huh. Just to warm up type “interface ip show config“ that will show 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

    Netsh IP address change

    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” then we setup a static IP address, Subnet Mask and at the end the default gateway.

    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 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

    There you have it, a useful tool to help you on your network configuration.

    ReplyDelete
  2. http://helpdeskgeek.com/networking/change-ip-address-and-dns-servers-using-the-command-prompt/

    ReplyDelete
  3. It's nice information...I check my speed test here http://www.ip-details.com/ It provides IP-Details.com, Search and find ip address's,domain name host's whois information including city, country, global latitude & longitude coordinates....

    ReplyDelete