Friday , June 21 2024
Home - Don't Forget! - Scripting Windows 2008 DHCP for ISP Failover

Scripting Windows 2008 DHCP for ISP Failover

Having two ISP connections and switch between them automatically is more a hardware (or Software -TMG) solution.  But I found a way to script the Windows DHCP server using the netsh command.

This allows for a site admin to run either of two scripts to change the default gateway on the server(s) and dhcp scope options for clients.

An example of such script:

netsh Dhcp Server \\ set optionvalue 3 IPADDRESS “”
netsh interface ipv4 delete route “Local Area Connection”
netsh interface ipv4 delete route “Local Area Connection”
netsh interface ipv4 add route “Local Area Connection”

The netsh dhcp servercommand changes the scope with the ip addressing of on server \\ to use the first ISP of

The next netsh commands clear out and set the default router ip address on the Local Interface named ‘Local Area Connection’.

A second batch is given to the site admin to change the same setting but use the second ISP default router ip address of

The netsh command looks like a very powerful tool.  From this you can export out the full DHCP server settings and use the output file to create a new dhcp server on other hardware.  Without changing a line of the exported file,  just like Cisco IOS config files.

Note:  The clients do not see the change of default router until they renew their IP address.This could be expanded I know, my scripting head is crying for a ping check on change ISP automatically….

Check Also

The pain of TLS 1.2 with PowerShell module for Azure Active Directory (MSOnline)

Building labs in a hurry sometimes can bite you with recent changes in Office 365 …

One comment

  1. Amiable post and this fill someone in on helped me alot in my college assignement. Gratefulness you as your information.

Leave a Reply

Your email address will not be published. Required fields are marked *