Netsh.exe offers a unique 'view'

Netsh.exe offers a unique 'view'

Please let us know how useful you find this tip by rating it below!


Do you know what Netsh.exe is capable of doing for you?

One task you can use it for is viewing your TCP/IP settings.

Type the following command in a Command Prompt window (CMD.EXE):
netsh interface ip show config

You can configure your computer's 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

(The above line is one long line, so watch for word wrap. Copy and paste it as one line.)

Netsh.exe can also be useful in certain situations when you have a portable computer that needs to be relocated between two or more office locations, while still maintaining a specific and static IP address configuration. With Netsh.exe, you can save and restore the appropriate network configuration all from the command prompt.

Connect your portable computer to location #1, and then manually configure the required network settings.

Now, you need to export your current IP settings to a text file. Use the following command:

    Requires Free Membership to View

    By submitting your registration information to SearchWindowsServer.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchWindowsServer.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.


netsh -c interface dump > c:\location1.txt

When you reach location #2, do the same thing, only keep the new settings to a different file:
netsh -c interface dump > c:\location2.txt 

You can go on with as many other locations you may need.

Now, whenever you need to travel between locations, you can enter the following command in a Command Prompt window (CMD.EXE):
netsh -f c:\location1.txt or netsh -f c:\location2.txt. 

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 use this command to setup WINS:
netsh interface ip set wins "Local Area Connection" static 192.168.0.200

Or, if you want, you can configure your NIC to dynamically obtain its DNS settings:
netsh interface ip set dns "Local Area Connection" dhcp

As you can see, Netsh.exe is very customizable and useful.


ABOUT THE AUTHOR: Ron is the PC systems administrator at military and government contractor MPD Inc., of Owensboro, KY. He is the administrator for SMS 2.0, SMS 2003, Exchange 2000, Active Directory, Windows 2000 Server and Windows Server 2003, PC desktops, workstations and laptops.

This was first published in January 2005

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.

    Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.