other:networking:opnsense:multiwan
This is an old revision of the document!
Table of Contents
Multiple External WAN connections
Occasionally, you need more than one external network connections. If one outside (WAN, Internet, whatever you want to call it) fails, your router should automatically swap to a second.
OpnSense has done an excellent job of setting this up.
This is just a recipe. If you want to know what is going on, RTFM. It is a good document with a lot of detailed information.
Anyway, here is my “quick and dirty”
My Scenario
Using a Protectli (https://protectli.com/) Vault with 4 ports
- WAN Port - Connected to Internet Provider via their modem (or their router in pass-through mode)
- LAN Port - My LAN
- OPT1 Port - Connected to a GL-iNet Puli Cellular Router
- OPT2 Port - Wireless Access Point (separate subnet). I am not setting this up in this document
Preparation
- Choose a separate Monitor IP for each WAN connection. In my case, I'm using 9.9.9.9 for the primary WAN, and 1.1.1.1 for the failover, but it can be any two reliable targets. Google at 8.8.8.8 and 8.8.4.4 is good.
- If you are doing any N2N (site-to-site) VPN's from your router, collect the subnet range for all targets, in other words, all of the remote LAN's you connect to over the VPN. Hint: Open each VPN connection and just copy the ranges from there.
Mess with Gateways
- Add monitor IP's
- System | Gateways | Configuration
- For each gateway
- Disable Gateway Monitoring: UNCHECK
- Monitor IP: enter the IP you chose for this gateway
- Mark Gateway Down: UNCHECK
- Save
- When done, you should see all columns filled in, RTT, RTTd, Loss
- Set up Gateway Group
- System | Gateways | Group
- Add Group
- Name: WANGROUP
- set the primary gateway to be Tier1
- Set the secondary to be Tier2
- Set Trigger Level to be Packet Loss
- Put in a description like Failover Group
- Save
Set up separate DNS for each
- System | Settings | General
- For each gateway
- Enter one or more separate DNS server
- They must NOT be the same, for some reason
Firewall Rules
- Create VPN Alias (only if you have router based N2N VPN)
- Firewall | Alias
- New Alias (Plus sign)
- Name: vpn_subnets
- Type: Network(s)
- Categories: MultiWAN
- Content: put all remote VPN subnets, hint, separate with comma's, example, 192.168.1.0/24,10.10.10.0/23
- Description: All remote VPN networks we access
- Save
- Firewall | Rules | LAN
- IF you are setting up for VPN
- Clone rule which has description “Default allow LAN to any rule”
- Change Gateway to the gateway group you defined (WANGROUP in these instructions)
- Change description by appending “Modified ” (so you can tell which one you changed)
- Save
- Go to original rule (above the one you just changed, we hope). This must be before the “Modified” one in the list
- Change Destination to the alias you created before (vpn_subnets)
- Change Description to something like “Route VPN traffic through default gateway”
- Save
- If you are NOT setting up for VPN
- Edit rule which has a description of “Default allow LAN to any rule”
- Change gateway to the gateway group you defined (WANGROUP in these instructions)
- Add a new firewall rule above the one or two you have created here
- Action: Pass
- Interface: LAN
- TCP/IP Version: ipv4
- Protocol: TCP/UDP
- Source: Any
- Destination: Single host or network
- Destination: your LAN IP of the router, ie 192.168.1.1/32
- Destination Port Range: DNS - DNS
- Category: DNS
- Description: Local Route DNS
- Gateway: Default
- Save
- Apply Changes
Testing
- Open a window and start pinging something.
- Open your routers WebUI
- Reports | Traffic
- Ensure both WAN and Failover WAN are on (I turn off LAN for this so I can see what is going on)
- Shut down the primary WAN (I'm lazy, so I just unplug the network cable)
- You may see your ping's skip a few numbers.
- You'll see the WAN traffic die, to be picked up by the Failover WAN
- Run any additional tests
- Note: VPN may die, and it may take 15 seconds to a minute for the VPN connection to realize it has to reconnect. You can force restart the VPN connection to speed things up.
- Bring your primary WAN back online
- Again, pings may skip a little
- You'll see Failover WAN's traffic die down and picked up by primary
- Note: your VPN connections
Links
other/networking/opnsense/multiwan.1734249751.txt.gz · Last modified: 2024/12/15 02:02 by rodolico