Network and uplinks → Gateways

A gateway is an interface’s default route: it tells the appliance where traffic for the internet leaves from. You create one for each interface that…

What it is for

A gateway is an interface’s default route: it tells the appliance where traffic for the internet leaves from. You create one for each interface that carries an internet connection: a card or a VLAN, with a static address or on DHCP, or a PPPoE link. With two gateways or more the appliance does failover: the line with the lowest priority carries the traffic, the others stand by and take over when it fails.

Only this page sets the default route. The Interfaces tab has no gateway field and Routing does not accept a 0.0.0.0/0 route.

John Smith Ltd has two gateways:

Description Interface Gateway address Priority Probe host
Fibre (main line) eth0 (static, 203.0.113.10/29) 203.0.113.9 10 9.9.9.9
FWA (backup line) eth2 (DHCP, lease 192.168.8.100/24) empty: the lease’s router, 192.168.8.1 20 1.1.1.1

Each line has a probe host of its own: that way a fault of a single host does not make both lines look down.

How the page is laid out

Gateways: the list with the fibre as primary and the FWA on standbyGateways: the list with the fibre as primary and the FWA on standby
Gateways: the list with the fibre as primary and the FWA on standby

At the top you find a summary with three numbers: “Gateways” (how many you have configured), “Active” (how many are on) and “To apply” (how many differ from those confirmed with the last apply of the firewall).

Below it is the list, a table with these columns:

  • “Interface”, with the description below the name;
  • “Gateway address”: the address typed in, or the router the DHCP lease names at that moment (“via the lease’s router 192.168.8.1” for the FWA), or “via the lease’s router (no lease yet)”; on a PPPoE link “via the session’s peer” with its address, or “via the session’s peer (not connected)”;
  • “Priority”;
  • “Probe host”, or “link state only” when there is none;
  • “State”, with one of these indicators:
State Meaning
“Primary” On, not withdrawn, with the lowest priority among those in service: it carries the traffic.
“Standby” On and healthy, but with a higher priority: it takes over if the primary fails.
“Down” The WAN monitor has withdrawn it after the failed probes (see below).
“Probe pending” It has a probe host, but the monitor has not tried it yet: typically a gateway saved and not applied yet.
“Disabled” Switched off with the “Active” switch.

“To apply” may appear beside it: the saved gateway differs from the confirmed one, and must be applied.

The list’s bar holds “Reload” and “Add gateway” (the “+”). The detail’s bar, with a gateway open, holds “Delete gateway” (the bin); the title says “Gateways / eth0 · Fibre (main line)”, or “Gateways / New gateway” for a new one. With nothing selected the detail shows a short “How to” guide and, when there are two active gateways or more, the sentence about the routing of replies (see further on).

The fields

Gateways: the detail of the fibre lineGateways: the detail of the fibre line
Gateways: the detail of the fibre line

The detail has two boxes. Labels in bold mark the required fields.

“Gateway” box

  • “Description” — free text, optional. It appears in the list and in the detail’s title. Example: “Fibre (main line)”.
  • “Interface” — required. The menu offers the cards, the VLANs and the PPPoE links that do not already have a gateway: an interface has only one. If the saved interface no longer exists on the appliance, it appears with the note “no longer on this host” and the save is refused until you choose another one.
  • “Gateway address” — it depends on the interface:
    • on a static interface it is required: an IPv4 address, normally inside the interface’s network (for eth0, 203.0.113.9). An address outside that network (the “off-link” gateway some providers assign) is accepted and installed all the same; the save warns with “Warning: the gateway is outside this interface’s networks.”;
    • on a DHCP interface you can leave it empty: the gateway is then the lease’s router, followed at every renewal. You can also type a fixed one;
    • on a PPPoE link the field is switched off: the gateway is the session’s peer, which the provider assigns at every connection. A typed address is refused.
  • “Priority” — required, from 0 to 999; a new gateway starts at 100. The lowest carries the traffic. Two active gateways cannot have the same priority. The default route a DHCP lease installs by itself, on a DHCP interface without a gateway, always comes after every gateway.
  • “Active” — the switch. Off, the gateway stays in the configuration but installs no route.

“Health check” box

  • “Probe host” — optional, an IPv4 address. If there is one, the WAN monitor pings it through the gateway’s interface; empty, failover happens only on link loss.
  • “Probe every (s)” — required, from 2 to 3600 seconds; default 10.

