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.
The router advertises a route
The subnet router tells the control plane that it can reach 10.20.0.0/24.
The laptop learns the route
The control plane sends the route to each device that has permission to use it.
Traffic goes to the router
The laptop sends packets for the subnet through an encrypted tunnel to the subnet router.
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.
- Advertise the smallest range. If the legacy hosts are in
10.20.0.0/28, do not advertise10.20.0.0/16. - Write rules for hosts and ports. Give the print team TCP port 631 on the printer, not the full subnet.
- Put an agent on the hosts that can run one. Use the subnet router only for the hosts that cannot.
- 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.
- 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.
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.
- Deploy a Gateway on a Linux host that can reach the subnet. The hosts in the subnet need no agent.
- Add a CIDR Resource for the range, for example
10.20.0.0/24, and put it in the Site. - 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 + VPN | Mesh VPN subnet router | Firezone | |
|---|---|---|---|
| Hosts in the subnet need no agent | Yes | Yes | Yes |
| How devices learn the route | An administrator sets it on each side | The router advertises it, and an administrator approves it | You add a CIDR Resource to a Site |
| No inbound firewall port | NoThe VPN server listens on a public IP | YesUsually, with NAT traversal | YesOutbound connections only |
| Limit access to ports and protocols | PartialWith separate firewall rules | YesWith an access control list | YesTraffic restrictions on each Resource |
| Different rules for overlapping ranges | No | Partial | YesThe most specific Resource wins |
| Failover between routers | PartialYou build it | Yes | YesTwo 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.