Subscribe to Windows IT Pro
April 27, 2004 12:00 AM

IP Configuration Selection

Windows IT Pro
InstantDoc ID #42199
Rating: (0)
Downloads
42199.zip

Every morning, I take my Acer notebook to work; in the evening, I take the notebook to class; at night, I take the notebook home. And every time I change locations, I need to reconfigure my IP settings. I don't like dynamic IP addressing; I want to know the IP address, gateway, and DNS server that I'm using whenever possible.

Certain tools (e.g., Softmate's IPSwitcher) let you select an IP configuration from several sets of configurations. However, the Netsh command achieves the same result. You can use Netsh to change your IP address, subnet mask, gateway, and DNS settings.

To configure IP settings, go to a command prompt and enter

netsh interface ip set 
  address name="local area 
  connection" source=static 
  10.2.2.2 255.0.0.0 
  10.200.0.3 1
netsh interface ip set dns 
  "Local area connection" 
  static 10.2.2.2

The first Netsh command configures the local area connection settings. This command sets the IP address to 10.2.2.2, subnet mask to 255.0.0.0, gateway to 10.200.0.3, and gateway metric to 1. The second Netsh command sets the Preferred DNS Server setting to 10.2.2.2.

I used the Microsoft Windows 2000 Server Resource Kit's Choice command to create a batch file to retrieve user input and the Netsh command to modify the IP settings according to that input. Listing 1 shows my batch file. The menu.txt file, which Listing 2 shows, contains my selection menu.

Related Content:

ARTICLE TOOLS

Comments
  • Wayne
    8 years ago
    May 21, 2004

    Can this run in Windows XP Pro?

  • jlee
    8 years ago
    May 09, 2004

    It is very useful tip. Thank for your offering!

  • alex
    8 years ago
    May 01, 2004

    This is a very great tip ! Just what I needed !

    However, how can I run netsh on NT 4.0 workstations ?

    Many thanks

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.