How to Setup Failover and Load Balancing in PFSense

Step 4: Configuring Gateway Group

10. After configuring Gateway monitoring, click on Groups to create a Gateway Group. Click + button right to add new GW group.

Create Gateway Group
Create Gateway Group

11. Give a Group Name and choose Tier for WAN1 and WAN2 and make changes by clicking on Save.

I have provided my group name as TecmintADSL and chosen tier1. To obtain a LoadBalancer we have to select more than one gateway in same tier.

Give Gateway Group Name
Give Gateway Group Name
Configured Gateway Groups
Configured Gateway Groups

Step 5: Configuring Firewall Rules

12. After creating a Group, now it’s time to create firewall rules for the created group, to assign the Rules, navigate to “FIREWALL” from top and choose “RULES“.

Choose the LAN interface and edit configuration.

Configure Firewall Rules for Group
Configure Firewall Rules for Group

13. At the bottom of the page, choose the created Gateway Group “TecmintADSL” by clicking on Advanced under Gateway option and click on save to Apply changes to make the changes permanent.

Configure Firewall Gateway
Configure Firewall Gateway

After applying modifications, you can see the gateway and advanced icon as show below.

Confirm Firewall Settings
Confirm Firewall Settings

We have successfully setup-ed our LoadBalancer, Now let us verify how it work’s.

Step 6: Testing LoadBalancer

14. To verify the Load Balancer, go the ‘Status‘ from the top Menu and click on “Gateways” to verify that the both Gateways are online.

Confirm Gateway Status
Confirm Gateway Status

15. To get the real time Graph we can use “Traffic Graph” under “Status” menu.

Real Time Traffic Graph
Real Time Traffic Graph

Step 7: Setup Failover Using Pfsense

16. To setup a failover in Pfsense, we need to create different Tier, navigate to “System” menu and choose “Routing“. There we can see Gateways already assigned for LoadBalancer, so let’s create two groups for failover now.

Choose “Groups” under System: Gateway Groups. Here we will create two groups, the first group we will be creating for WAN1 and the second group for WAN2, if WAN1 fails it will automatically switch to WAN2 and vise-versa.

Create a Group in the name of WAN1Failover, Choose WAN1 with Tier1 and WAN2 with Tier2, if WAN1 fails it will switch to WAN2. Choose Packet Loss for Tigger Level, When ever ping reply to DNS packet Loss it will switch to WAN2.

Create Failover Groups
Create Failover Groups

17. Follow the same above instructions for creating WAN2Failover group. Choose WAN2 with Tier2 and WAN2 with Tier1, If WAN2 fails it will Switch to WAN1. Choose Packet Loss for Trigger Level. Here to when ever ping fails to DNS it will Switch to WAN1.

Create Failover WAN2 Group
Create Failover WAN2 Group

Now, we will get three groups, first for LoadBalancing, second and third for Failover.

Confirm System Gateway Groups
Confirm System Gateway Groups

Step 8: Configure Firewall Rules for Failover

18. Now, here we need to assign firewall rules for failover, To configure firewall rules navigate to “Firewall” and choose “Rules“. Under LAN we have to add new rules for failover.

Click on + Symbol in right side to add new rules.

Add FailOver Firewall Rule
Add FailOver Firewall Rule

Make changes to below options.

  1. Interface = LAN
  2. Protocol = any
  3. Source = LAN net
  4. Description = What ever you wish for fail-over.
Configure FailOver Firewall Rule
Configure FailOver Firewall Rule

Under advance settings of Gateway choose WAN1Failover and save, repeat the same instructions to configure WAN2Failover.

Select FailOver Gateway for WAN1
Select FailOver Gateway for WAN1
Select FailOver Gateway for WAN2
Select FailOver Gateway for WAN2

19. After adding the above rules, you can see the below listed rules for both LoadBalancer and Failover.

Confirm LoadBalancer Failover Rules
Confirm LoadBalancer Failover Rules

20. Now it’s time to assign at least one DNS server for our Gateway and apply changes and make sure to check the Status of our Gateway.

From “System” Menu choose “General Setup” and check for DNS respectively, which we have assigned under gateway.

Add DNS IP Addresses
Add DNS IP Addresses

Choose “Status” menu and click on “Gateways” to get the status.

Check DNS Status
Check DNS Status

That’s it we have successfully deployed a Failover in pfsense.

Conclusion

The above pfsense LoadBalancer and Failover setup can be used in home or office environments only if you have Dual ISP connection’s. Instead of paying for a branded dedicated Router with LB options we can use this setup to build a LB with Failover.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

41 thoughts on “How to Setup Failover and Load Balancing in PFSense”

  1. I configured pfSense as described but found it does not work as documented (or at least as I interpreted it). In step 19 the rule with the TechmintADSL gateway will be valid for all IPv4 traffic and all IPv4 will be load balanced.

    The 2 rules with WAN1Failover and WAN2Failover as gateways will never be used since all traffic match the rule higher in the list. This is exactly what my configuration was doing.

    You would either have to limit the traffic for each rule so that they cover specific traffic that doesn’t overlap with another rule below it. In other words, you might have a rule with WAN1Failover that matches http/https traffic and another rule for TechmintADSL that matched anything to send everything else via load balancing.

    Reply
  2. Hello ! please i have a question how i can test the 2 WANs by putting one of them up or down
    i don’t know how to test it

    Reply
  3. I did exactly as in guide, but performance is horrible. With dual WAN my overall speed is same as one WAN.
    Tested with 5 clients connected to pfsense doing various different transfers over the internet.
    Please write how to fix this.

    Reply
  4. Hello I did these instructions and it was successfully been worked with the process but the problem is the traffic shaper or limiter is not working properly I set up some 2 mpbs in and out but the result in speed test is now with the given speed. how should i fix this?
    thank you in advance

    Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.