Network and uplinks → Routing

The tab has two parts: the static routes, to reach networks that are not directly connected to the appliance, and policy routing, to send through a chosen…

What it is for

The tab has two parts: the static routes, to reach networks that are not directly connected to the appliance, and policy routing, to send through a chosen gateway the traffic towards precise destinations or the traffic that starts from a client or an internal network. Both go into the kernel at the save, without “Apply”.

The interfaces’ networks are already reachable by themselves, and the remote networks of the WireGuard and IPsec tunnels are routed with the tunnels: here you need only the networks that sit behind another router.

Static routes

The list shows for each route the network, “via” the gateway, “dev” the interface, the metric if it is not 0, the comment and the state (“Enabled” or “Disabled”). The bar holds “Reload” and “Add route”; the detail “Delete route”.

Routing: a static route to a network behind an internal routerRouting: a static route to a network behind an internal router
Routing: a static route to a network behind an internal router

The fields:

  • “Network (CIDR)” — the destination network, for example 172.16.0.0/16.
  • “Gateway” — the next hop, an IPv4 address reachable on that interface; for example the internal router 192.168.10.2.
  • “Interface” — the appliance’s cards and VLANs.
  • “Metric” — from 0 to 65535, default 0.
  • “Comment” — optional.
  • “Enabled” — off, the route stays saved but leaves the kernel.

For John Smith Ltd the test lab’s network, 172.16.0.0/16, sits behind the internal router 192.168.10.2 on the LAN: “Network (CIDR)” 172.16.0.0/16, “Gateway” 192.168.10.2, “Interface” eth1, “Comment” Test lab network. In the list the row reads “172.16.0.0/16”, with “via 192.168.10.2 · dev eth1 · Test lab network” below.

“Create route” or “Save route” installs the route at once (“Route applied” appears). The route is also written into the hooks of the interfaces file and into the boot pass, so it stays after a reboot. If the kernel refuses it — typically because the gateway is not reachable on the chosen interface — “Applying the route failed” appears, followed by the kernel’s message: the route stays saved, correct it or delete it. “Delete route” asks “Delete route 172.16.0.0/16?”.

A default route (0.0.0.0/0) cannot be saved here: it is the gateways’ job, and they are applied with the firewall and the confirmation window. The message is “A default route is a gateway: set it in Network and uplinks → Gateways”.

Message What it means
“Not a valid CIDR (e.g. 10.20.0.0/24)” Network badly written.
“Not a valid IPv4 address” Gateway badly written.
“Choose a valid interface” The interface does not exist.
“Metric must be 0-65535” Metric out of range.
“A default route is a gateway…” Use Network and uplinks → Gateways.
“A route for this network already exists on this interface, or with this metric on another…” The kernel recognises a route by network and metric: two identical routes would replace each other. Change the metric or edit the existing one.

The routing table the kernel really uses can be read in Events and diagnostics → Diagnostics, “Routes” and “Policy rules” blocks.

Policy routing

Policy routing sends through a chosen gateway, instead of the one carrying the default route, the traffic that meets a criterion: where it goes (the destination), where it starts from (the source: a client or an internal network) or both. John Smith Ltd has two, both towards the FWA line:

Source Destination Via gateway Comment
empty 198.51.100.160/28 eth2 Video archive to the cloud on the backup line
192.168.20.0/24 empty eth2 Guests on the backup line

The first sends over the FWA the recordings the NVR uploads to the security company’s cloud (198.51.100.160/28), even while the fibre carries everything else: the continuous upload of the videos does not take up the offices’ line. The second sends the guest network (eth1.20) to the internet over the FWA, for the same purpose. The scenario Sending a service or a network over a chosen line shows a policy route step by step.

The “Policy routing” section appears below the page’s guide, when no static route is open, if there are at least two active gateways (or if policy routes already exist). “Add policy route” is available only with two active gateways or more.

Routing: the Policy routing section with the two policy routesRouting: the Policy routing section with the two policy routes
Routing: the Policy routing section with the two policy routes

Each row reads “source → destination”, with “any source” or “any destination” in place of the empty one, and below, “via” the gateway’s interface and the comment: for the example “any source → 198.51.100.160/28” with “via eth2 · Video archive to the cloud on the backup line”, and “192.168.20.0/24 → any destination” with “via eth2 · Guests on the backup line”. Each row has the “Edit policy route” (the pencil) and “Delete policy route” (the bin) buttons; the deletion asks for confirmation naming the row (“Delete the policy route 192.168.20.0/24 → any destination?”). A route whose gateway is off reads “Gateway off: not installed until it is back on”; one whose gateway has been deleted is switched off and reads “Gateway deleted: choose another one”. Without policy routes the section says “No policy routes. Traffic follows the gateways’ priority.”. At the bottom, the table of the ip rule rules the kernel has at that moment.

