Obtaining a DHCP IP address if static address is not available

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.


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


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 hereenter image description here

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


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.