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 have seen some questions that are similar to my problem but not a good solution.

Ex. User has a laptop and has a static IP address at the office. They also take the laptop off site where they also need internet.

Is there a way to configure their computer so that it will obtain an IP address automatically when the configured static address is not available (without making the user go into network configuration and changing to obtain automatically)?

share|improve this question
    
Don't know the answer for Windows 7, but many years ago (the XP times) some laptop manufacturers had their own software to handle this, one could define different settings for different locations and switch between them; I think the IBM one was called Access Connections or something similar. From what I remember, using the built-in network XP settings one could do this with Alternate Configuration or something like that, but it didn't work well. –  lupincho Jun 29 '12 at 19:40
    
Why don't go the other way around, configure the DHCP server at the office to assign user an static IP so it will always work. –  jhcaiced Jun 29 '12 at 22:53

4 Answers 4

up vote 8 down vote accepted

I don't know if there's an automatic way, but the way I did it with my laptop was with a program called Mobile Net Switch. http://www.mobilenetswitch.com/ It lets you juggle between different active network configurations so you can have one for your work network and when you go off site, you switch to the network configuration that is set to obtain DHCP automatically.

An alternate solution if your router has this feature in its firmware is to configure Static DHCP for that device. Get the laptop's wireless MAC address, and if your router supports it, configure it to automatically assign a static IP address on the router. Third party router firmwares like Tomato and DD-WRT support this out of the box. I feel this is the cleanest solution. Using this method will allow your user to keep the laptop set on DHCP mode without any problems. I use this setup for my home network so I don't have to worry about manual configuration on the device side - all configuration is done from the router.

share|improve this answer
    
I don't really want to put any other software on it, I don't want users to have to do anything. It would be nice if DHCP could just be an "Alternate Configuration" when static is not available but there is probably a reason its not. The second solution seems like my best bet, thanks. –  user142485 Jun 29 '12 at 19:44
5  
Agreed. Don't use statis IP addresses. Create reservations in your DHCP server instead. –  jftuga Jun 29 '12 at 19:51

A lot of people are not aware that the Windows network configuration can be adjusted through the command line. For example:

Set your network adapter to DHCP

netsh interface ipv4 set address "Local Area Connection" dhcp
ipconfig /renew

Set your network adapter to static IP

netsh interface ipv4 set address "Local Area Connection" static 10.1.2.3 255.0.0.0 10.0.0.1

With that in mind, it becomes trivial to write 2 .bat files which you can put on your desktop.

This makes it a lot easier to switch network configurations

share|improve this answer
    
Depending on the wireless adapter, you might also be able to assign it to run these when they connect to each network so that minimal user intervention is needed (probably when new networks are added) –  Nick Jul 5 '12 at 20:01

Windows 7 has the concept of an "Alternate Configuration" in the network card's IP configuration. From the Windows Help page for "IPv4 Alternate Configuration Tab":

User configured specifies that IPv4 will use a manually specified configuration if a DHCP server is not found. This alternate configuration is useful when the computer is used on more than one network, at least one of the networks does not have a DHCP server, and an APIPA configuration is not wanted. A good example is a portable computer that is used at the office and at home. At the office, the laptop uses a DHCP-allocated TCP/IP configuration. At home, where there is no DHCP server present, the portable computer automatically uses the alternate configuration, allowing easy access to home network devices and the Internet. This enables the portable computer to operate seamlessly on both networks without manual IP reconfiguration.

Set this up by going to Control Panel -> Network status and tasks (or "Network and Sharing Centre" if you're not using the category view).

Click the connection name that you're interested in (probably "Local Area Connection" or "Wireless Network Connection (network name)").

enter image description here

This should pop up the Connection Status window, click the Properties button. enter image description here

In the Connection Properties window, look for the "Internet Protocol Version 4 (TCP/IPv4)" line, click that and click Properties.

enter image description here

You should now have a window with two tabs, one of which is "General", the other is "Alternate Configuration".

You can now set the first tab to use DHCP (select "Obtain an IP address automatically" and "Obtain DNS server address automatically") and put your static IP details into the second "Alternate Configuration" tab.

enter image description here enter image description here

More from Technet IPv4 Alternate Configuration Tab and elsewhere on SuperUser What is the "Alternate Configuration" tab in TCP/IP settings

share|improve this answer
    
This of course assumes that the reason you've got a static IP address is because there's no DHCP available at the office. On the other hand, if you do have DHCP in the office then why not just leave the laptop set to DHCP all the time and reserve the IP address for the machine on the DHCP server? –  GAThrawn Jul 6 '12 at 13:35
    
I agree with reserving the address in DHCP, that was the answer I accepted. Even-so, this is a great write-up for configuring IP properties, thanks for the input. –  user142485 Jul 6 '12 at 13:54

Not that I know of. Configuring a static address is analogous to telling the computer to completely ignore the network - a static address is in concept "always available" (barring a IP conflict) from the computer's point of view.

If you can find a way to use multiple network interfaces, configure one for DHCP and one for static, and set the static one to have a higher metric (cost) than the DHCP one. This will cause the system to use the DHCP if it's available, but fall back to the static one if the system isn't connected to a DHCP network. Most laptops don't have this, so you might need to use a USB network interface to achieve this.

If you're using a laptop running linux (you tagged windows 7, so this is more for completeness), then you can use IP aliasing to assign two IPs to the same interface. Combine with the above idea to create a network port which will try to use DHCP, but fall back to static IP if DHCP fails.

share|improve this answer
    
Your second paragraph seems like it would work, you switched your words in the second sentence though. –  user142485 Jun 29 '12 at 19:46
    
@user142485 Which words? I'm not noticing the ones to which you're referencing. –  Darth Android Jun 29 '12 at 20:00
1  
@user142485 You can't do that, as there's no way to detect when a static IP is "unavailable" (see my first paragraph). On the other hand, you can detect when DHCP is not available (given a timeout), and fall back to a static IP. –  Darth Android Jun 29 '12 at 20:04
1  
@user142485 I see. The issue is there is no way to tell the difference between a misconfigured static address, or a failing/temporarily unavailable gateway and a correctly configured static address. –  Darth Android Jun 29 '12 at 20:25
1  
I guess this answers my question on why my desired configuration is not an option: because it is expecting the address to be usable and in theory, that address could temporarily have limited access (due to a down gateway as you exemplified) and would not want to be changed in the event that the gateway would come back. Thanks for the explanation. –  user142485 Jun 29 '12 at 20:36

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.