PfSense LB Setup
PfSense LB Setup
nixCraft
Linux and Unix tutorials for new and seasoned sysadmin
In this tutorial you will learn how to con gure pfSense to load balance and fail over traf c from
a LAN to multiple Internet connections (WANs) i.e. dual wan.
A dual wan setup allows you to increase your internet bandwidth. You can load balance traf c
as per your needs. You can get internet connection redundancy and failover. If one connection
goes down your traf c will be routed automatically to a backup connection.
Requirements
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 1/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Two internet connections from two different ISPs. You can mix-match ADSL/FTTH/4G
LTE/Cable/T1/FIOS connection as per your needs.
Con guration
Before starting, make sure all of the WAN-type interfaces are enabled with static IP WANs and
with a gateway set as described above.
Open pfSense web interface using http://172.16.1.254/ > Interfaces > LAN and set it as follows as
per ( g.01):
Open pfSense web interface using http://172.16.1.254/ > Interfaces > WAN 01 and set it as follows
as per ( g.01):
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 3/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Now the rst WAN interface con gured 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 con rm that WAN 1 is actually online and working before
proceeding. You can do this from pfSense itself by visiting Diagnostics > Ping:
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 4/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Make sure the ISP #1 gateway responds to ping to con rm that each WAN 1 is actually
online
Open pfSense web interface using http://172.16.1.254/ > Interfaces > WAN 02 and set it as follows
as per ( g.01):
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 5/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Now the second WAN interface con gured 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 con rm that WAN 2 is actually online and working before
proceeding. You can do this from pfSense itself by visiting Diagnostics > Ping:
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 6/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Make sure the ISP #2 gateway responds to ping to con rm that each WAN 2 is
actually online
Once both gateways have been de ned, visit Status > Gateways:
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 7/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
If they’re green, the connection to the gateway is OK and you need to con gure monitor IP.
Visit System > Routing > Select Gateways tab and you will see a screen as follows with private
IP set as monitor IP for each gateway:
Click on edit gateway icon (button) for wan_adsl2_l1GW (default) and set monitor IP to 8.8.8.8:
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 8/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Next, click on edit gateway icon (button) for WAN_ADSL2_L2 (ADSL ISP # 2) and set monitor IP
to 208.69.38.205:
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 9/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 10/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
The gateway con guration has been changed. The changes must be applied for them to take
effect. So click on the Apply Changes button.
Finally, you are ready to con gure the pfSense as a Load Balancer by visiting System > Routing
> Select the Gateway Groups > Click the “Add” button:
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 11/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Where,
Next, con gure the pfSense as a failover for wan connections by visiting System > Routing >
Select the Gateway Groups > Click the “Add” button:
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 12/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
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 link failover for ADSL 2 as follows and swap Gateway Priority:
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 13/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Finally click the “Save” > “Apply Changes” button to nish the LB and failover gateway
con guration.
You need to pass traf c to these LBs using the Gateway setting on rewall rules. Click on
Firewall > Rules > Lan > Add and set it as follows:
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 14/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 15/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Click on the “Display advanced” button > scroll down > nd Gateway option and set it to
WanLoadBalancer:
Click the “Save” > “Apply Changes” button to save rewall rules.
You need to pass traf c to these failover gateways using the Gateway setting on rewall rules.
Click on Firewall > Rules > Lan > Add and set it as follows:
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 16/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 17/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Click on the “Display advanced†button > scroll down > nd Gateway option and set it to
ADSLLinkFailover1:
Click the “Save” > “Apply Changes” button to save rewall rules. Repeat the rewall rule for
ADSLLinkFailover2.
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)
$ ifconfig vio0
$ netstat -nr -f inet
$ ping -c 2 google.com
$ host cyberciti.biz 172.16.1.254
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 18/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Sample outputs:
You can run a speed test using fast.com or speedtest.net. You will notice and use both internet
connection when using Torrents and downloading a large le from load balancing. You can
use the speedtest-cli as follows to verify that bandwidth is doubled from a client computer:
$ python speedtest-cli
If one internet connections goes down, you will be still connected via failover.
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 19/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
What next?
You will get the wan (internet) connection redundancy and load balancing but not the router
redundancy. Your internet connection will go down, if your pfSense router failed due to
hardware problems. This draw back can be addressed using router redundancy setup.
19 comment
It’s important to note that the setup, above, should have a Static IP address assigned, by the
ISP. Most business accounts will include a few Static IPs (anywhere from 3 – 16 addresses), as
part of the service agreement.
However, if you’re trying this on a private ISP connection, you’ll either have to ask your ISP for
as Static IP address. Or you’ll have to con g your WAN interface to grab an address via DHCP,
rst. And, then, either use ‘as-is’.
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 20/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Or, recon gure the WAN interface to use the DHCP address as a static address.
[NOTE: Grabbing an IP via DHCP, then entering it as a ‘Static IP’, will BREAK your con guration,
in the event that your ISP updates their network, or there is a long-term power outage…. or just
anything that may cause your ISP Modem (or pfSens) to refresh the DHCP Lease.]
How does this setup handles nat? If there is a web server or ftp server working within the
internal network will it continue to work if one of the ISPs goes down? Is there a speci c way to
con gure nat/rules if the user wants to host email or web services behind that router?
Yes. Just add new gateway groups and rewall rules for each of the conditions in which you
would want to operate the rewall.
Nice tutorial! just one thing, the SSL traf c, I’ve noticed problems with apps like banking and
CPanel, last one complains “same session with 2 differents IPs” and you get to the login page
again, personally I separate the SSL traf c from HTTP using source port in the rewall rules
and using failover rules like you show us for SSL only.
Francisco
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 21/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Hi !
I believe “failover” is useless on the latest pfsense version
if load balance have only two WANs.
can you con rm ?
Also, some servers may generate problems if using two different IP when accessing them.
Do you know some solution else than the “stick to ip” on the general options ?
I have now 3 gateway groups, one load balancer and two failover.
I’m about to con gure the rewall rules.
What should be the order of these rules, or is it optional??
Thanks! :)
hi,
May i ask also if i need a wan load balancer if i want to separate a browsing traf c from other
traf c. like gaming..
Hi after setting everything it seems to work, but if for example I disconnect my wan1 cable I
cannot browse anything from the lan via my wan2, if I do a ping disgnistic on the second wan
it will send the packets ok, am I missing soemthing?
Regards
For anyone having this issue I resolved it by going to rewall > lan > edited the lan rule and
added on gateway Wanloadbalancer
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 22/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
Sorry this did not x anything I am still having trouble to browse from the lan, and this
only made a combine of the 2 ISPs having dif culties since Ip changes a lot.
thank you for this nice tutorial! Helped me a lot! In Step 7 and 8 there are two different Firewall
> Rules > Lan > Add. One “Add” adds on top, the other on the bottom. As I remarked, the
position is also important. Mabye you could add a screenshot in the end whith the positions of
the rewall rules.
would like to know how i should add rewall rukles with this setup i have a email server on the
lan network and i have a dyndns running to to auto update to the best external ip at the time
how can i setup the rewall tio send and receive the email ports over this load balance rule?
Hi
Can you update this tutoriul for connect 3g modem? Please
Sometimes the WAN connections aren’t of the same bandwidth. so in this case the WEIGHT
option is useful (System->Routing->Gateway) edit the gateway and in Advanced Option set a
Weight.
Hi Vivek Gite,
Good Day,
May I know?
Can pfsense :
1. give me bandwidth BONDING or AGGREGATION OR ADD bandwidth
eg.
If I have 8 dynamic ip WAN that is asymmetrical with such speeds of : upstream = 50Mbps ,
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 23/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
downstream = 100Mbps
this is the maximum link speed that I can subscribe at my current location.
I have 100+ cpu/windows PC for gaming purposes
location = malaysia post code 75450
meaning will pfsense give me 400Mbps upstream bandwidth and 800Mbps downstream
bandwidth?
thus provides 4Mbps for each PC of upstream speed/bandwidth
this is my primary router
I may face a challenge of getting 8 PCI Ethernet card slots PC to work on pfsense.
does pfsense works with usb/lan adapter to use as wan?
can I also con gure in same network a backup router (secondary) with dedicate 4 WAN of
similar specs above so when any of the 1st pfsense WAN fails or its router fails, 2nd router with
separate WAN will take over.
can I also con gure pfsense secondary router to return to primary router as soon as the outage
at primary router is restored?
PRIVACY
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 24/25
1/7/2019 How to configure pfSense as multi wan (DUAL WAN) load balance failover router - nixCraft
TERM OF SERVICE
CONTACT/EMAIL
DONATIONS
SEARCH
https://www.cyberciti.biz/faq/howto-configure-dual-wan-load-balance-failover-pfsense-router/ 25/25