<

Easily configure your NIC for multiple environments with Netsh

Published on
6,909 Points
3,609 Views
3 Endorsements
Last Modified:
The goal of this article is to show you how to easily switch to different NIC configurations with netsh.

Let's consider the following example :

- Your NIC configuration at work is given by a DHCP server
- You have to visit one important customer twice a week, and an IP address has been reserved for you. The problem is, you have to enter the configuration manually.
- Your home configuration is also static.

OK, there's some work to do now, but you'll perform these actions only once.

Let's start with the easiest one : the DHCP configuration. You can use the friendly graphic interface, and set the parameters to "obtain an address automatically". But you can also use the powerful netsh !

Open a command prompt and type the following command :

netsh interface ip set address "Local Area Connection" dhcp

where "Local Area Connection" is the name of the interface you want to configure.

We now want to export this configuration to be able to use it when needed. To achieve this, type :

netsh -c interface dump >C:\office_dhcp.txt

Good. First file done. 2 to go...

Now, we'll have to configure our card for the customer's environment. Let's say that the IP reserved for us is 10.91.1.100 with a netmask of 255.255.255.0, a default gateway 10.91.1.1, a DNS 10.91.1.10 and a WINS 10.91.1.12

Again, we can do it the good old graphic way, or use netsh :

netsh interface ip set address name="Local Area Connection" static 10.91.1.100  255.255.255.0 10.91.1.1 1

Got the address, netmask and default GW. Now let's take care of the DNS part :

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

And the WINS server :

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

We're now all set to export this configuration :

netsh -c interface dump >C:\Customer.txt


You can repeat these steps to configure your card for your home environment, then export the file :

netsh -c interface dump >C:\home.txt

Now, all we need to do is call the right file for the right environment !

Work : netsh -f C:\office_dhcp.txt
Customer : netsh -f C:\Customer.txt
Home : netsh -f C:\home.txt






 
3
Author:vsg375
Enjoy this complimentary article view.

Get unlimited access to our entire library of technical procedures, guides, and tutorials written by certified industry professionals.

Get 7 days free
Click here to view the full article

Using this article for work? Experts Exchange can benefit your whole team.

Learn More
COLLABORATE WITH CERTIFIED PROFESSIONALS
Experts Exchange is a tech solutions provider where users receive personalized tech help from vetted certified professionals. These industry professionals also write and publish relevant articles on our site.
Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Learn from the best.