How to configure pfSense as multi wan (DUAL WAN) load balance failover router

Datetime:2016-08-23 01:35:35          Topic: Load Balancing           Share

H ow do I setup a multi-WAN load balancing and failover on pfSense router with two ADSL or cable or leased-line or FTTH (Fiber to the home) connections?

In this tutorial you will learn how to configure pfSense to load balance and fail over traffic from a LAN to multiple Internet connections (WANs) i.e. dual wan.

Why and how to setup a dual wan router?

A dual wan setup allows you to increase your internet bandwidth. You can load balance traffic as per your needs. You can get internet connection redundancy and failover. If one connection goes down your traffic will be routed automatically to a backup connection.

Requirements

Two internet connections from two different ISPs. You can mix-match ADSL/FTTH/4G LTE/Cable/T1/FIOS connection as per your needs.

  1. pfSense router with three network ports (NICS).
  2. Two ISP modems with network port (NIC)
  3. Static or dynamic IPs from ISPs
  4. Monitor IP # 1 for ISP # 1 – 8.8.8.8 (google dns IP)
  5. Monitor IP # 2 for ISP # 2 – 208.69.38.205 (opendns IP)

Our sample setup

Fig.01: What you’ll need to get started with this setup

  1. I have two ISP modems+routers with dynamic IP address assigned.
  2. You need to connect each modem with pfsense using an Ethernet connection.
  3. You need to connect a network switch to pfsense using an Ethernet connection.
  4. All systems/servers/printers/wifi on LAN uses 172.16.1.254/24 subnet with 172.16.1.254 as a default gateway.

Configuration

Before starting, make sure all of the WAN-type interfaces are enabled with static IP WANs and with a gateway set as described above.

Step 1: Configure pfsense LAN interface

Open pfSense web interface using http://172.16.1.254/ > Interfaces > LAN and set it as follows as per (fig.01):

Fig.02: LAN interface settings

