Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use my Windows 7 laptop at work and at home. At work, I connect through the network, and must specify a static IP, gateway, and static DNS servers. At home, I can connect using automatic configuration.

My problem is that I have to switch between the manual configuration and the automatic one when I move between locations. The gateway and DNS addresses for work do not function at home, and vice versa.

Is there a way to set up the ethernet adapter to automatically switch configurations?

I tried setting the work options in the adapter's IPv4 settings, and then adding the gateway and DNS servers from home in the advanced section of the IPv4 settings, but I can't seem to get it to work.

Is there anything I'm missing?

share|improve this question
    
Can you vpn into the network as an alternative. This will issue you the local ips, DNS, etc. with out having to change your connection setting. –  iDev Jan 25 at 22:33

3 Answers 3

up vote 2 down vote accepted

The best way I can think of is to create a batch file to do it for you. Copy and paste the below code into filename.bat then edit the various settings to match your configuration.

@ECHO OFF

REM Static IP
set varip=65.88.48.77

REM Subnet Mask
set varsm=255.255.255.224

REM Gateway
set vargw=65.88.48.65

REM Primary DNS
set vardns1=66.78.202.254

REM Secondary DNS
set vardns2=66.78.210.254

REM ***** You don’t need to change anything below this line! ******

ECHO Setting IP Address and Subnet Mask
netsh int ipv4 set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm%

ECHO Setting Gateway
netsh int ipv4 set address name = "Local Area Connection" gateway = %vargw% gwmetric = 1

ECHO Setting Primary DNS
netsh int ipv4 set dns name = "Local Area Connection" source = static addr = %vardns1%

ECHO Setting Secondary DNS
netsh int ipv4 add dns name = "Local Area Connection" addr = %vardns2%

ECHO Here are the new settings for %computername%:
netsh int ipv4 show config

pause

And, in a separate batch file, to change back to DHCP

netsh interface ipv4 set address "Local Area Connection" dhcp

You might need to change "Local Area Connection" to what ever the name of your network card is that you are changing.

share|improve this answer
    
OK, I'll give this a shot. Thanks for taking the time to reply. –  evanjdooner Jan 24 at 13:53
    
That works perfectly. Thanks a lot! –  evanjdooner Jan 25 at 1:02
    
No problem @evanjdooner. I'm glad I could help. –  imtheman Jan 25 at 19:17

To keep this simple, I would speak with someone in the networking department and see if they will block your MAC address from DCHP. This should allow you to use the Alternative Configuration option under the tcp/ip properties. Chose DHCP for the general tab and place your static info under the Alternative tab. When at home, your laptop will get assigned an IP from your home router. When at work, Windows will first attempt to get an auto. IP but then use the static when DHCP cannot retrieve an address. I am saying this assuming that not everyone at your workplace has a static IP(I would hope not)- An exception can then be made for you so that your laptop's Ethernet card isn't distributed an IP address when it contacts the DHCP server.

share|improve this answer
    
+1. Note though that using the "Alternate Configuration" requires waiting for the DHCP request to time out before continuing; which adds (at least) a 30 second delay when connecting. –  Billy ONeal Jan 24 at 5:01
    
I don't think that solution will be possible, due to the way the network is administrated at work. Thanks for your suggestion though! –  evanjdooner Jan 24 at 13:54

you should be able to add multiple gateways,dns servers and ip addresses.

For the ip address you may have to change the order

share|improve this answer
1  
Can you provide any further details on how to accomplish that? –  Dracs Jan 24 at 3:31
1  
-1. First, this is completely false. Second, even if it was true, it wouldn't help this user. –  Billy ONeal Jan 24 at 5:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.