The “New policy route” window (or “Policy route” for an existing one) asks for:

  • “Source” — the client or the internal network the traffic starts from: an IPv4 address or a CIDR network, for example 192.168.20.0/24. Empty means any source;
  • “Destination” — an IPv4 address or a CIDR network, for example 198.51.100.160/28. Empty means any destination;
  • “Via gateway” — one of the active gateways, shown by its interface; for a new route the first active gateway of the list is proposed;
  • “Comment” — optional;
  • “Enabled”.

At least one of source and destination is needed: that is why each label is in bold while the other is empty; “Via gateway” always is. “Create” (or “Save” for an existing route) installs the rule at once (“Policy route applied”); “Cancel” closes the window without saving. If the chosen gateway is saved but not applied yet, the rule goes in with the next “Apply” of the firewall.

In what order. When several policy routes hold for the same traffic, the one with the most specific destination wins, then the one with the most specific source; if they are equal, the first created. The list is already in this order, and with more than one route the page says so: “When several rules match the same traffic, the one with the most specific destination wins, then the one with the most specific source: the list is in that order.” In the example the video archive route comes before the guests’ one: a guest’s traffic towards 198.51.100.160/28 is decided by the destination rule. In the same way an exception for a single client (its address as source, via eth0) always comes before the rule for its network, and between two overlapping destinations the more specific decides, as in a routing table. There is no way to reorder them by hand.

When a policy route decides. Only in place of the default route:

  • the interfaces’ networks, the static routes and the tunnels always keep their path, even if the policy route’s source or destination covers them: a policy route written by mistake on the LAN’s network does not send the console’s replies out through a WAN, and the guests keep reaching the other internal networks as before;
  • with two active gateways, a connection that came in through a line gets its replies through that line, whatever a policy route says: a LAN server that answers a publication on the fibre answers through the fibre even if its network were the source of a policy route;
  • the traffic that starts from the appliance itself is not touched by a source policy route: it leaves according to the gateways’ priority;
  • for traffic to really leave through the second line, masquerade is needed on its zone, as for failover: the wan zone has it by default.

When the line fails. If the WAN monitor reports “Down” for a policy route’s gateway, the route is lifted while the line is withdrawn: the traffic it sent there follows the default route, that is the line carrying the traffic at that moment. When the line comes back, the policy route comes back with it. Meanwhile the list marks it in amber: “Line down: lifted until the gateway is back, and meanwhile the traffic follows the default route”. In the example, while the FWA is down the NVR’s videos and the guests leave through the fibre. A service that accepts only that line’s address stays unreachable all the same until the line comes back.

Message What it means
“Not a valid IPv4 address or CIDR” Source or destination badly written.
“Enter a source, a destination or both” Both are empty.
“Choose an active gateway” The gateway does not exist or is off.
“A policy route for this source and destination already exists” The same pair is already there: edit the existing one.

For the technician The static routes are ip route replace <network> via <gateway> dev <if> metric <n> in the main table; the deletion is ip route del of the same route. A policy route is ip rule add pref 3300+<position> [from <source>] [to <destination>] lookup <the gateway's table>: the position is the one in the list’s order, counting the switched-off routes too (switching one off does not move the others). It is preceded by the rule pref 2999 lookup main suppress_prefixlength 0 (present as long as a policy route or the routing of replies exists): the main table, without its default routes, is consulted first. With two active gateways the reply rules (pref 3000+, fwmark) come before as well. For the example:

ip rule add pref 2999 lookup main suppress_prefixlength 0
ip rule add pref 3000 fwmark 0x00010000/0x00ff0000 lookup 1000
ip rule add pref 3001 fwmark 0x00020000/0x00ff0000 lookup 1001
ip rule add pref 3300 to 198.51.100.160/28 lookup 1001
ip rule add pref 3301 from 192.168.20.0/24 lookup 1001

A route with neither source nor destination (possible only by editing argos.json by hand) is never installed. The gateway’s table holds default via <gateway> dev <if> onlink. While a line is withdrawn the WAN monitor removes the rules of its policy routes at every pass and puts them back when it returns ([argos-wan] lines in the journal); the reply rules stay. The appliance’s traffic leaves from sockets not bound to an address and matches no from rule. Policy routes do not change the nft ruleset: the firewall does not become “to apply”. Static routes and policy routes also become up/down hooks in the stanzas Argos manages; the argos-network boot pass puts them all back, even on the interfaces Argos does not manage. From the shell: argos network routing policies add --source 192.168.20.0/24 --uplink eth2.

LET’S TALK INFRASTRUCTURE

Control starts with a conversation.

Tell us about your infrastructure. Let’s start with what you actually need.

Talk to an engineer