Configuring TCP/IP from the cmd line in Windows

Netsh.exe can be very useful in viewing and editing TCP/IP settings from the command line.

To view your TCP/IP settings in a Command Prompt, type
netsh interface ip show config

To configure an IP address and other TCP/IP related settings:
netsh interface ip set address name=\"Local Area Connection\" static 192.168.1.101 255.255.255.0 192.168.1.1 1

To obtain an IP address from a DHCP server:
netsh interface ip set address \"Local Area Connection\" dhcp

To configure DNS and WINS addresses:
netsh interface ip set dns \"Local Area Connection\" static 192.168.0.200

and this for WINS:
netsh interface ip set wins \"Local Area Connection\" static 192.168.0.200

Or, to dynamically obtain DNS settings:
netsh interface ip set dns \"Local Area Connection\" dhcp

As a bonus tip, you can export your IP settings to a text file using the following command:
netsh -c interface dump > c:IPSettings.txt

To import the settings, type
netsh -f c:IPSettings.txt
OR
netsh exec c:location2.txt

You can use this to quickly switch between different settings.

1 Comment

  1. Itsme

    Thanks for taking the time to put up the nice set of tips. I was looking for a way to use a wildcard for the interface name in NETSH. Didn’t find it here, but thanks for putting all these up anyway.

Leave a Reply

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