Configuring 2 routers in the same LAN
I have been trying to build an internet redundancy with two routers.
The coniguration is as follows:
I got 1 router (A) connected to ISP-X.
I got 1 router (B) connected to ISP-Y.
The ISPs are off course different, and both are connected just fine.
I have configured my DNS servers like this (by priority):
1) Main DC
2) Router (A)
3) Router (B)
Now, everything works just fine (all clients have their network configured automatically, and all connect to the internet), however, when Router (A) disconnects from ISP-X, the clients can't resolve the DNS since they won't switch to router (B).
I have both routers configured in the DHCP scope options (prioritized as shown above), I also have them configured in the DHCP scope - DNS options.
Why won't my clients try to use Router (B) when Router (A) DNS routing is down?
More to it than what meets the eye
You can't just take two residential gateway routers from Staples, CompUSA or Future Shop and expect to network them with WAN fail over. They aren't designed to do that. What Model of Router's are you using?
In order to achieve dual ISP redundancy you should be only using 1 Router with 2 Wan ports. This router must support WAN port fail over. Fail over is achived by a ping server built into the router and configured on one of the WAN port interfaces.
Please Note: DNS has nothing to do with WAN fail-over. You can use any DNS server you want to resolve internet addresses as long as the DNS server permitts you to use their service. (Best practice is to use your assigned ISP's DNS for each connection).
Typically on most routers when you enable redundancy on the primary WAN port this internet connection remains unused until the first WAN port goes down. At this point the outgoing WAN port becomes WAN port 2. It is possible however to route traffic out different WAN port's simulataneously but that requires advanced networking experience.
Keeping things simple, you enable the ping server on WAN port 1 to perform a constant ping to the gateway of that ISP & set the "Dead Gateway Detection" value of 60 seconds and "Fail-over Detection" to 5 Seconds.
Now you need to create a policy to direct traffic out WAN port 2 when WAN port 1 goes down. For Example: Firewall Policy > Source Internal: All --> Destination WAN 2 > All: Destination > All: Schedule > Always: Service > Any: Action > Accept: Enable NAT on Policy.
Now when the Ping server is enabled on WAN Interface 1 that will automatically indicate to the router that upon 60 seconds with 5 failed ping attempts fail-over to WAN2 and your firewall policy will automatically direct traffic out the second WAN port using your second internet provider connection.
Here's a Software implementation
Okay... i've done a bit of searching and found this VB script for altering "the default gateway" upon dead gateway detection. Just follow the comments in the script and input your values as required. Make sure the public IP PING_IP is something other than your internal network IP address preferably the ISPs Gateway IP for the primary segment. This assumes you have 2 NIC's in your DC configured each with their own gateway to the internet through each router.
----> Beginning of Script
' The script will check the availability of the PING_IP on the current ISP and then switch between them
' when one fails every XX seconds (managed by WaitVal). If SwitchBack is 1 then it will switch back
' to ISP1 when it is available. The script does NOT change NIC configuration values, only the
' routing table for the default route.
'
strDebug = 2 ' Set variables for output - 0 is no output, 1 is output for initialization, 2 is full output
SwitchBack = 0 ' If switchback=1 then switch back to ISP1 when available
RouteFlag=1 ' Set RouteFlag = 1, 1 is ISP1, 2 is ISP2
WaitVal = 5000 ' Number of milliseconds to wait between gateway checks
SwitchWait = 720 ' Number of loops before rechecking ISP1 if SwitchBack is one. The check may disconnect all internet traffic
'
' Set up the two different ISP IP addresses and names
ISP1_IP = "xx.xx.xx.xx"
ISP1_GateWay = "xx.xx.xx.xx"
ISP2_IP = "xx.xx.xx.x"
ISP2_GateWay = "xx.xx.xx.xx"
PING_IP = "xx.xx.xx.xx"
'
' These adapter names must match the NIC exactly
ISP1_AdapterName = "Primary ISP"
ISP2_AdapterName = "Secondary ISP"
'
' Create necessary objects
Dim WshShell
Dim ISP1MAC
Dim ISP2MAC
Set WshShell = CreateObject("WScript.Shell")
'On Error Resume Next
strComputer = "." ' This computer
'
' Choose ISP1 adapter by Name
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objISP1Adapter = objWMIService._
ExecQuery("Select * from Win32_NetworkAdapter where NetConnectionID = '" _
& ISP1_AdapterName & "'") ',,48)
'
' Choose ISP2 adapter by Name
Set objISP2Adapter = objWMIService._
ExecQuery("Select * from Win32_NetworkAdapter where NetConnectionID = '" _
& ISP2_AdapterName & "'") ',,48)
'
' Store the MAC addresses of each interface
if strDebug <> 0 then Wscript.Echo "================================================= =================="
For Each objItem in objISP1Adapter
if strDebug <> 0 then Wscript.Echo "Primary ISP MACAddress: " & objItem.MACAddress
ISP1MAC = objItem.MACAddress
ISP1InterfaceIndex = Hex(objItem.InterfaceIndex)
if strDebug <> 0 then Wscript.Echo "Primary ISP InterfaceIndex: " & ISP1InterfaceIndex
Next
For Each objItem in objISP2Adapter
if strDebug <> 0 then Wscript.Echo "Secondary ISP MACAddress: " & objItem.MACAddress
ISP2MAC = objItem.MACAddress
ISP2InterfaceIndex = Hex(objItem.InterfaceIndex)
if strDebug <> 0 then Wscript.Echo "Secondary ISP InterfaceIndex: " & ISP2InterfaceIndex
Next
if strDebug <> 0 then Wscript.Echo "================================================= =================="
'
' Choose ISP1 adapter CONFIGURATION by MACAddress
Set CONFobjISP1Adapter = objWMIService._
ExecQuery("Select * from Win32_NetworkAdapterConfiguration where MACAddress = '" _
& ISP1MAC & "'") ',,48)
' Choose ISP2 adapter CONFIGURATION by MACAddress
Set CONFobjISP2Adapter = objWMIService._
ExecQuery("Select * from Win32_NetworkAdapterConfiguration where MACAddress = '" _
& ISP2MAC & "'") ',,48)
For Each objItem in CONFobjISP1Adapter
if strDebug <> 0 then Wscript.Echo "Primary ISP Description: " & objItem.Description
ISP1MAC = objItem.MACAddress
Next
For Each objItem in CONFobjISP2Adapter
if strDebug <> 0 then Wscript.Echo "Secondary ISP Description: " & objItem.Description
UltraMAC = objItem.MACAddress
Next
if strDebug <> 0 then Wscript.Echo "================================================= =================="
SwitchCount = 0
Do
'
' The loop checks the public IP PING_IP to see if it is reachable. If so, then it is assumed the
' ISP is up. If not, it is assumed the ISP is down. Later a periodic check is done which
' will see if ISP1 is up and switch to it if it is up.
'
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonat e}")._
ExecQuery("select * from Win32_PingStatus where address = '" _
& PING_IP & "'")
For Each ISPStatus in objPing
If IsNull(ISPStatus.StatusCode) or ISPStatus.StatusCode<>0 Then
if RouteFlag = 1 Then
if strDebug = 2 Then WScript.Echo "Primary ISP Status PING Status Code: " & ISPStatus.StatusCode
if strDebug = 2 Then WScript.Echo " " & Now() & " ####### Switching to Secondary ISP ##########"
' Change the routing table to use ISP2 gateway for default route
WshShell.Run "route DELETE 0.0.0.0", True
WshShell.Run "route ADD 0.0.0.0 MASK 0.0.0.0 " & ISP2_Gateway, True
RouteFlag = 2
SwitchCount = 0
ElseIf RouteFlag = 2 Then
if strDebug = 2 Then WScript.Echo "Secondary ISP Status PING Status Code: " & ISPStatus.StatusCode
if strDebug = 2 Then WScript.Echo " " & Now() & " ####### Switching to Primary ISP ##########"
WshShell.Run "route DELETE 0.0.0.0", True
WshShell.Run "route ADD 0.0.0.0 MASK 0.0.0.0 " & ISP1_Gateway, True
RouteFlag = 1
End If
End If
Next
' If switchback is set then increment the counter and see if we should test again
If SwitchBack = 1 And RouteFlag = 2 Then
SwitchCount = SwitchCount + 1
If SwitchCount = SwitchWait Then
if strDebug = 2 Then WScript.Echo "Checking Primary ISP Status"
if strDebug = 2 Then WScript.Echo " " & Now() & " ####### Switching to Primary ISP ##########"
WshShell.Run "route DELETE 0.0.0.0", True
WshShell.Run "route ADD 0.0.0.0 MASK 0.0.0.0 " & ISP1_Gateway, True
RouteFlag = 1
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonat e}")._
ExecQuery("select * from Win32_PingStatus where address = '" _
& PING_IP & "'")
For Each ISPStatus in objPing
If IsNull(ISPStatus.StatusCode) or ISPStatus.StatusCode<>0 Then
if strDebug = 2 Then WScript.Echo "Primary ISP Status PING Status Code: " & ISPStatus.StatusCode
if strDebug = 2 Then WScript.Echo " " & Now() & " ####### Switching back to Secondary ISP ##########"
' Change the routing table to use ISP2 gateway for default route
WshShell.Run "route DELETE 0.0.0.0", True
WshShell.Run "route ADD 0.0.0.0 MASK 0.0.0.0 " & ISP2_Gateway, True
RouteFlag = 2
SwitchCount = 0
Else
if strDebug = 2 Then WScript.Echo "Primary ISP up, leaving active"
End If
Next
End If
End If
WScript.Sleep WaitVal
Loop
<---- End of Script
Now we need to find a way to have the client PC's receive the updated gateway information without causing too much of a hassle.
Something Simple Made Complicated...
Unfortunately if you were running a Terminal Server this script would work wonders for TS Clients. However, due to complications (DHCP Server Service and Clients obtaining IP information from this service) I'm not sure we can address this with a simple software solution. Even by creating a script to run on the individual client workstations it would require admin permissions to run on the local workstation which would prove to be a security risk for your network. Here's a couple links to finding a hardware device that can suite your needs:
http://www.freedom9.com/products/product.php?p=28
http://www.sonicwall.com/us/products/TZ_170_Series.html
If the majority of your systems are XP or earlier...
I wouldn't waste too much time with that vista article as the TCP/IP stack in Vista has been modified to provide for proper dead gateway detection fail-over... Where as, in XP and prior operating systems it really wasn't fully designed for that. Vista has its advantages =)