sitetositevpntunnel.com A guide by Firezone

Site-to-site VPN tunnels, explained in full

A site-to-site VPN tunnel joins two networks across the internet, so that hosts on each side can reach the other side. This guide explains IPsec, the design decisions, and the problems that most teams find. It also shows a design that opens no inbound ports.

See site-to-site with FirezoneBook a demo

How a site-to-site VPN tunnel carries a packetA host in Site A sends a packet for Site B to the VPN gateway of Site A. The two VPN gateways hold an encrypted IPsec tunnel across the internet. The VPN gateway of Site B decrypts the packet and delivers it to a host in Site B. Neither host runs VPN software.Site A 10.10.10.0/24Site B 192.168.10.0/24routeIPsecdeliverHost in Site Ano VPN softwareVPN gateway AencryptsVPN gateway BdecryptsHost in Site Bno VPN software
  1. The host uses a normal route

    A host in Site A sends a packet for Site B to its VPN gateway. The host does not know about the tunnel.

  2. The gateways agree on keys

    The two VPN gateways authenticate each other with IKE and make the keys for the tunnel.

  3. The tunnel carries the packet

    Gateway A encrypts the packet, puts it in a new packet, and sends it across the internet.

  4. The far gateway delivers it

    Gateway B decrypts the packet and sends it to the host in Site B.

What a site-to-site VPN tunnel is

A site-to-site VPN tunnel is an encrypted connection between two networks. Each network has a VPN gateway at its edge. The two gateways encrypt the traffic between the sites and send it across the internet.

The hosts in each site run no VPN software. A server in one office sends a packet to a printer in a different office with a normal route. The gateways do all the work.

This is the difference from a remote access VPN. A remote access VPN connects one device with a client to a network. A site-to-site VPN connects a network to a network, and it is always on.

Teams use a site-to-site VPN to join offices, data centers, and cloud networks. It is the low-cost alternative to a private circuit.

IPsec and IKE in short

Most site-to-site tunnels use IPsec. IPsec is a family of protocols, and two of them do most of the work.

  • IKE, the Internet Key Exchange, sets up the tunnel. The two gateways authenticate each other with a pre-shared key or with certificates. They then agree on the encryption algorithms and make the keys. The current version is IKEv2.
  • ESP, the Encapsulating Security Payload, carries the data. In tunnel mode, ESP encrypts the full original packet and puts it in a new packet between the two gateways.

IKE uses UDP port 500. When a NAT device is in the path, IKE and ESP move to UDP port 4500. Without NAT, ESP is IP protocol 50, which is not TCP and not UDP.

The two gateways must agree on each parameter. These include the IKE version, the encryption and integrity algorithms, the Diffie-Hellman group, and the lifetimes. One difference stops the tunnel, and the error messages are frequently not clear.

The design decisions

Route-based or policy-based

A policy-based VPN uses a list of rules to select the traffic to encrypt. Each rule names a source subnet and a destination subnet. A packet that matches a rule goes into the tunnel. Each new subnet needs a new rule on the two sides.

A route-based VPN makes a virtual tunnel interface. The route table decides which traffic goes to that interface. You can add static routes, or you can run a routing protocol such as BGP through the tunnel. Most new deployments are route-based, because routes are easier to change than paired rules.

Hub and spoke or full mesh

In a hub and spoke design, each site has one tunnel to a central site. The design is simple, but traffic between two spokes goes through the hub. The hub is a bottleneck and a single point of failure.

In a full mesh design, each site has a tunnel to each other site. Traffic takes the direct path. The cost is the number of tunnels. Ten sites need 45 tunnels, and each tunnel has its own keys and its own parameters.

The usual problems

Overlapping subnets

Two sites that both use 192.168.1.0/24 cannot route to each other. A host believes that the remote address is on its own network and never sends the packet to the gateway. The fixes are to renumber one site or to translate addresses at the gateway. This problem is common after a company merger.

MTU

The tunnel adds headers to each packet, so a full-size packet no longer fits. If a firewall also blocks the ICMP messages that report the problem, large packets disappear. A ping works, and a file transfer stalls. The usual fix is to clamp the TCP maximum segment size on the gateways.

A public IP and open ports on each side

Each gateway must be reachable from the other gateway. In practice, each side needs a static public IP address and inbound rules for UDP 500, UDP 4500, and ESP. A listener on a public address is a target, and VPN gateways have a long history of vulnerabilities.

All-or-nothing access

