subnetrouting.guide A guide by Firezone

Subnet routing for devices without an agent

A subnet router is one machine that forwards traffic for a full subnet. It makes printers, databases, and legacy servers reachable from an overlay network, with no software on those devices. This guide explains how subnet routing works and how to keep the access narrow.

Give access to a private networkBook a demo

How a subnet router carries traffic to devices with no agentA subnet router inside an office subnet advertises the route 10.20.0.0/24 to the control plane. The control plane sends that route to a remote laptop. The laptop sends traffic for the subnet through a tunnel to the subnet router. The subnet router forwards the traffic to a printer and a database that run no agent.Overlay networkOffice subnet 10.20.0.0/24advertiseroutestunnelforwardControl planeshares the routesRemote laptopruns the agentSubnet routerforwards and NATsDatabase10.20.0.40, no agentPrinter10.20.0.15, no agent
  1. The router advertises a route

    The subnet router tells the control plane that it can reach 10.20.0.0/24.

  2. The laptop learns the route

    The control plane sends the route to each device that has permission to use it.

  3. Traffic goes to the router

    The laptop sends packets for the subnet through an encrypted tunnel to the subnet router.

  4. The router forwards and translates

    The router changes the source address to its own and sends each packet to the host.

What subnet routing is

An overlay network connects devices that run an agent. Each device gets an address on the overlay, and the agents build encrypted tunnels between them.

Some devices cannot run an agent. A printer, a managed database, a camera, and a twenty-year-old server are examples. Subnet routing solves this problem. One machine in the same network runs the agent and forwards traffic for all the other hosts.

That machine is the subnet router. It has one interface on the overlay and one interface on the local subnet. To the remote device, the full subnet looks like it is behind one peer.

How a subnet router works

A subnet router needs three things to work.

Advertised routes

The subnet router tells the control plane which ranges it can reach, for example 10.20.0.0/24. These are the advertised routes. An administrator usually approves them. The control plane then sends the routes to the other devices, and each device adds them to its route table.

IP forwarding

By default, a Linux host drops a packet that is not for its own address. IP forwarding changes this behavior. On Linux, the setting is net.ipv4.ip_forward = 1, and IPv6 has an equivalent setting. Without IP forwarding, the tunnel connects and no traffic gets through.

Source NAT

The printer does not know the overlay network. If a packet arrives with an overlay source address, the printer sends its reply to its default gateway, and the reply gets lost. Source NAT solves this problem. The subnet router replaces the source address with its own address, so the reply comes back to the router.

Source NAT has a cost. Each host in the subnet sees the address of the router, not the address of the user. Host logs and host firewalls can no longer tell one user from a different user. The alternative is a return route on the subnet's own router, which keeps the source address.

Where subnet routing goes wrong

Overlapping subnets

Two offices that both use 192.168.1.0/24 cannot both advertise that range to the same devices. The device has one route table, and one address can go to only one place. The same conflict occurs when a home network uses the range of the office.

You can renumber one network, or you can translate one subnet to a different range at the router. The two fixes take time, so select address ranges that do not overlap before you grow.

One router is one point of failure

All traffic for the subnet goes through one machine. If that machine stops, each host behind it becomes unreachable. Run a minimum of two subnet routers for each subnet, and make sure that failover is automatic.

A route is too much access

A route to 10.20.0.0/24 gives a path to 254 hosts and to every port on each host. The user needed one printer. If that laptop is compromised, the attacker can scan the full subnet through the tunnel.

A route is a statement about reach. It is not an access rule. Subnet routing needs a second layer that says which user can open which port on which host.

How to keep subnet access narrow

These steps apply to any product that does subnet routing.

  1. Advertise the smallest range. If the legacy hosts are in 10.20.0.0/28, do not advertise 10.20.0.0/16.
  2. Write rules for hosts and ports. Give the print team TCP port 631 on the printer, not the full subnet.
  3. Put an agent on the hosts that can run one. Use the subnet router only for the hosts that cannot.
  4. Keep the identity of the user. If you use source NAT, make sure that the router or the control plane records which user made each connection.
  5. Review the wide rules. Start with one range if you must, look at what people use, and then replace the range with narrow rules.

