Create a WireGuard® Peer Between Two VDCs
Overview
This tutorial demonstrates how to configure the VPN Gateway product in IONOS CLOUD to create a WireGuard® based site-to-site setup between two Virtual Data Centers (VDCs) in different regions. It uses a managed WireGuard instance in each VDC to provide secure, encrypted connectivity between the two networks.
This tutorial demonstrates the use of the following:
Components
Description
Two VDCs
- Berlin VPN example (de/txl) is the first VDC.
- London VPN example (gb/lhr) is the second VDC.
Managed gateways
A managed WireGuard gateway in each VDC (wg-txl and wg-lhr) provides secure, encrypted connectivity between the two VDCs in IONOS CLOUD.


Target audience
This tutorial is intended to help both developers and technical decision-makers.
What you will learn
By following this tutorial, you will learn how to:
Provision managed WireGuard VPN Gateways in IONOS CLOUD across different regions.
Generate and manage WireGuard key pairs for secure connectivity.
Set up LAN subnets and assign gateway addresses.
Configure a VPN peer on each gateway for site-to-site communication.
Manually add routing rules to enable traffic flow between the two VDCs.
Verify connectivity between hosts in separate VDCs.
Before you begin
The following information is necessary to set up a WireGuard connection between two VDCs:
Components
Berlin VPN (Left) de/txl
London VPN (Right) gb/lhr
Datacenter Name
Berlin VPN example
London VPN example
Gateway Name
wg-txl
wg-lhr
Gateway Public Address
203.0.113.10
203.0.113.20
LAN ID
1
2
LAN Subnet
192.168.1.0/24
192.168.2.0/24
Gateway LAN Address
192.168.1.5/24
192.168.2.5/24
LAN Host 1
192.168.1.11 (berlin-lan-host-1)
192.168.2.11 (london-lan-host-1)
LAN Host 2
192.168.1.12
192.168.2.12
WireGuard Subnet
172.16.1.0/30
172.16.1.0/30
Gateway WireGuard Address
172.16.1.1/30
172.16.1.2/30
Gateway Private Key
abcdefABC12345=
kHKHABcC+67891=
Gateway Public Key
defDEFhiH/98765=
lmnoLMNO/89762=
Create the VDCs
Ensure you have already created two VDCs, one in de/txl and one in gb/lhr. Each VDC must contain two virtual servers connected to each other via a private LAN. For more information, see Create a Data Center.
Reserve IP addresses
Before proceeding, ensure you have an IP block with at least one free IP address to assign to each gateway. Each VPN Gateway must be assigned a public IP address. For more information, see Reserve an IPv4 Address.
Components
Berlin VPN (Left) de/txl
London VPN (Right) gb/lhr
Gateway Public Address
203.0.113.10
203.0.113.20
Configure LAN
This tutorial uses 192.168.1.0/24 for the private LAN in Berlin and 192.168.2.0/24 for the private LAN in London. Assign an IP address from each subnet to its respective gateway. For example, use 192.168.1.5 for the Berlin VPN Gateway and 192.168.2.5 for the London VPN Gateway.
The VPN Gateway is not DHCP-aware. Therefore, assign it a static address that is outside the DHCP pool, in the range from .2 to .9.
Components
Berlin VPN (Left) de/txl
London VPN (Right) gb/lhr
LAN ID
1
2
LAN Subnet
192.168.1.0/24
192.168.2.0/24
Gateway LAN Address
192.168.1.5/24
192.168.2.5/24
WireGuard interface IP address and subnet information
Each participant in a WireGuard VPN setup requires its own WireGuard interface address and subnet, which are unrelated to the networks you use in the cloud. Choose a subnet that does not conflict with anything already in use in the cloud or on the other side of the connection.
This tutorial connects two gateways, so it uses a /30 subnet. A /30 provides 2 usable host addresses, one for each gateway.
Components
Berlin VPN (Left) de/txl
London VPN (Right) gb/lhr
WireGuard Subnet
172.16.1.0/30
172.16.1.0/30
Gateway WireGuard Address
172.16.1.1/30
172.16.1.2/30
Generate key pairs
WireGuard requires a key pair for each gateway. You can generate them using the WireGuard utilities or the OpenSSL command-line tools. This tutorial describes both approaches and recommends the WireGuard utilities because the procedure is more straightforward. Generate one key pair for each gateway.
Components
Berlin VPN (Left) de/txl
London VPN (Right) gb/lhr
Gateway Private Key
abcdefABC12345=
kHKHABcC+67891=
Gateway Public Key
defDEFhiH/98765=
lmnoLMNO/89762=
Use wg genkey to create the private key and wg pubkey to derive the public key content from the private key. You can also perform it via a single command, as shown below. The umask 077 command ensures that only your user can read the key files. Repeat the process for each gateway.
The output shows the private key followed by the public key:
Use openssl to generate der keys and convert them to the required format for WireGuard. The umask 077 command ensures that only your user can read the key files. Repeat the process for each gateway:
The output shows the private key followed by the public key:
If the WireGuard tools are also available locally, you can verify the OpenSSL-generated key by deriving the public key from the OpenSSL-generated private key.
The output shows the public key:
The public key content matches the one generated by OpenSSL.
Procedure
Set up the VDCs
The following screenshot from the Data Center Designer (DCD) shows the Berlin VDC. It contains two virtual servers that are connected to each other via a private LAN. They have no other connectivity. In this instance, LAN 1 uses a custom subnet of 192.168.1.0/24. The two LAN hosts use the addresses 192.168.1.11 and 192.168.1.12.