At the bottom, “Create gateway” (for a new one) or “Save gateway”; “Restore” puts the form back to the saved values.

Tip As probe host choose a stable public address that answers ping, beyond the line you want to check. Do not use the address of the modem or of the gateway itself: the modem answers even when the line behind it is dead, and the monitor would not notice.

Saving and applying

Saving writes only the configuration and shows “Gateway saved — apply the firewall to load it”. The gateway appears with “To apply” and the firewall status button, in the header, reports unapplied changes. When you press “Apply”, the appliance loads the firewall rules and the gateways (default routes, tables, routing rules) together and opens the “Keep the new ruleset?” window. If you press “Confirm” within 60 seconds, the gateways stay, even after a reboot; if you do not confirm, or press “Revert”, the previous routes come back together with the previous rules.

The reason is simple: a wrong gateway can cut off whoever is working remotely, and the confirmation window puts things back as they were.

Warning Already at the save, before “Apply”, a gateway’s interface counts as WAN side (even if the gateway is off): the DHCP server stops serving it and the console treats it as WAN — it answers there only if access from the WAN is on in System → Management access, and it always asks for the second factor. That is why a gateway on an interface of the LAN zone is refused (“This interface is in the LAN…”: an interface with a gateway cannot be in the LAN), and one on the interface you are working from with “You would lose the console on the interface you are using…”.

For traffic to really leave through a line, the interface must also be in a zone: usually the wan, which masquerades the internal addresses. The zone is assigned in Network and uplinks → Interfaces.

Failover and the WAN monitor

The switch from one line to the other happens in two ways.

  1. Link loss. If the card loses its signal (cable unplugged, modem switched off), the kernel stops using that gateway’s route and moves at once to the next one in order of priority.
  2. Probe host. A line can die with its link still up: the modem is on but nothing gets through beyond it. That is why the WAN monitor service (argos-wan-monitor) pings each gateway’s probe host through its interface, every “Probe every (s)” seconds. After 3 failed probes in a row it withdraws the gateway’s default route (with the 10-second interval, about 30 seconds after the fault) and the traffic moves to the next gateway. At the first answer the route goes back in place.

Some rules of the monitor, worth knowing:

  • it never withdraws the last default route: if no other gateway carries one, the line stays in use even if the probe fails (there would be nowhere to go). If for some reason none is left, it puts one back;
  • while a gateway is withdrawn, the probe keeps going through its line, so the monitor notices when it comes back;
  • if someone puts back the route of a withdrawn line (the DHCP client at a renewal, an ifup, someone by hand), the monitor takes it away again;
  • while a line is withdrawn its policy routes are lifted too (by destination and by source, see Network and uplinks → Routing): the traffic they sent there follows the default route, that is the line carrying the traffic at that moment; they come back with the line;
  • every 30 seconds it puts back the route of a gateway in service that the kernel has lost (for example after an ifup of a hand-written stanza); for a gateway that uses the lease’s router the DHCP client takes care of it;
  • a probe that cannot even start (the ping command is missing or is interrupted) does not count as failed: the monitor decides nothing and notes it once in the journal.

The withdrawal shows in three places: the “Down” state in this list, the “Gateways and tunnels” tile on the System status → Status page and, in the “Attention” strip, the message “WAN uplink eth0 is down: its default route is withdrawn”. The monitor’s lines are in the system journal (Events and diagnostics → System).

Tip Failover moves new connections. A connection already open keeps the line and the address translation it was born with: the registration of a VoIP phone, renewed continuously, can stay hooked to the dead line. You fix it by deleting it in Events and diagnostics → Diagnostics, “Connection tracking” block; the scenario After a line change the phones stay on the old one shows it step by step.

Failover only, no load balancing

The gateways do not share the traffic: at any moment only one line carries the default route. That is why two active gateways with the same priority are refused: the two default routes would replace each other in the kernel. If you want a precise destination, a client or an internal network to use the second line even while the first one works, use policy routing in Network and uplinks → Routing.

Replies leave through the line the connection came in on

With two active gateways or more, a connection that came in through a line gets its replies through the same line, whichever gateway carries the default route at that moment. It holds for the publications, for the console and for SSH. Without this rule a publication on the FWA line would not work while the fibre is primary: the replies would leave through the fibre, with an address the client does not expect.

Replies towards the LAN and towards the networks of the static routes and of the tunnels never change path. With only one active gateway this mechanism does not even exist in the rules. Switching on the second gateway therefore changes the firewall rules too: you apply them with “Apply” and the confirmation window, like any other gateway.

A publication can be restricted to a gateway’s interface (for example the fibre only): see Published services.

Deleting or moving a gateway

“Delete gateway” asks for confirmation with “Delete the gateway on eth2?” and adds, when they apply, two notes:

  • “N policy routes use it: they are switched off, to point at another gateway.”;
  • “N publications answer on this interface only: they are switched off, to be pointed elsewhere.”

After the deletion you see “Gateway deleted — apply the firewall to take it away”: the route stays in the kernel until “Apply”.

If you move a gateway to another interface, the publications restricted to the previous interface are switched off and the save warns: “The publications limited to the gateway’s previous interface were switched off: point them at the new one in Port publication.”

A PPPoE link or a VLAN that has a gateway cannot be deleted: delete the gateway first.

Error messages

Message What it means
“Required” The interface is missing, or the address on a non-DHCP interface.
“Choose a valid interface” The interface does not exist on this appliance.
“This interface already has a gateway” An interface has only one gateway: edit that one.
“Not a valid IPv4 address” In the gateway’s address or in the probe host.
“On a PPPoE link the gateway is the session’s peer: leave the address empty” You typed an address on a PPPoE link.
“Priority must be 0-999” Priority out of range.
“Another active gateway has this priority…” Choose a different priority: it is failover only.
“A static default route has this metric…” A 0.0.0.0/0 route left over from an earlier version uses the same metric: delete it in Routing.
“Interval must be 2-3600 seconds” “Probe every (s)” value out of range.
“No more gateways: 255 at most” Limit reached.
“This interface is in the LAN, and an interface with a gateway is the WAN side…” The interface is in the LAN zone: move it to another zone first (Network and uplinks → Interfaces), or choose another one.
“You would lose the console on the interface you are using…” The gateway would put the interface you work from on the WAN side.

Rarely, straight after the update from a version that set the gateway on the Interfaces page, the save can fail with “Saving the gateway failed — the gateways the interfaces file still names are not adopted yet…”: Argos is still converting the old gateway, or is waiting for you to confirm an apply in progress. Confirm the window (or let it expire) and try again after a few seconds.

For the technician Every gateway has a routing table of its own, with a stable number assigned at creation (from 1000 up, 255 gateways at most) and never reused while the gateway exists. “Apply” runs, for each active gateway:

ip route replace default via 203.0.113.9 dev eth0 metric 10 onlink
ip route replace default via 203.0.113.9 dev eth0 table 1000 onlink

All the gateways’ routes are onlink. On a DHCP interface without an address the router is read from the lease (dhcpcd’s /var/lib/dhcpcd/<iface>.lease or dhclient’s /var/lib/dhcp/dhclient.<iface>.leases) and the monitor realigns the gateway’s table at every change and every 30 s; on a PPPoE link the peer is read from the device (ip -j addr show dev ppp0). A DHCP interface without a gateway keeps its lease’s route at metric 1000 or more (dhcpcd uses 1000 + the interface’s index; for dhclient an Argos hook sets 1000), always below every gateway (0–999). Failover on link loss is net.ipv4.conf.<dev>.ignore_routes_with_linkdown = 1, which Argos sets on the gateways’ interfaces.

With two active gateways or more the routing of replies adds two nft chains — gateway_mark (prerouting, mangle: marks in the ct mark, bits 0x00ff0000, the new connections that came in through a gateway’s interface) and gateway_reply (route output: copies the mark into the appliance’s packets) — and these rules:

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

Rule 2999 consults the main table first, without its default routes: connected networks, static routes and tunnels always win. The WAN monitor is argos-wan-monitor.service (state in /etc/edon/argos.wan.state.json, [argos-wan] lines in the journal): it runs ping -n -I &lt;dev> -c 1 -W 2 &lt;host>, withdraws with ip route del default dev &lt;dev> metric &lt;n> and, while the route is withdrawn, sends the probe out through the gateway’s table with ip rule pref 40000+n oif <dev> lookup <table>. The reverse-path filter must stay loose (Debian’s default) or off. At the confirmation Argos writes the confirmed gateways as up hooks in the stanzas it manages in /etc/network/interfaces and, for the PPPoE links, in /etc/ppp/ip-up.d/argos-gateways; the argos-network boot pass puts them back after a reboot. No stanza holds a gateway line any more.

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