Tuesday , October 15 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 \\192.168.0.1Scope 192.168.0.0 set optionvalue 3 IPADDRESS “192.168.0.2”
netsh interface ipv4 delete route 0.0.0.0/0 “Local Area Connection” 192.168.0.2
netsh interface ipv4 delete route 0.0.0.0/0 “Local Area Connection” 192.168.0.3
netsh interface ipv4 add route 0.0.0.0/0 “Local Area Connection” 192.168.0.2

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

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 19.168.0.3.

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 *