Step 2: Configure pfsense wan01 interface (ADSL ISP #1)

Open pfSense web interface using http://172.16.1.254/ > Interfaces > WAN 01 and set it as follows as per (fig.01):

Fig.02: Wan 01 (ADSL ISP 1) interface settings

Now the first WAN interface configured with a Static IP from the Interfaces menu. If you want you can set type to DHCP depending on your ISP 1 modem settings. Next make sure the gateway IP responds to ping to confirm that WAN 1 is actually online and working before proceeding. You can do this from pfSense itself by visiting Diagnostics > Ping :

Make sure the ISP #1 gateway responds to ping to confirm that each WAN 1 is actually online

Step 3: Configure pfsense wan02 interface (ADSL ISP #2)

Open pfSense web interface using http://172.16.1.254/ > Interfaces > WAN 02 and set it as follows as per (fig.01):

Fig.03: Wan 02 (ADSL ISP 2) interface settings

Now the second WAN interface configured with a Static IP from the Interfaces menu. If you want you can set type to DHCP depending on your ISP 2 modem settings. Next make sure the gateway IP responds to ping to confirm that WAN 2 is actually online and working before proceeding. You can do this from pfSense itself by visiting Diagnostics > Ping :

Make sure the ISP #2 gateway responds to ping to confirm that each WAN 2 is actually online

Step 4: Confirm both gateways are online

Once both gateways have been defined, visit Status > Gateways :

Fig.04: Wan gateways status must be green

If they’re green, the connection to the gateway is OK and you need to configure monitor IP.

Step 5: Configure monitor IP for each gateway

Visit System > Routing > Select Gateways tab and you will see a screen as follows with private IP set as monitor IP for each gateway:

Fig.05: Ensure a gateway entry exists for each WAN interface

Click on edit gateway icon (button) for wan_adsl2_l1GW (default) and set monitor IP to 8.8.8.8:

Fig.06: Set monitor IP for WAN 1 (ADSL ISP # 1)

Next, click on edit gateway icon (button) for WAN_ADSL2_L2 (ADSL ISP # 2) and set monitor IP to 208.69.38.205:

Fig.07: Set monitor IP for WAN 2 (ADSL ISP # 2)

The gateway configuration has been changed. The changes must be applied for them to take effect. So click on the Apply Changes button.

Step 6: Configuring dual WAN link load balancer

Finally, you are ready to configure the pfSense as a Load Balancer by visiting System > Routing > Select the Gateway Groups > Click the “ Add ” button:

Fig.08: Dual wan load balancer config

Where,

  • Set Group Name to “ WanLoadBalancer “.
  • Set Gateway Priority for both gateways to “ Tire 1 “. Please note that when two gateways are on the same tier (e.g. Tire 1), they will load balance. This means that on a per-connection basis, connections are routed over each WAN in a round-robin manner. If any gateway on the same tier goes down, it is removed from use and the other gateways on the tier continue to operate normally.
  • Set Trigger Level to “ Memberdown “.
  • Set Description to “ My Dual ADSL Wan Link Load Balancer
  • Finally click the “ Save ” > “ Apply Changes ” button.

Step 7: Configuring link fail over

Next, configure the pfSense as a failover for wan connections by visiting System > Routing > Select the Gateway Groups > Click the “ Add ” button:

Fig.09: Link failover for ADSL link 1 (wan1/isp1)

When two gateways are on different tiers, the lower tier gateway(s) are preferred. If a lower tier gateway goes down, it is removed from use and the next highest tier gateway is used. This is how failover works on pfSense. So to set link failover for ADSL 1:

  • Set Group Name to “ ADSLLinkFailover2
  • Set Gateway Priority wan_adsl2_l1GW (ISP 1) to “ Tire 1
  • Set Gateway Priority wan_adsl2_l2GW (ISP 2) to “ Tire 2
  • Set Trigger Level to “ Member down
  • Set Description to “ Link failover for ADSL 1

Set link failover for ADSL 2 as follows and swap Gateway Priority:

Fig.10: Link failover for ADSL link 2 (wan2/isp2)

Finally click the “ Save ” > “ Apply Changes

” button to finish the LB and failover gateway configuration.

Step 7: Configuring the firewall rules for load balancer

You need to pass traffic to these LBs using the Gateway setting on firewall rules. Click on Firewall > Rules > Lan > Add and set it as follows:

Fig.11: LB firewall rule

Click on the “ Display advanced ” button > scroll down > find Gateway option and set it to WanLoadBalancer:

Set gateway to WanLoadBalancer

Click the “Save” > “Apply Changes” button to save firewall rules.

Step 8: Configuring the firewall rules for failover

You need to pass traffic to these failover gateways using the Gateway setting on firewall rules. Click on Firewall > Rules > Lan > Add and set it as follows:

Fig.12: Failover firewall rule for ISP 1 /ADSL 1 link

Click on the “Display advanced” button > scroll down > find Gateway option and set it to ADSLLinkFailover1:

Set gateway to ADSLLinkFailover1

Click the “Save” > “Apply Changes” button to save firewall rules. Repeat the firewall rule for ADSLLinkFailover2.

Step 9: Client configuration

Make sure you assign all the IP addresses in the following range to your client computers:

  • Network: 172.16.1.254/24
  • IP ranges: 172.16.1.1 to 172.16.1.253
  • Default gateway: 172.16.1.254
  • DNS server: 172.16.1.254 (or 8.8.8.8/8.8.4.4)

Test it as follows from client system (I’m using OpenBSD):

$ ifconfig vio0
 $ netstat -nr -f inet
 $ ping -c 2 google.com
 $ host cyberciti.biz 172.16.1.254

Sample outputs:

Fig.13: Testing your pfSense LB/Failover router

You can run a speed test using fast.com or speedtest.net. You will notice and use both internet connectin when using Torrents and downloading a large file from load balancing. If one internet connections goes down, you will be still connected via failover. Share this tutorial on:




About List