Networking · OpenWrt
Two fiber lines, one OpenWrt router: dual-WAN with mwan3
How I put two fiber lines behind one OpenWrt router with mwan3: wiring the second line over PPPoE, health checks and failover, the mistakes, and benchmarks on an 880 MHz router.
Why two lines
I have two fiber lines at home: a 300 Mbps line with a static public IP and a 40 Mbps line. I wanted both behind one router, with everything using the fast line by default and the second line taking over automatically when the primary drops.
The obvious idea is load balancing, and I decided against it. mwan3 balances per connection, not per packet, so a single download never goes faster than one line. With a 300:40 split, every balanced connection that lands on the slow line is about seven times slower. Sites that tie a session to one IP address, like banking and work portals, can also break when consecutive connections leave from different addresses.
So the setup is pure failover: all traffic uses WAN1 as long as it's healthy, and moves to WAN2 only when WAN1 is down.
The hardware
The router is a TP-Link Archer C6U v1: a MediaTek MT7621 with two MIPS cores at 880 MHz (four threads) and 128 MB of RAM, about 118 MiB of it usable. It runs OpenWrt 22.03.5 on kernel 5.10, with its switch exposed through DSA as ports wan and lan1 to lan4. The stock TP-Link firmware has no dual-WAN at all, so OpenWrt is what makes this possible.
- WAN1 is 300 Mbps fiber with a static public IP. The router runs PPPoE itself over the primary ONT, and keeps a small static interface on the ONT's subnet (192.168.1.0/24) so the ONT's admin page stays reachable.
- WAN2 is 40 Mbps fiber. Its ONT, a Syrotech SY-GPON-1110-WDONT, runs in bridge mode, and the router handles PPPoE over it.
- The LAN is 10.20.7.0/24, with dnsmasq handing out addresses from .100 up and static leases for my own devices. NextDNS runs on the router as the only resolver.
On the LAN, a Tailscale subnet router runs 24/7, with a static route on the router sending 100.64.0.0/10 to it.
Wiring WAN2 into the router
With the second ONT switched to bridge mode, on the router:
- Download a config backup (System → Backup).
- Install
mwan3(2.11.7) andluci-app-mwan3. On 22.03 this pulls in the legacy iptables modules mwan3 needs, and free flash went from about 4.5 MiB to about 3.75 MiB. - Remove
lan4from thebr-lanbridge. - Create
wan2as a PPPoE interface onlan4, in the existingwanfirewall zone, with Use DNS servers advertised by peer off so NextDNS stays the only resolver. - Give the default routes metrics:
10on the existingwanand20onwan2. - Apply, then configure mwan3.
config interface 'wan2'
option device 'lan4'
option proto 'pppoe'
option username '...'
option password '...'
option peerdns '0' # keep NextDNS the only resolver
option metric '20' # 'wan' gets 10The PPPoE session on WAN1 stayed up through the network change, and its uptime didn't reset, so the house never lost the internet. The metrics matter later: they decide where traffic goes when mwan3 has no rule for it.
How mwan3 decides
mwan3 has four building blocks: interfaces it health-checks, members that give an interface a metric, policies that list members, and rules that send traffic to a policy.
Each line pings 1.1.1.1, 8.8.8.8 and 9.9.9.9 every 5 seconds, and at least two of the three must answer. Three failed rounds in a row, about 15 seconds, mark the line down. Three good rounds mark it up again. With three targets from different providers, one of them having a bad minute doesn't take a line down.
Each line gets a member, with WAN1 at metric 1 and WAN2 at metric 2, and a single policy (wan_primary) lists both. mwan3 uses the lowest-metric member that's online, so everything goes out WAN1 until it fails, then falls back to WAN2. If both lines are down, last_resort 'unreachable' fails the connection straight away instead of handing it to the main routing table.
config interface 'wan' # same block for 'wan2'
option enabled '1'
option family 'ipv4'
list track_ip '1.1.1.1'
list track_ip '8.8.8.8'
list track_ip '9.9.9.9'
option reliability '2' # 2 of 3 targets must answer
option interval '5'
option down '3'
option up '3'
config member 'wan_m1' option interface 'wan' option metric '1'
config member 'wan2_m2' option interface 'wan2' option metric '2'
config policy 'wan_primary' # WAN1, fail over to WAN2
list use_member 'wan_m1'
list use_member 'wan2_m2'
option last_resort 'unreachable'
config rule 'tailnet_direct' # never send tailnet traffic to a WAN
option dest_ip '100.64.0.0/10'
option use_policy 'default'
config rule 'default_rule' # everything else on the LAN
option src_ip '10.20.7.0/24'
option dest_ip '0.0.0.0/0'
option use_policy 'wan_primary'Rules are matched top to bottom, and the first match wins. Tailnet traffic comes first and goes to the default policy, which means the normal routing table and its static route to the Tailscale subnet router. Without that rule, the catch-all would send 100.64.0.0/10 out a WAN. Everything else on the LAN hits the catch-all and uses wan_primary.
The catch-all matches the LAN's source range on purpose. Traffic the router sends itself, like NextDNS lookups and package updates, matches no rule and follows the main routing table, where WAN1 wins on metric 10.
Tailscale stays on WAN1 too: the subnet router keeps the static IP so its direct connections are stable, and if WAN1 fails it reconnects over WAN2 and remote access keeps working.
mwan3 decides once per connection. It marks the connection in conntrack and every later packet follows the mark, so existing connections keep their line and only new ones go through the rules. After applying, Status → MultiWAN Manager → Status lists the live rules with packet counters, which is the quickest way to see whether a rule is matching anything.
What tripped me up
- Rule names longer than 15 characters are skipped silently. The UI accepts them, so check the system log after applying.
- Rules are first-match, and new rules go to the bottom. That can put them below the catch-all, where they never match.
- Existing connections keep their line. A policy change only affects new connections.
conntrack -Fforces everything to re-route, at the cost of every app reconnecting. - Applying mwan3 doesn't redial anything, but editing an interface does. Changing a line's credentials or protocol redials that line, and mwan3 fails its traffic over while it comes back. LuCI rolls the change back automatically if it locks you out.
- Two ONTs can share a default subnet. If both use the same LAN range out of the box, change one before plugging it in.
Does the router keep up?
An 880 MHz MIPS chip routing two lines, marking every connection and doing no offloading sounded like a stretch, so I measured it:
- WAN1 alone, wired: 290 down and 271 up in Ookla's speed test, about 97% of the plan. The rest is normal PPPoE and TCP overhead. Load average peaked at 1.17.
- Both lines at full speed, WAN1 wired and WAN2 on Wi-Fi: WAN1 held 275–280 and WAN2 41. Load average was 2.61 / 0.97 / 0.56 on a CPU with four threads: busy, but not saturated.
- Memory: available memory went from about 39 MiB before mwan3 to about 27 MiB after, and stayed flat under load. Idle load average rose from about 0.15 to about 0.6.
Wi-Fi costs extra CPU on this chip, because the radio driver processes packets on the main CPU. Flow offloading, software and hardware, stays off: these numbers don't need it, and leaving it off avoids conflicts with mwan3's packet marking.
So the MT7621 is about the right size for 300 + 40 Mbps without offloading. A faster WAN1 plan, 500 Mbps or more, is when I'd revisit offloading or the hardware.
What this setup can't do
Failover covers what I needed. Here is what it doesn't:
- A busy WAN2 during failover makes calls stutter. There's no traffic shaping (SQM) yet, and on this router it would cost CPU.
- Failover drops in-flight connections. A call reconnects within seconds, but it does drop.
- There's no IPv6 on either line.
- Each policy uses one line at a time, so no single download goes faster than one line.
- Networking
- OpenWrt
- Homelab
- mwan3
- Tailscale