Tuesday, August 08, 2006

MS: How to use netsh to configure TCP/IP settings from the Command Prompt

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.

Netsh.exe is available on Windows 2000, Windows XP and Windows Server 2003.

With Netsh.exe, you can configure the IP address and other TCP/IP related settings. For example:

The following command configures the interface named Local Area Connection with the static IP address 192.168.0.100, the subnet mask of 255.255.255.0, and a default gateway of 192.168.0.1:

netsh interface ip set address name="Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1

Netsh.exe can also be used to configure your NIC to automatically obtain an IP address from a DHCP server:

netsh interface ip set address "Local Area Connection" dhcp

You can configure your NIC to dynamically obtain it's DNS settings:

netsh interface ip set dns "Local Area Connection" dhcp

You can configure DNS addresses from the Command Prompt:

netsh interface ip set dns "Local Area Connection" static 192.168.0.200

You can add extra DNS servers using:

netsh interface ip add dns "Local Area Connection" 192.168.0.210

You can configure your NIC to dynamically obtain it's WINS settings:

netsh interface ip set wins "Local Area Connection" dhcp

You can configure WINS addresses from the Command Prompt :

netsh interface ip set wins "Local Area Connection" static 192.168.0.200

If you want you can add extra WINS servers using:

netsh interface ip add wins "Local Area Connection" 192.168.0.210

Example Script to setup a computer:

netsh interface ip set address name="Local Area Connection" static 10.150.0.125 255.255.0.0 10.150.0.254 1
netsh interface ip set dns "Local Area Connection" static 10.150.0.10
netsh interface ip add dns "Local Area Connection" 10.150.0.11
netsh interface ip add dns "Local Area Connection" 10.150.0.12
netsh interface ip set wins "Local Area Connection" static 10.150.0.10
netsh interface ip add wins "Local Area Connection" 10.150.0.11
netsh interface ip add wins "Local Area Connection" 10.150.0.12

No comments: