---
title: "Connecting VPCs across zones and organizations with WireGuard"
description: "Exoscale VPCs live in one zone and one organization. Here is the simplest way to connect two of them: one small gateway per VPC, one WireGuard tunnel, one route."
date: 2026-12-03
author: "Denis Arnst"
tags: ["Network","VPC","VPN"]
url: https://www.exoscale.com/blog/vpc-to-vpc-wireguard/
---
# Connecting VPCs across zones and organizations with WireGuard

![Two VPCs in different zones. In each, a route sends traffic for the other VPC to a small gateway, and the two gateways are connected by a WireGuard tunnel.](https://www.exoscale.com/blog/vpc-to-vpc-wireguard/cover.png)

An [Exoscale VPC](https://community.exoscale.com/product/networking/vpc/) is a private network for your instances. It lives in **one zone** and belongs to **one organization**.

Sometimes two VPCs need to talk anyway: a database replica in another zone, or a partner organization that needs one of your services. [VPC peering](https://www.exoscale.com/virtual-private-cloud/) is coming, but it will only connect VPCs in the same zone and the same organization.

For everything else, this is the simplest setup we found:

- **one small Ubuntu gateway** in each VPC,
- **one WireGuard tunnel** between the gateways,
- **one route** in each VPC that sends traffic to its gateway.

It works the same between zones and between organizations. We tested it between Geneva, Vienna and Frankfurt, across two organizations.

## What you need

Per VPC:

| Resource | How many | Notes | Cost |
|---|---|---|---|
| VPC with one subnet | 1 | Ranges must not overlap with the other side | free |
| Security Group | 1 | 4 rules | free |
| Gateway instance | 1 | `standard.micro`, Ubuntu 24.04, with `--ip-forwarding` | about €6.30 / month, including its 10 GB disk |
| Route | 1 per other VPC | Points to the gateway | free |
| App instances | the ones you already have | One extra network route, set by cloud-init | – |

The two sides only exchange **the gateway's public IP and its WireGuard public key**.

So connecting two VPCs costs about **€13 a month**: one small instance on each side. VPC and private traffic are free. The tunnel runs over the gateways' public interfaces, which include 1.42 GiB of outbound traffic per hour, roughly 1 TB a month. Above that, traffic costs €0.02 per GB. Prices are from the [pricing page](https://www.exoscale.com/pricing/) at the time of writing, without tax.

## How it works

![Each VPC has one subnet. A route sends traffic for the other VPC to the local gateway, which sends it through the WireGuard tunnel.](https://www.exoscale.com/blog/vpc-to-vpc-wireguard/architecture.svg)

When `app-a` sends a packet to `10.20.1.10`:

1. The VPC route sends it to the gateway, `10.10.1.5`.
2. The gateway sends it through the tunnel to the other gateway.
3. That gateway delivers it to `app-b`. The reply takes the same way back.

There is no NAT: `app-b` sees the real address of `app-a`.

We use these addresses:

| | VPC A | VPC B |
|---|---|---|
| Zone | ch-gva-2 | at-vie-1 |
| VPC range | 10.10.0.0/16 | 10.20.0.0/16 |
| Subnet | 10.10.1.0/24 | 10.20.1.0/24 |
| Gateway | 10.10.1.5 | 10.20.1.5 |

**The ranges must not overlap.** Between organizations, agree on them first.

The commands below are for side A. Side B is the same with its own addresses.

## Step 1: Create the VPC and a Security Group

```console
exo networking vpc create vpc-a -z ch-gva-2
exo networking vpc subnet create vpc-a app -z ch-gva-2 \
    --address-family inet4 --address-space private --ipv4-block 10.10.1.0/24

exo compute security-group create vpn
exo compute security-group rule add vpn --flow ingress --protocol udp \
    --port 51820 --network <PUBLIC-IP-OF-OTHER-GATEWAY>/32
exo compute security-group rule add vpn --flow ingress --protocol tcp \
    --port 1-65535 --network 10.0.0.0/8
exo compute security-group rule add vpn --flow ingress --protocol icmp \
    --network 10.0.0.0/8 --icmp-type -1 --icmp-code -1
exo compute security-group rule add vpn --flow ingress --protocol tcp \
    --port 22 --network <YOUR-IP>/32
```

The first rule lets the other gateway in. The next two allow traffic from the VPCs. Security Groups also filter traffic inside a VPC, so later you can narrow these to the ports you need.

![The VPC with its subnet in the Exoscale console](https://www.exoscale.com/blog/vpc-to-vpc-wireguard/vpc-subnets.png)

## Step 2: Create the gateway

Save this as `gateway.yaml`:

```yaml
#cloud-config
packages: [wireguard]
write_files:
  - path: /etc/sysctl.d/90-forward.conf
    content: "net.ipv4.ip_forward=1\n"
  - path: /etc/netplan/60-vpc.yaml
    permissions: "0600"
    content: |
      network:
        version: 2
        ethernets:
          eth1:
            dhcp4: true
runcmd:
  - sysctl -p /etc/sysctl.d/90-forward.conf
  - netplan apply
```

```console
exo compute instance create gateway-a -z ch-gva-2 \
    --template "Linux Ubuntu 24.04 LTS 64-bit" --instance-type standard.micro \
    --security-group vpn --ssh-key <YOUR-KEY> \
    --cloud-init gateway.yaml --ip-forwarding
exo compute instance attach-to-subnet gateway-a vpc-a app --ipv4 10.10.1.5 -z ch-gva-2
```

Don't forget `--ip-forwarding`. It allows the gateway to pass on other machines' traffic, and **you can't add it later**.

![The gateway in the console, with IP forwarding turned on](https://www.exoscale.com/blog/vpc-to-vpc-wireguard/gateway-ip-forwarding.png)

## Step 3: Start the tunnel

**On each gateway**, create a key. The command prints the public key, which you send to the other side:

```bash
sudo sh -c 'umask 077; wg genkey > /etc/wireguard/private.key'
sudo cat /etc/wireguard/private.key | wg pubkey
```

The private key stays in its file on the gateway. Nobody needs to copy it.

If one person runs both gateways, they can fetch the other public key from their laptop instead:

```bash
ssh ubuntu@<PUBLIC-IP-OF-GATEWAY-B> 'sudo cat /etc/wireguard/private.key | wg pubkey'
```

**Then, on each gateway**, fill in the three values for the *other* side and paste the whole block:

```bash
PEER_KEY="<public key of the other gateway>"
PEER_IP="<public IP of the other gateway>"
PEER_RANGE="10.20.0.0/16"     # the other VPC's range (on gateway-b: 10.10.0.0/16)

sudo tee /etc/wireguard/wg0.conf >/dev/null <<EOF
[Interface]
PostUp = wg set %i private-key /etc/wireguard/private.key
ListenPort = 51820

[Peer]
PublicKey = $PEER_KEY
Endpoint = $PEER_IP:51820
AllowedIPs = $PEER_RANGE
PersistentKeepalive = 25
EOF

sudo systemctl enable --now wg-quick@wg0
sudo wg show
```

When `wg show` shows a `latest handshake`, the tunnel is up.

`AllowedIPs` is the other VPC's range. WireGuard sends that range through the tunnel, and only accepts that range from the other side. You don't need tunnel addresses or firewall rules.

## Step 4: Add the route

```console
exo networking vpc route create vpc-a -z ch-gva-2 --subnet app \
    --destination 10.20.0.0/16 --target ip=10.10.1.5
```

On side B: `--destination 10.10.0.0/16 --target ip=10.20.1.5`.

![The routes of the subnet: the subnet's own route, and the routes to the other VPCs through the gateway](https://www.exoscale.com/blog/vpc-to-vpc-wireguard/subnet-routes.png)

## Step 5: Prepare your app instances

Your instances need one more line. Today, the [instance itself needs a route](https://community.exoscale.com/product/networking/vpc/how-to/cross-subnet-communication/) that sends private traffic into the VPC, through the subnet's `.1` address. Create your instances with this `app.yaml`:

```yaml
#cloud-config
write_files:
  - path: /etc/netplan/60-vpc.yaml
    permissions: "0600"
    content: |
      network:
        version: 2
        ethernets:
          eth1:
            dhcp4: true
            routes:
              - to: 10.0.0.0/8
                via: 10.10.1.1
                on-link: true
runcmd:
  - netplan apply
```

```console
exo compute instance create app-a -z ch-gva-2 \
    --template "Linux Ubuntu 24.04 LTS 64-bit" --instance-type standard.micro \
    --security-group vpn --ssh-key <YOUR-KEY> --cloud-init app.yaml
exo compute instance attach-to-subnet app-a vpc-a app -z ch-gva-2
```

Only the app instances get this route, not the gateway.

## Test it

```text
app-a$ ping -c3 10.20.1.10
rtt min/avg/max/mdev = 16.609/16.664/16.729/0.049 ms
```

Geneva to Vienna: about 17 ms. The web server on `app-b` logs `10.10.1.10`, the real address of `app-a`.

Test from an app instance, not from the gateway. The gateway sends its own packets from its public IP, which the other side doesn't accept. On the gateway, use `ping -I 10.10.1.5 10.20.1.10`.

If it doesn't work right away, wait a minute. In a new VPC, a new route took about a minute to apply in our tests.

## Between organizations

Nothing changes. Each organization creates its own VPC, gateway and route. They only exchange two things: **the gateway's public IP and its WireGuard public key**. Nobody needs access to the other organization.

Either side can cut the link alone, by deleting its route or stopping the tunnel.

## More than two VPCs

To add a third VPC, add one more `[Peer]` block on the gateway and one more route on each side. Our Geneva gateway connects to Vienna (same organization) and to Frankfurt (another organization). You can see both routes in the screenshot of step 4.

The gateway doesn't connect Vienna and Frankfurt to each other. They only reach what you add routes for, which is what you want with a partner.

## Kubernetes nodes (SKS)

[SKS Nodepools can join a VPC](https://community.exoscale.com/product/compute/containers/how-to/sks-vpc/) too:

```console
exo compute sks nodepool add my-cluster my-nodepool -z ch-gva-2 \
    --size 3 --instance-type standard.medium --security-group my-sks-nodes \
    --vpc vpc-a --vpc-subnet app
```

The nodes need the same route as the app instances in step 5, but you can't give them your own cloud-init. A small DaemonSet sets the route on every node instead:

```yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: vpc-route
  namespace: kube-system
spec:
  selector:
    matchLabels: {app: vpc-route}
  template:
    metadata:
      labels: {app: vpc-route}
    spec:
      hostNetwork: true
      tolerations: [{operator: Exists}]
      containers:
        - name: route
          image: alpine:3.22
          securityContext:
            capabilities: {add: ["NET_ADMIN"]}
          command:
            - sh
            - -c
            - |
              apk add --no-cache iproute2 >/dev/null
              while true; do
                ip route replace 10.0.0.0/8 via 10.10.1.1 dev eth1
                sleep 60
              done
```

The loop puts the route back if it disappears, for example after a reboot. We tested it with an SKS node in Geneva: a pod reached `app-b` in Vienna in about 17 ms. The other side sees the node's VPC address, not the pod's address.

## What about Layer 2?

A VPC is a Layer 3 network: no broadcast, no multicast. Tools like keepalived (VRRP) don't work in it directly.

If an application really needs one Layer 2 segment across zones, you can run VXLAN on the VMs themselves, through the tunnel from this post. We tested it between Geneva and Vienna: a keepalived VIP moved to the other zone in about 2 seconds. Inside the overlay, the MTU is 1370.

With more VMs, it gets more work. Without multicast, every VM needs a list of all the others, and every broadcast is sent to each VM separately. We tested it with four VMs, two per zone. That's fine for a few fixed VMs, but not for many. A mesh VPN like NetBird or Tailscale doesn't help here, because it also only carries IP.

But be careful: when we cut the link between the zones, **both sides took the VIP** (split brain). For geo-redundancy, we recommend connecting the zones at Layer 3 and handling failover in the application or through DNS.

## Good to know

- **One gateway is a single point of failure.** For high availability, run a second gateway and point the route at it when the first one fails.
- **The gateway's size limits bandwidth.** A `standard.micro` is fine to start with. Measure your traffic and size up if needed.
- **The tunnel's MTU is 1420.** Normal TCP traffic adjusts to it by itself. If large packets get stuck, for example because a firewall blocks ICMP, check this first.
- **Many sites or many users?** With more than a handful of tunnels, a mesh VPN with a central dashboard is easier to manage. We'll look at one in a follow-up.
- **Same zone and same organization?** Use VPC peering once it is available.

## Summary

Three things per VPC: a gateway with IP forwarding, a WireGuard config, and a route. It costs about €6 a month per side. It's plain Ubuntu and plain WireGuard, so any Linux admin can run and debug it.

Learn more:

- [VPC documentation](https://community.exoscale.com/product/networking/vpc/)
- [Connect a VPC to an external network with WireGuard](https://community.exoscale.com/product/networking/vpc/recipes/wireguard-gateway/), for a VPC and a network outside of Exoscale
- [Building a Landing Zone on Exoscale](https://www.exoscale.com/blog/landing-zone/)

