OPNsenseI · Networking Foundations for Firewall AdministratorsLayer 2 and Layer 3 foundations
Gateways, default routes and asymmetric routing
What you'll learn
- Explain how a host chooses its next hop for an off-subnet destination
- Trace the route selection on a Linux/FreeBSD/OPNsense host
- Define asymmetric routing and describe how it breaks stateful filtering
- Identify the symptoms of asymmetric routing in production
Prerequisites
Verified against OPNsense 25.x · FreeBSD 14.x · PF (FreeBSD packet filter) FreeBSD 14.x · Unbound 1.20+ · Kea DHCP OPNsense 25.x plugin · WireGuard in-kernel + OPNsense plugin · strongSwan (IPsec plugin) OPNsense 25.x plugin · OpenVPN 2.6.x · Suricata 7.x · 2026-08-14
A firewall is also a router. It has routes for everything it knows about (directly connected networks, static routes, dynamic routes, the default route) and uses those routes to decide which interface a packet leaves on.
If the route the firewall picks for the forward direction and the route the rest of the network picks for the return direction do not agree, you have asymmetric routing. Stateful firewalls fall over when this happens.
How a host picks a route
A host’s routing table looks like this:
Destination Gateway Interface
127.0.0.0/8 link-local lo0
192.0.2.0/24 link-local eth0 ← directly connected
0.0.0.0/0 192.0.2.1 eth0 ← default route
To send a packet to 203.0.113.50, the host walks the table:
- Is there a route for
203.0.113.50exactly? No. - Is there a route for
203.0.113.0/24? No. - Is there a route for
203.0.0.0/16? No. - Is there a default route (
0.0.0.0/0)? Yes →192.0.2.1.
The longest matching prefix wins. That is the “longest prefix
match” rule. /0 is the shortest possible match — anything
matches it — so it is the fallback.
$ netstat -rnRouting tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 192.0.2.1 UGS 0 0 em0
127.0.0.1 link#4 UH 0 0 lo0
192.0.2.0/24 link#1 U 0 0 em0
192.0.2.50 link#1 UHS 0 0 lo0Illustrative output
How OPNsense picks a route
OPNsense’s routing table is the same shape, with one entry per
directly-connected interface plus any static or dynamic routes
the operator added. The routing page (System → Routes → Configuration)
shows the table; System → Routes → Diagnostics and the CLI
netstat -rn show the same data.
The decisions the firewall makes:
| Destination matches | Action |
|---|---|
| Directly connected network | Send directly via that interface’s ARP/ND |
| Static or dynamic route | Forward to that route’s gateway |
| Nothing else matches | Forward via the default route (the “WAN gateway”) |
| Nothing matches and no default | Drop |
The “gateway” field in the static route is the IP of the next-hop router. The firewall ARPs that IP and sends the packet to its MAC.
Symmetric and asymmetric routing
Symmetric routing means the forward path and the return path for a flow are the same set of routers, in the same order, in reverse. For a flow from LAN to WAN:
LAN host → OPNsense → WAN router → Internet → Server
Server → Internet → WAN router → OPNsense → LAN host
Every router on the forward path sees the corresponding return packet. PF can match state.
Asymmetric routing is when one direction takes a different path:
LAN host → OPNsense → WAN-A → Internet → Server
Server → Internet → WAN-B → OPNsense → LAN host
The outbound path went via WAN-A; the return path came back via WAN-B. OPNsense will see the return packet on its WAN-B interface but have no state for it (the state is on WAN-A). The packet will be dropped.
Causes of asymmetric routing
- Multi-WAN misconfiguration. Two WAN interfaces each have a default route; outbound traffic uses one, inbound traffic from the other provider returns via that other provider. The firewall’s state for the connection is on the first WAN, but the return packet arrives on the second.
- Server-side routing. A server has two interfaces, the application binds to one but the OS routes outbound responses via the other.
- ECMP / link aggregation. Equal-cost multi-path routing on upstream routers can pick different paths for each direction.
- Direct connections between subnets. If two OPNsense interfaces are bridged to the same broadcast domain and the hosts also have a default route, traffic may take the host’s default instead of the firewall’s route.
Diagnosing asymmetric routing
The tool is traceroute (or tracert on Windows). Run it in
both directions for a problematic flow:
$ traceroute -n 203.0.113.50traceroute to 203.0.113.50 (203.0.113.50), 64 hops max
1 192.0.2.1 0.412 ms ← firewall (LAN)
2 198.51.100.1 4.220 ms ← WAN-A gateway
3 10.0.0.1 8.113 ms ← ISP-A
4 ...
10 203.0.113.50 32.890 msIllustrative output
If the two paths diverge, the fix is not on OPNsense; it is on the upstream network that has multiple equal-cost paths. OPNsense cannot force a remote router to send return traffic via a specific path.
The cases OPNsense can fix are:
- Multi-WAN with both interfaces accepting default routes. Use gateway groups and the firewall’s outbound NAT rules to keep return traffic on the same WAN it left on.
- Server-side routing where the firewall can rewrite the source IP (NAT) so the server sees the traffic as coming from the firewall and replies to the firewall.
Summary
- Routing is “longest prefix match, fallback to default”.
- Symmetric routing keeps stateful filtering working. Asymmetric routing breaks it in a way that looks intermittent.
- The first tool for diagnosing asymmetric routing is
traceroutein both directions. - OPNsense can fix some asymmetric-routing cases via policy routing and NAT; others require upstream cooperation.
Knowledge check · 3 questions
Q1. A user reports that some HTTPS connections to a remote service work and some hang and reset. The PF state table shows entries for both, but one of them has a state counter that never advances. The most likely cause is:
Q2. OPNsense can always fix asymmetric routing by adding an inbound firewall rule that permits the return traffic.
Q3. Which of the following are valid causes of asymmetric routing? Select all that apply.
Passing score: 75%. Answers are checked in this browser.