XP & 2000 users that use static ip\’s in one office & dhcp in another office

Contributor Icon Contributed by Blade Date Icon March 25, 2004  
Tag Icon Tagged: Windows networking

We have clients that have laptops with a static IP in one office & use dhcp in the main office. These are some bat files that can be used to switch from static to dhcp & back so they can log on to either part of the domain with as little inconvenience as possible. All the client has to do is double click the appropriate .bat file for thier location. These have saved me a lot of time changing configs when the clients are in the main office.


The dhcp bat is:
netsh interface ip set address “Local Area Connection” dhcp

The Static bat is:
netsh interface ip set address “Local Area Connection” static 127.0.0.1 255.xxx.xxx.xxx 127.xxx.xxx.xxx 1

The first series of numbers is the IP, the second series is the Subnet Mask, the third series is the Gateway, & the last number is the multiplier

And of course you create these in notepad & save as dhcp.bat & static.bat.
or you can name them by location Topeka.bat & Lawrence.bat

There is also a .bat to check the config after you run one of the batch files which is:

Netsh interface ip show config
pause

Previous recipe | Next recipe |
 
  • Anonymous
    IBM Thinkpads come with a utility called Access Connections which allows you to switch networking profiles from the taskbar, and completely hide the complexities of networking from the end user.

    You can download this from their support site.
  • Anonymous
    What about the DNS information? Doesn't that need to be set as well?
  • Anonymous
    does anyone know how to set the DNS information???....this is a nice, easy quick fix, but I need to know how to set DNS also....I'm assuming it's just an additional line???
  • Anonymous Coward
    Yes you can add a DNS address with the following line.

    netsh interface ip add dns "local area connection" 172.16.0.1
    netsh interface ip add dns "local area connection" 172.16.0.2

    It will add each additional dns entry behind the other two. To change that you can specify where you want the dns entry to be placed with the index option. So if you typed in:

    netsh interface ip add dns "local area connection" 172.16.0.3 index=1

    Your dns entries would look like:
    172.16.0.3
    172.16.0.1
    172.16.0.2

    Hope that helps.

    Does anyone know how to use the netsh command to change a dhcp address to a static address on a remote computer? I have tried the netsh -r <computername> int ip set address "local area connection" static 172.16.0.100 255.255.255.0 172.16.0.1, but it returns
    The following command was not found: int ip set address "local area connection" static 172.16.0.100 255.255.255.0 172.16.0.1.
blog comments powered by Disqus