Easily configure your NIC for multiple environments with Netsh

Published on
6,834 Points
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 with a netmask of, a default gateway, a DNS and a WINS

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

netsh interface ip set address name="Local Area Connection" static 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

And the WINS server :

netsh interface ip set wins "Local Area Connection" static

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


Expert Comment

Nice i liked this article and by creating a batch for each config it would be much easier with just mouse clicks
LVL 18

Expert Comment

by:Ravi Agrawal
A small tip --

If there are only two configurations one with a Static IP and another one for a Dynamic one (by a dhcp server) -- then you can define a Static IP in the Alternate configuration of TCP/IP properties. This will tell  Windows XP to try to get an IP by DHCP server first & if it fails, then it will use the static IP,


Expert Comment

you are better off using a tool like :

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Join & Write a Comment

Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month