meshvpn.guide A guide by Firezone

Mesh VPNs, and the rules they need

A mesh VPN connects devices directly to each other, with no central server in the path of the traffic. This guide explains how a mesh differs from hub and spoke, what the coordination server does, and why a flat mesh needs access rules.

See the Firezone mesh VPNBook a demo

How a mesh VPN connects devicesThree devices each register with a coordination server in the control plane. The server gives two of the devices the keys and addresses of each other, and they make a direct encrypted tunnel. The third device has no rule that permits access, so it gets no tunnel.Control planeData planeregisterregisterdirect tunneldeniedCoordinatorkeys, addresses, rulesLaptopat homeWorkstationin the officeBuild serverno rule for the laptop
  1. Each device registers

    A device signs in and sends its public key to the coordination server. The private key stays on the device.

  2. The server introduces the peers

    The server checks the rules. It then gives each of the two devices the key and the addresses of the other.

  3. Traffic goes directly

    The two devices make an encrypted tunnel between them. The coordination server carries none of the traffic.

  4. No rule, no tunnel

    With default-deny rules, a device that has no permission gets no key and no path.

What a mesh VPN is

A mesh VPN is a network where each device can make an encrypted tunnel directly to each other device. No central gateway sits in the path. The result is an overlay network. Each device has a stable private address that works from any location.

Most products of this type build a WireGuard mesh. WireGuard is a good fit, because it is fast and its configuration for each peer is small. WireGuard itself does not find peers or get through NAT. The mesh product adds those parts.

People also use the name peer-to-peer VPN for the same design. The name describes the data path. The devices are peers, and traffic goes from one to the other.

Hub and spoke versus mesh

A traditional VPN is hub and spoke. Each device connects to one central server, which is the hub. All traffic goes through the hub, and that includes traffic between two devices in the same room.

Hub and spoke has clear strengths. One place sees all the traffic, so one place can filter it and log it. Only the hub needs a public address. The model is easy to explain.

It also has clear limits.

  • Latency. A packet between two devices in Berlin goes through a hub in Virginia and back.
  • Capacity. The hub carries the traffic of every device, so it is the bottleneck.
  • Availability. If the hub stops, all connections stop.
  • Exposure. The hub has an open port on the internet, and attackers can find it.

A mesh removes the hub from the data path. Each pair of devices uses the shortest path between them. If one device fails, only the connections to that device are lost.

How a mesh VPN works

A mesh VPN has two parts that do different jobs.

The coordination server

A full mesh of 100 devices has 4,950 possible pairs. No person can manage the keys and addresses for all of them by hand. A coordination server does this work. Each device registers its public key. The server then tells each device which peers exist, which keys they use, and where to find them.

The coordination server is the control plane. It does not carry user traffic, and it does not have the private keys of the devices. It does decide who learns about whom, so it is also the place to enforce access rules.

The data plane

The data plane is the set of tunnels between devices. Each tunnel is encrypted from one device to the other. Only those two devices can read the traffic.

NAT traversal

Most devices are behind a router that does network address translation. They have no public address, and they accept no inbound connections. NAT traversal solves this problem. Each device learns its public address from a STUN server. The two devices then send packets to each other at the same time, and each router lets the reply in.

Relays

Some networks do not permit a direct path. Two strict NAT devices or a firewall that limits UDP can prevent it. The devices then send their encrypted packets through a relay. The relay forwards the packets and cannot decrypt them. A relayed path is slower than a direct path, so a good mesh uses it only when it must.

The weakness of a flat mesh

In a flat mesh, each device can reach each other device on every port. This is the default in many setups, because it is the easiest way to start. It is also a security problem that grows with the network.

  • Lateral movement. An attacker who controls one laptop has a network path to every server, workstation, and phone in the mesh.
  • Inbound access to user devices. A classic VPN lets a laptop reach servers. A flat mesh also lets every device reach the laptop.
  • Rules that come too late. If the default is to allow, each rule removes access that people already use. Teams delay that work.
  • Devices that cannot join. A printer, a managed database, or a legacy appliance cannot run the agent. A pure mesh has no place for them.