Set up the London VDC in the same way, using LAN 2 with the custom subnet 192.168.2.0/24. The two LAN hosts use the addresses 192.168.2.11 and 192.168.2.12.
Provision the VPN Gateways
Create the Berlin gateway (wg-txl) first, and then repeat the procedure for the London gateway (wg-lhr) using the values for that site.
1. In the DCD, go to Menu > Network Services > VPN Gateway.
2. Click Create VPN Gateway from the VPN Gateways window.
3. Enter the following details:
Components
Description
Example (Berlin)
Example (London)
Name
Enter a descriptive name for the gateway instance. It is not required to be globally unique but must be limited to 255 characters.
wg-txl
wg-lhr
Description
Enter a descriptive text for the gateway. It is limited to 1024 characters.
Not applicable
Not applicable
Location
Select a location from the drop-down list of available locations for VPN Gateway.
de/txl
gb/lhr
IP Address
Select an IP address from the drop-down list of available Public IPv4 Addresses.
203.0.113.10
203.0.113.20

The Enhanced VPN tier is selected by default. The number of LANs and peers differ for each tier. You can also enable High Availability for a chosen tier, allowing VMs to operate in an active-passive mode. It minimizes downtime during a failover and ensures an uninterrupted connection.

Select WireGuard protocol and specify the following:
Components
Description
Example (Berlin)
Example (London)
Private Key
The gateway_private_key value generated earlier in this tutorial for this gateway.
abcdefABC12345=
kHKHABcC+67891=
Interface IPv4
The IPv4 address of the WireGuard interface.
172.16.1.1/30
172.16.1.2/30
Interface IPv6
The IPv6 address of the WireGuard interface. This demonstration does not contain IPv6 addresses.
Not applicable
Not applicable
ListenPort
The UDP port on which WireGuard listens for encrypted VPN packets. The tutorial uses the default value 51820.
51820
51820

Attach a VPN Gateway to LANs in IONOS CLOUD. You can only connect to LANs in the exact location where the VPN Gateway was provisioned. Take a look at the following mandatory parameters:
Components
Description
Example (Berlin)
Example (London)
Datacenter
Select a data center from the drop-down that lists VDCs in the same location as the gateway.
Berlin VPN example
London VPN example
Connections
After selecting a data center, click Add LAN Connection to open an additional pop-up window to set the properties.
See Below
See Below
Enter the following in the Edit LAN Connection pop-up window:
Components
Description
Example (Berlin)
Example (London)
LAN
The ID of the LAN to connect to.
1
2
IPv4 CIDR
The LAN IPv4 address assigned to the subnet's gateway in CIDR notation.
192.168.1.5/24
192.168.2.5/24
IPv6 CIDR
The LAN IPv6 address assigned to the subnet's gateway in CIDR notation.
Not applicable
Not applicable

4. Click Save and wait for the gateway to complete provisioning. The process typically takes about 10-15 minutes, but further operations on the gateway are almost instantaneous. When provisioning completes, the gateway status shows Available.
Configure the VPN peers
Now that the VPN Gateway instances are provisioned, configure a peer on each gateway to permit the two sides to communicate with each other. Configure the peer to_lhr on wg-txl and the peer to_txl on wg-lhr.
1. Click Create Peers to begin configuring a new peer.

Enter the following details to configure a peer:
Components
Description
Example (on wg-txl)
Example (on wg-lhr)
Peer Name
Specify a name for the peer. The name is not required to be unique and can be up to 255 characters long.
to_lhr
to_txl
Description
Enter more descriptive text for the peer, not exceeding 1024 characters.
Not applicable
Not applicable

Configure the endpoint so the gateway knows with which remote address the connection must be established. Set it to the public IPv4 address of the gateway in the other location.
Components
Description
Example (on wg-txl)
Example (on wg-lhr)
Endpoint host
The gateway public IPv4 address of the remote gateway.
203.0.113.20
203.0.113.10
Endpoint port
The endpoint port on which WireGuard listens for incoming encrypted VPN packets. The tutorial uses the default value 51820.
51820
51820

The peers section specifies which networks are permitted across the peer. Specify the LAN subnet of the remote site in CIDR notation, together with the public key of the remote gateway.
Components
Description
Example (on wg-txl)
Example (on wg-lhr)
Allowed IPs
Enter a comma separated list of subnets in CIDR notation that are permitted to send traffic to the given peer. It is the LAN subnet used on the remote site.
192.168.2.0/24
192.168.1.0/24
Public Key
The public key of the remote gateway, as generated earlier in this tutorial.
lmnoLMNO/89762=
defDEFhiH/98765=

2. Click Save to save the peer configuration. This operation typically completes within a few minutes at most. When the operation completes, the gateway status shows Available.
3. Repeat the steps on the wg-lhr gateway in London, using the values from the Example (on wg-lhr) column.
Final result
You can now test connectivity across the VPN from either side. From a LAN host in Berlin, run ping against a LAN host in London (192.168.2.11). From a LAN host in London, run ping against a LAN host in Berlin (192.168.1.11).
On the Berlin LAN host berlin-lan-host-1, test connectivity to a London LAN host:
On the London LAN host london-lan-host-1, test connectivity to a Berlin LAN host:
Conclusion
You have successfully configured two managed WireGuard gateways connected to different VDCs and established a site-to-site VPN connection between them in IONOS CLOUD.
Next steps
Connect a VDC to an on-premises network, as described in Create a WireGuard® Peer between a VDC and an on-premises Gateway.
Set up the same VDC-to-VDC connection using IPSec, as described in Create an IPSec Tunnel between two VDCs.
Download the configuration of your VPN Gateway, as described in Download VPN Gateway Configuration.
Learn more about VPN Gateway features and limits in the VPN Gateway Overview.
Last updated
Was this helpful?

