Connect two sites
A site-to-site connection joins two networks, such as an office and a
cloud network, so that the machines at each site reach the machines at the
other. The machines don’t run the Guard client. A
subnet router at each site carries the traffic,
and each router is granted the other site’s subnet. You set this up in the
Guard console or with awctl, and you add one route at each site.
Before you begin
Section titled “Before you begin”- Everything that a subnet router needs, at both sites: a Guard
network, a Linux machine on the site’s subnet, and a
tenantAdminornetworkAdminrole. See Route a subnet through a Linux node. Both routers join the same Guard network. - Ranges that don’t overlap. Each site’s range is outside
100.64.0.0/10, and neither range holds any address of the other. Guard doesn’t translate addresses between sites. Two sites that both use192.168.1.0/24can’t be connected until one of them is renumbered. - The right to add a route at each site, on the site’s gateway or in the cloud network’s route table.
How it works
Section titled “How it works”The examples on this page use these two sites:
| Site A | Site B | |
|---|---|---|
| Subnet | 10.20.0.0/16 | 10.30.0.0/16 |
| Router’s address on the site | 10.20.0.5 | 10.30.0.5 |
| A machine with no Guard client | 10.20.0.9 | 10.30.0.9 |
site A 10.20.0.0/16 site B 10.30.0.0/16
machine ---- gateway ---- router A ==== Guard ==== router B ---- gateway ---- machine10.20.0.9 10.20.0.5 10.30.0.5 10.30.0.9
route 10.30.0.0/16 route 10.20.0.0/16 through 10.20.0.5 through 10.30.0.5Three things make the connection:
| What | Who does it |
|---|---|
| Each router serves its own site’s subnet as a resource. | You, in Guard. |
| Each router is granted the other site’s resource. | You, in Guard. |
| Each site routes the other site’s subnet to its own router. | You, on the site’s gateway or route table. |
Guard does the rest on the routers. When a router is granted the far subnet, the client adds a route for it through the tunnel. When a router serves a subnet, the client turns on forwarding. You don’t add a route or a firewall rule on a router.
The routers need no address between them
Section titled “The routers need no address between them”You don’t choose a tunnel address, a transit network, or a virtual IP
address for the pair. Guard gives each router an address in
100.64.0.0/10, and the routers find each other through Guard. Neither
router needs a public address: when no direct path exists, traffic goes
through a Guard relay. For a faster path, see
Make the router reachable directly.
A virtual IP address comes in only when you run two routers at one site. It’s an address on the site’s own network, and Guard doesn’t manage it. See Run two routers at a site.
Machines keep their own addresses
Section titled “Machines keep their own addresses”Traffic from a machine at one site to a machine at the other isn’t
address-translated. The machine at 10.30.0.9 sees a connection from
10.20.0.9, not from a router. Two things follow:
- A firewall at either site can allow or refuse the far site’s machines by their real addresses.
- Each site needs its route. A reply to
10.20.0.9has to find router B, and the route for10.20.0.0/16at site B is what sends it there.
A connection that a router opens itself, or that another Guard node opens through a router, is different. It arrives from the router’s address on the site, as on any subnet router.
Both grants are required, and both directions are open
Section titled “Both grants are required, and both directions are open”A grant gives a router its route to the far subnet. With only one grant, nothing crosses: the far router has no route for the near site’s addresses, so it drops what arrives from them and has no way to send a reply. With both grants, the machines at either site can open connections to the machines at the other.
Between the two subnets, Guard passes every port and protocol. A router drops only what comes from, or is bound for, an address outside the two resources, as in How Guard enforces grants. To limit what crosses, use one or both of these:
- Serve less. A resource can be a smaller range, or a single machine with
kind
host. The far site gets a route for that range only. - Filter at the sites, in the firewall or security group that protects the machines. The far machines’ real addresses are what it sees.
Set up a router at each site
Section titled “Set up a router at each site”Register a router at each site, with the site’s own subnet as the resource that it serves. Then install the client on it and join.
- At site A, follow Register the router and Install the client and join, with site A’s range as the subnet.
- At site B, do the same with site B’s range.
With awctl, the two registrations look like this:
awctl guard context set --tenant TENANT --network NETWORK
awctl guard nodes create --display-name site-a-router --out site-a.codeawctl guard resources create --display-name "Site A" \ --kind subnet --address 10.20.0.0/16 --serving-node-ids SITE_A_NODE_ID
awctl guard nodes create --display-name site-b-router --out site-b.codeawctl guard resources create --display-name "Site B" \ --kind subnet --address 10.30.0.0/16 --serving-node-ids SITE_B_NODE_IDReplace TENANT and NETWORK with your tenant and Guard network. Each
nodes create prints the node’s name, which ends in its ID (nd-…). Use
those IDs as SITE_A_NODE_ID and SITE_B_NODE_ID. Each
resources create prints the resource that it created. The next section
uses the two resource IDs.
Grant each router the other site
Section titled “Grant each router the other site”- In the console, open site A’s router. Under Can reach, select site B’s resource.
- Open site B’s router. Under Can reach, select site A’s resource.
With awctl:
awctl guard nodes add-grants SITE_A_NODE_ID resources/SITE_B_RESOURCE_IDawctl guard nodes add-grants SITE_B_NODE_ID resources/SITE_A_RESOURCE_IDReplace SITE_A_RESOURCE_ID and SITE_B_RESOURCE_ID with the IDs of the
two resources.
Each router picks the change up at its next configuration poll, within a minute.
Route each site to its router
Section titled “Route each site to its router”At each site, send the other site’s subnet to the local router’s address
on that site. In the example, site A routes 10.30.0.0/16 to 10.20.0.5,
and site B routes 10.20.0.0/16 to 10.30.0.5.
| Where the site is | What to do |
|---|---|
| A network with its own gateway or firewall | On the gateway, add a static route for the far subnet with the router’s address as the next hop. |
| An AWS VPC | In each route table that the machines use, add a route for the far subnet with the router instance as the target. Turn off the source and destination check on the router instance. |
| A Google Cloud VPC | Turn on IP forwarding for the router instance. Add a static route for the far subnet with the router instance as the next hop. A served range can hold the addresses of internal passthrough load balancers. For those, the MSS has to be lowered on the router, which a router on Guard client 0.26.0 or later does by itself. See Keep large packets from stalling connections. |
| An Azure virtual network | Turn on IP forwarding on the router’s network interface. Add a user-defined route for the far subnet, with next hop type virtual appliance and the router’s private address. |
| One machine only | On that machine, add the route by hand, as in the command after this table. |
sudo ip route add 10.30.0.0/16 via 10.20.0.5A cloud network drops packets that an instance forwards for other addresses unless you turn that check off, which is why the cloud rows have two parts. A machine whose default gateway is the router needs no extra route.
Then let the traffic through. In each site’s firewall or security groups, allow the far subnet to reach the machines, and allow the machines to reach the far subnet. If the router has a host firewall, allow forwarding in and out of the tunnel interface, as in Troubleshooting for a subnet router.
Check that it works
Section titled “Check that it works”-
On each router, run
awguard status. The line for the other router lists the far subnet underROUTES, and shows the path asdirectorrelay-udp.Terminal window awguard status -
From a machine at site A, reach a machine at site B at its own address.
Terminal window ping 10.30.0.9 -
Repeat in the other direction, from a machine at site B to a machine at site A.
To see the address that a connection arrives from, watch on the receiving
machine while the ping runs. The requests come from 10.20.0.9.
sudo tcpdump -ni any icmpRun two routers at a site
Section titled “Run two routers at a site”One router at a site is a single point of failure. Two routers at a site need two things, one in Guard and one on the site.
In Guard, let both routers serve the site’s resource, and grant the far site’s resource to both:
awctl guard resources add-nodes SITE_A_RESOURCE_ID SECOND_NODE_IDawctl guard nodes add-grants SECOND_NODE_ID resources/SITE_B_RESOURCE_IDReplace SECOND_NODE_ID with the ID of site A’s second router. The far
routers send site A’s traffic to one of the two, and keep using it while
it answers. When it goes quiet, they move to the other in about a minute.
This needs Guard client 0.23.0 or later on the routers.
On the site, the route for the far subnet names one next hop, and Guard doesn’t move it when a router stops. Give the route a next hop that survives one router:
- On a network that you run, share a virtual IP address between the two
routers with the Virtual Router Redundancy Protocol (VRRP), for example
with
keepalived, and route the far subnet to that address. - In a cloud network, use the platform’s own way to keep a route’s next hop healthy, such as a route to an internal passthrough load balancer in front of both routers.
A reply might come back through a different router than the request used, because each router chooses its far router by itself. Guard’s own rules allow that. A host firewall on a router that drops packets it has no tracked connection for doesn’t, so allow forwarding through the tunnel interface there without a connection-state condition.
Connect more than two sites
Section titled “Connect more than two sites”Every pair of sites is its own connection. For each pair, grant each router the other site’s resource, and add a route at each site for every other site’s subnet. Traffic between two sites goes between their two routers and never through a third site’s router.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause and fix |
|---|---|
| Requests reach the far machine and no reply comes back | The far site has no route for the near subnet. Add the route. If the far router runs a Guard client earlier than 0.26.0, the far router might also lack the grant to the near site’s resource. Add the grant. |
| Nothing reaches the far machine | The near site doesn’t route the far subnet to its router, or a cloud network drops forwarded packets. Check the route, and the source and destination check or IP forwarding setting on the router instance. Or the far router isn’t granted the near site’s resource, and drops what arrives “from an address the peer does not hold”. Add the grant. See Read what a node dropped. |
| The routers reach each other’s machines and other machines don’t | The machines’ route to the far subnet doesn’t go through the router. Add the route on the gateway or route table that those machines use. |
| Small requests work and large transfers stall, or each new connection pauses for several seconds | The tunnel carries packets of up to 1280 bytes. A router tells a sender to use smaller packets with an ICMP “fragmentation needed” message. Allow ICMP from the routers to the machines. Where that message can’t reach the sender, for example behind a passthrough load balancer, the MSS has to be lowered on the router. A router on Guard client 0.26.0 or later does this by itself. See Keep large packets from stalling connections. |
| The resource is refused as overlapping | The two sites’ ranges overlap. Renumber one site, or serve a smaller range that doesn’t overlap. |
| Traffic works and is slow | The path between the routers is relay-udp. See Make the router reachable directly. |
What’s next
Section titled “What’s next”- Route a subnet through a Linux node covers what the client changes on a router and how to give it a direct path.
- Reach nodes and applications by name publishes an application at a site by hostname to the Guard nodes that you grant.