Good practice

  • Start from default-deny. A device gets a path only when a rule permits it.
  • Write rules for groups of people, not for single devices.
  • Limit each rule to the ports that the task needs, such as TCP port 22 for SSH.
  • Make access one-directional. Permission to reach a device must not give that device a path back.
  • Use a gateway for the systems that cannot run an agent.

How Firezone does a mesh

Firezone is zero trust access built on WireGuard. It has two ways to reach a destination, and you can use the two together.

Device Pools for device-to-device access

A Device Pool is a Resource that contains Clients. A Client connects directly to a Client in the pool over a WireGuard tunnel. You deploy no Gateway, you give the destination no public address, and you open no inbound port. If the network prevents a direct path, traffic goes through a relay and stays encrypted between the two Clients.

You select the members of a pool with one of four rules.

  • Your devices. Each user reaches only the devices that the user owns.
  • All devices. Every Client in the account.
  • A group's devices. The devices of the members of one Group.
  • Static list. Only the devices that you select.

Rules before paths

Firezone is default-deny. Membership in a pool gives no access. A Policy must give a Group access to the pool before a Client can connect. Access is also one-directional. A device that is in a pool gets no path to the other members.

Traffic restrictions limit a pool to the protocols and ports that people need. Examples are TCP port 22 for SSH and TCP port 3389 for RDP.

Stable addresses and names

Each Client has a stable tunnel address from 100.64.0.0/10, and an IPv6 address. Each Client also has a DNS name in the form alice-laptop.firezone.network. The name resolves only for Clients that have access to that device.

Gateways for all other things

A database, a printer, or a full subnet cannot run a Client. For these, you deploy a Gateway in the same network and add the destination as a Resource. The same Policies apply. The guide Access a device via SSH or RDP gives the steps for a pool.

A hub and spoke VPN, a flat mesh VPN, and Firezone

The three approaches put the traffic and the rules in different places.

Hub and spoke VPNFlat mesh VPNFirezone
Path between two devicesThrough the central serverDirect, or through a relayDirect, or through a relay
No public port to openNoThe hub listens on the internetYesYes
Access is denied by defaultNoA user gets the networkNoEvery device reaches every deviceYesA Policy must permit it
Rules for ports and protocolsPartialIn a separate firewallPartialIf you write themYesTraffic restrictions on each Resource
Reaches systems that cannot run an agentYesPartialNeeds a subnet routerYesThrough a Gateway
One device fails, and the others continueNoThe hub is a single pointYesYes
Stable address and name for each devicePartialDepends on the serverYesYes

The table describes the usual design of each category. Many mesh VPN products have access rules that you can turn on. Read the documentation of the product before you decide.

Common questions

What is the difference between a mesh VPN and a traditional VPN?

A traditional VPN sends all traffic through one central server. A mesh VPN makes a direct tunnel between each pair of devices that need to talk. The mesh has lower latency and no central bottleneck. It needs a coordination server to manage keys and peers.

Is a mesh VPN secure?

The tunnels are secure, because each one is encrypted between the two devices. The risk is in the access model. A flat mesh lets every device reach every device. Use default-deny rules, and limit each rule to the ports that the task needs.

Does a mesh VPN need a central server?

It needs a coordination server for keys, peer discovery, and rules. It usually needs relays for the networks where a direct path fails. Neither one reads your traffic. The data goes between the devices.

Can I build a WireGuard mesh by hand?

Yes, for a few devices. Each device needs the public key and the endpoint of each peer, and one side of each pair needs a reachable port. The work grows with the square of the number of devices. A product that has a coordination server and NAT traversal removes that work.

Is Firezone a mesh VPN?

Firezone connects Clients directly to each other with Device Pools, which is a mesh. It also connects Clients to Gateways for the systems that cannot run a Client. In the two cases, a Policy must permit the connection first.

How do I reach my work computer from home with a mesh VPN?

Install the agent on the two computers and sign in. Then permit access from one to the other. In Firezone, create a Device Pool with the rule "Your devices" and add a Policy. Then connect to the .firezone.network name of the work computer with SSH or RDP.

Build a mesh that starts from deny

Firezone connects your devices directly over WireGuard, and a Policy decides who can connect. You need no Gateway for a Device Pool and no inbound ports. The Starter plan is free.

See plans and pricingBook a demo