A tunnel joins networks, not users or apps. After the tunnel is up, each host in one site can usually reach each host in the other site. A compromised host in a branch office then has a path to the data center. The tunnel itself has no concept of a user or an app. You must add firewall rules on each side to limit the access.

Good practice for any site-to-site VPN

  1. Plan the address ranges. Give each site its own range before you connect the sites.
  2. Use IKEv2 and current algorithms. Prefer certificates to a pre-shared key. If you use a pre-shared key, make it long and random.
  3. Limit what crosses. Write rules for each direction. Permit the ports that the sites need, and deny the rest.
  4. Set the MTU deliberately. Clamp the TCP maximum segment size, and test with a large transfer.
  5. Remove the single point of failure. Run two gateways on each side, and test the failover.
  6. Monitor the tunnel. Send an alert when the tunnel goes down, and keep a record of what crosses it.

How Firezone connects two sites

Firezone connects sites with WireGuard tunnels and does not use IPsec. Connections in Firezone are directional. A Client connects to a Gateway, and never the reverse. Each Site therefore runs two Linux machines:

  • A Gateway, which receives traffic from the other Site and delivers it to the local hosts.
  • A headless Client, which the local hosts use as their route to the other Site.

You add a CIDR Resource for the subnet of each Site. You then add a static route on the router of each Site that points to the headless Client. The hosts need no agent.

What is different

  • No inbound ports. Clients and Gateways make outbound connections only and use NAT traversal. Neither Site needs a public IP address or an open firewall port.
  • A Policy for each direction. Each headless Client uses its own service account and its own Group. You can permit Site A to reach Site B and not the reverse.
  • Limits on what crosses. Traffic restrictions permit only the ports and protocols that you list. Conditions such as time of day are available on the Team plan and up.
  • No parameters to match. WireGuard has one set of algorithms. Firezone makes the keys and rotates them.

What stays the same

The subnets of the two Sites must not overlap. You must turn on IP forwarding and add a NAT rule on each headless Client. You must also clamp the TCP maximum segment size, because the tunnel interface has an MTU of 1280 bytes. The setup guide gives each command.

An IPsec tunnel, a cloud VPN gateway, and Firezone

The three approaches all join two networks with no software on the hosts. They differ in what each side must expose, and in how you limit the access.

IPsec tunnelCloud VPN gatewayFirezone
Hosts need no agentYesYesYes
No public IP or inbound portNoUDP 500, UDP 4500, and ESP on each sideNoYour side needs a public addressYesOutbound connections only
A separate rule for each directionPartialWith firewall rules on each sidePartialWith firewall rules and route tablesYesOne Policy for each direction
Parameters that the two sides must matchMany: algorithms, groups, and lifetimesMany, but the provider gives a templateNone
Dynamic routing with BGPYesWith a route-based VPNYesNoYou add static routes
Overlapping subnetsPartialWith NAT rulesPartialWith NAT rulesNoThe subnets must not overlap
Machines for each siteOne router or firewallOne managed gateway, and one device on your sideTwo Linux machines, a Gateway and a headless Client

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 the difference between a site-to-site VPN and a remote access VPN?

A site-to-site VPN connects two networks, and the hosts run no VPN software. A remote access VPN connects one device to a network, and the device runs a client. A site-to-site VPN tunnel is always on. A remote access tunnel starts when the user signs in.

Which ports does an IPsec site-to-site VPN use?

IKE uses UDP port 500. With NAT traversal, IKE and the encrypted data use UDP port 4500. Without NAT, the data uses ESP, which is IP protocol 50. The firewall on each side must permit these from the other gateway.

Is a route-based VPN better than a policy-based VPN?

For most new deployments, yes. A route-based VPN lets the route table decide what goes into the tunnel, and it supports routing protocols. A policy-based VPN is sufficient for two sites with a small number of subnets that do not change.

Why does ping work across the tunnel when large transfers stall?

The cause is usually the MTU. A small ping packet fits in the tunnel. A full-size packet does not fit, and the network drops it. Clamp the TCP maximum segment size on the gateways.

Do the two sites need static public IP addresses?

With IPsec, usually yes, because each gateway must find and reach the other gateway. With Firezone, no. The Gateway and the headless Client in each Site make outbound connections only.

How fast is a Firezone site-to-site link?

Firezone states that each Client and Gateway routes more than 5 Gbps on modest commodity hardware. To get more capacity, add Clients and Gateways. See the site-to-site page.

Join two sites with no open ports

Firezone is zero trust access built on WireGuard. Each Site runs a Gateway and a headless Client, and each direction has its own Policy. The Starter plan is free.

See plans and pricingBook a demo