Friday, May 25, 2012

Configure IP Address and DNS using Command Prompt

Netsh IP Address
In order to configure TCP/IP settings such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses and many other options you can use Netsh.exe. The requested operation requires elevation (Run as administrator).

The IP address of your computer can be set from the command prompt by running the following commands at an administrative level prompt:

netsh interface ip set address name="Local Area Connection" static 146.40.202.222 255.255.255.0 146.40.202.1 1

Netsh interface set ip address

Local Area Connection is the name of the adapter you want to modify. In single NIC systems it is normally called Local Area Connection.
146.40.202.222 is the IP address you want to set.
255.255.255.0 is the subnet mask.
146.40.202.1 is the gateway.
1 is the gateway metric. You can leave this as 1 for almost all cases.

If you want to enable DHCP you can run:
netsh interface ip set address name="Local Area Connection" dhcp

There are two commands for DNS since administrators typically configure a primary and secondary DNS server.
For the primary DNS run:
netsh interface ip set dns name="Local Area Connection" static 146.40.202.9

For the secondary run:
netsh interface ip add dns name="Local Area Connection" 146.40.203.9 index=2

Local Area Connection

If you want to configure the computer to use DNS from DHCP run:
netsh interface ip set dnsservers name="Local Area Connection" source=dhcp

When you are finished with all of your IP and DNS changes run ipconfig -all to review the new settings.

0 comments:

Post a Comment