Try overlapping rules

These rules show a subnet with overlapping Firezone Resources. Type an IPv4 address to see which rule applies. When more than one rule contains the address, the rule with the longest prefix wins.

CIDR ResourceWho has access
10.20.0.0/16The network team, on all ports, through the Gateway in the office Site
10.20.0.0/24The IT support Group, on ICMP and TCP port 22 only
10.20.0.15/32All employees, on TCP port 631 only, for the printer
10.20.0.40/32The database team, on TCP port 5432 only
All other addressesNot a Resource. The traffic does not enter Firezone.

How Firezone does subnet routing

Firezone has no separate subnet router feature. A Gateway in a Site, together with a CIDR Resource, does the same job.

  1. Deploy a Gateway on a Linux host that can reach the subnet. The hosts in the subnet need no agent.
  2. Add a CIDR Resource for the range, for example 10.20.0.0/24, and put it in the Site.
  3. Write a Policy that gives one Group access to that Resource. Access is default-deny.

The Gateway makes outbound connections only, so you open no inbound firewall port. The standard Gateway install turns on IP forwarding, and you do not approve advertised routes by hand. The private network guide gives each step.

Less access than a route

A CIDR Resource for a full subnet is a first step, and Firezone recommends narrower Resources where possible. Two features reduce the access:

  • Traffic restrictions. A Resource can permit only some protocols and port ranges, for example TCP port 22 only.
  • Narrower Resources. Add an IP Resource or a DNS Resource for one host, with its own Policy. The most specific Resource wins, and an IP Resource beats any CIDR Resource.

For high availability, put two or more Gateways in the Site. If one Gateway fails, the Client moves to a healthy Gateway.

Static routes, a mesh VPN subnet router, and Firezone

The three approaches all reach hosts that run no agent. They differ in how much the remote user can reach after the route exists.

Static routes + VPNMesh VPN subnet routerFirezone
Hosts in the subnet need no agentYesYesYes
How devices learn the routeAn administrator sets it on each sideThe router advertises it, and an administrator approves itYou add a CIDR Resource to a Site
No inbound firewall portNoThe VPN server listens on a public IPYesUsually, with NAT traversalYesOutbound connections only
Limit access to ports and protocolsPartialWith separate firewall rulesYesWith an access control listYesTraffic restrictions on each Resource
Different rules for overlapping rangesNoPartialYesThe most specific Resource wins
Failover between routersPartialYou build itYesYesTwo or more Gateways in a Site

The table describes the usual design of each category. A specific product can be different. Read the documentation of the product before you decide.

Common questions

What is a subnet router?

A subnet router is a machine that connects an overlay network to a local subnet. It runs the agent of the overlay network and forwards traffic for the other hosts in the subnet. Those hosts need no agent.

Does a subnet router need IP forwarding?

Yes. Without IP forwarding, the operating system drops each packet that is not for its own address. On Linux, set net.ipv4.ip_forward to 1. The Firezone Gateway install turns on IP forwarding for you.

Why do hosts see the address of the router and not the address of the user?

The subnet router uses source NAT. It replaces the source address of each packet with its own address, so that replies come back to it. A Firezone Gateway usually does the same. Allow the address of the Gateway in the firewall of each host.

Can two sites with overlapping subnets use subnet routing?

Not with plain routes. One address range can go to only one place in a route table. Renumber one of the sites, or translate one range at the router. In Firezone, a DNS Resource is an alternative. Each name gets its own address on the Client, so the route works when the real addresses overlap.

Is subnet routing the same as a site-to-site VPN?

No. Subnet routing lets devices with an agent reach a subnet. A site-to-site VPN connects two subnets, so that hosts with no agent on the two sides can reach each other. A site-to-site link needs a router on each side.

Reach the subnet, and only what each team needs

Firezone is zero trust access built on WireGuard. Deploy a Gateway next to the hosts, add a CIDR Resource, and write a Policy. The Starter plan is free.

See plans and pricingBook a demo