Juniper

From Cresswell.org
Jump to navigation Jump to search

How to configure a Juniper SSG firewall to failover with two dhcp internet connections.

Example 1: Simple failover

I have my firewall connected as per the diagram. My goals are: 1. To have a constant internet connection even if one of the providers goes down 2. To use ISP1 as my primary connection, and switch to ISP2 only if ISP1 is down (this may be for any reason, in my case I have 20Mbit/sec downloads with ISP2, and only 10Mbit/sec with ISP2)

Primary setup:

ethernet0/0 provides DHCP for my network using the subnet 192.168.12.0/24 ethernet0/1 gets a DHCP address from ISP1 ethernet0/2 gets a DHCP address from ISP2

Traffic from ethernet0/0 is NAT'ed through the interface that it leaves through

DNS that I used in this example is provided by google, because the DNS servers from ISP1 were not reachable through ISP2, so I used google DNS servers because they are reachable from either ISP.

Configuration: set interface eth0/0 zone trust set interface eth0/0 ip 192.168.12.1/24 set interface eth0/0 route set interface eth0/0 dhcp server enable set interface eth0/0 dhcp server option gateway 192.168.12.1 set interface eth0/0 dhcp server dns1 8.8.8.8 set interface eth0/0 dhcp server dns2 8.8.4.4 set interface eth0/0 dhcp server ip 192.168.12.10 to 192.168.12.100

set interface eth0/1 zone untrust set interface eth0/1 route set interface eth0/1 dhcp client enable set interface eth0/1 monitor track-ip ip 8.8.8.8

set interface eth0/2 zone untrust set interface eth0/2 route set interface eth0/2 dhcp client enable set interface eth0/2 monitor track-ip ip 8.8.8.8

set policy from trust to untrust any any any nat src permit


Conclusion:

With this setup I was able to get failover to work. The monitor statements caused the default route (0.0.0.0/0) to be removed from the routing table when the track ip was unreachable. However this setup was not optimal because I found that sometimes I would get switched over to ISP2 even if ISP1 was up. I redesigned in example 2 to fix this issue.


Example 2: Dual zone failover

The connections are all going to the same place as in example 1.

Configuration: set zone name untrust2 set vrouter untrust2-vr set zone untrust2 vrouter untrust2-vr

set interface eth0/0 zone trust set interface eth0/0 ip 192.168.12.1/24 set interface eth0/0 route set interface eth0/0 dhcp server enable set interface eth0/0 dhcp server option gateway 192.168.12.1 set interface eth0/0 dhcp server dns1 8.8.8.8 set interface eth0/0 dhcp server dns2 8.8.4.4 set interface eth0/0 dhcp server ip 192.168.12.10 to 192.168.12.100

set interface eth0/1 zone untrust set interface eth0/1 route set interface eth0/1 dhcp client enable set interface eth0/1 monitor track-ip ip 8.8.8.8

set interface eth0/2 zone untrust2 set interface eth0/2 route set interface eth0/2 dhcp client enable set interface eth0/2 monitor track-ip ip 8.8.8.8

set route 0.0.0.0/0 vrouter untrust2-vr preference 20

set policy from trust to untrust any any any nat src permit set policy from trust to untrust2 any any any nat src permit

Explanation: In this example eth0/1 will be the primary connection, as the route added by DHCP has a preference of 0. The monitor will still remove this route in the event that the track IP becomes unreachable, and then the static route to untrust2-vr will become active. The default route from ISP2 will be active in untrust2-vr as long as the track IP is reachable. This accomplishes everything I set out in my objectives, but this configuration does have the drawback of requiring a separate zone, and a separate policy. If you have a lot of policies on outgoing traffic you will have to duplicate those policies for both zones.