Create a WireGuard Peer between a VDC and an on-premises Gateway
Overview
This tutorial demonstrates configuring the VPN Gateway in IONOS Cloud to create a site-to-site setup between an IONOS Cloud VDC and a simulated on-premises installation. It uses a managed WireGuard instance to provide secure, encrypted connectivity between an IONOS Cloud VDC and a simulated on-premises setup.
This tutorial demonstrates the use of the following:
Components
Description
Two VDCs
- ionos-cloud-txl as IONOS Cloud's VDC.
- user-on-prem-lhr simulates a user-managed on-premises setup.
Managed gateways
We use a single managed gateway in ionos-cloud-txl for the cloud side.
For a user-managed gateway, we use on-premises simulation, install the components, and manually configure WireGuard on a virtual server to complete the setup.

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:
Set up a managed WireGuard VPN Gateway in IONOS Cloud.
Simulate an on-premises WireGuard gateway using a virtual server.
Generate and manage WireGuard key pairs for secure connectivity.
Configure VPN peers and endpoints for site-to-site communication.
Deploy and configure WireGuard on a user-managed gateway.
Manually add routing rules to enable traffic flow between cloud and on-premises LANs.
Verify end-to-end connectivity between the two sites.
Before you begin
The following information is necessary to set up a connection between a WireGuard VDC and an on-premises VDC:
Components
IONOS Cloud (Left) ionos-cloud-txl
User On-Premises (Right) user-on-prem-lhr
VDC Name
ionos-cloud-txl
user-on-prem-lhr
Gateway Public Address
203.0.113.10
203.0.113.20
LAN ID
1
2 (Not applicable in this use case)
LAN Subnet
192.168.1.0/24
192.168.2.0/24
Gateway LAN Address
192.168.1.5
192.168.2.5
LAN Host 1
192.168.1.11
192.168.2.11
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=
Pre-Shared Key
defDEFhiH/98765=
lmnoLMNO/89762=
Reserve IP addresses
Before proceeding, ensure you have an IP block with at least one free IP address to assign to each gateway. For more information, see Reserve an IPv4 Address.
IONOS Cloud (Left) ionos-cloud-txl Gateway Public Address
User On-Premises (Right) user-on-prem-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 IONOS Cloud (Left) and 192.168.2.0/24 for User On-Premises (Right). Assign an IP address from each subnet to its respective gateway. For example, use 192.168.1.5 for the VPN Gateway, as it is not DHCP-aware. The chosen IP address must be outside the DHCP pool and should be in the range from .2 to .9.
Components
IONOS Cloud (Left) ionos-cloud-txl
User On-Premises (Right) user-on-prem-lhr
LAN ID
1
2 (But not applicable here)
LAN Subnet
192.168.1.0/24
192.168.2.0/24
Gateway LAN Address
192.168.1.5
192.168.2.5
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. It should be a subnet that does not conflict with anything already in the cloud or on the client side.
Components
IONOS Cloud (Left) ionos-cloud-txl
User On-Premises (Right) user-on-prem-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 Keypairs
WireGuard requires a key pair for the gateway and each connected peer. You can generate them using the WireGuard utilities or the OpenSSL command-line tools. Although we describe both approaches below, we recommend the former because it is a more straightforward procedure.
Components
IONOS Cloud (Left) ionos-cloud-txl
User On-Premises (Right) user-on-prem-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. Repeat the process for the gateway and each peer.
demo: wg genkey |tee gateway_private_key | wg pubkey > gateway_public_key
demo: cat gateway_private_key
abcdefABC12345=
demo: cat gateway_public_key
defDEFhiH/98765=Use openssl to generate der keys and convert them to the required format for WireGuard. We will use this to create the keypair:
demo: openssl genpkey -algorithm X25519 -outform der -out user_private.der
demo: openssl pkey -inform der -in user_private.der -pubout -outform der -out user_public.der
demo: cat user_private.der |tail -c 32 | base64 > user_private_key
demo: cat user_public.der |tail -c 32 | base64 > user_public_key
demo: rm *.der
demo: cat user_private_key
kHKHABcC+67891=
demo: cat user_public_key
lmnoLMNO/89762=With both these tools available locally, we can verify the OpenSSL-generated key by using the WireGuard tools to derive the public key from the OpenSSL-generated private key.
demo: wg pubkey < user_private_key
lmnoLMNO/89762=As we can see, the public key content matches the one generated by OpenSSL.
Process
Set up IONOS Cloud
Below are some screenshots from the DCD that contains the required VDCs.
To begin with, two virtual servers on the IONOS Cloud are provisioned and connected to each other via a private LAN. In this instance, LAN1 uses a custom subnet of 192.168.1.0/24. We designate these two LAN hosts as 192.168.1.11 and 192.168.1.12, respectively.

Simulate on-premises setup
Imagine the user-on-prem-lhr VDC as a user-managed site where you provision two virtual servers. Here, we will use the subnet 192.168.2.0/24. Host 1 has been configured with internet access (IP address: 203.0.113.20) and will function as the on-premises host acting as a user-managed gateway. We address these two LAN hosts as 192.168.2.11 and 192.168.2.12, respectively and the user managed VPN gateway is assigned the following IP address: 192.168.2.5.

Provision the VPN Gateway
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
Name
Enter a descriptive name for the gateway instance. It is not required to be globally unique but must be limited to 255 characters.
ionos-cloud-txl
Description
Enter a descriptive text for the gateway. It is limited to 1024 characters.
VPN Gateway for creating a WireGuard Peer between a VDC and on-premises gateway.
Location
Select a location from the drop-down list of available locations for VPN Gateway.
de/txl
IP Address
Select an IP address from the drop-down list of available public IPv4 addresses.
203.0.113.10

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
Private Key
The gateway_private_key value generated earlier in this document.
abcdefABC12345=
Interface IPv4
The IPv4 address of the WireGuard interface.
172.16.1.1/30
Interface IPv6
The IPv6 address of the WireGuard interface. This demonstration does not contain IPv6 addresses.
Not applicable
ListenPort
The UDP port on which WireGuard will listen for encrypted VPN packets. The tutorial uses the default value 51280.
51280

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
Datacenter
Select a data center from the drop-down that lists VDCs in the same location as the gateway.
ionos-cloud-txl
Connections
After selecting a data center, click Add LAN Connection to launch an additional pop-up window to set the properties.
See Below
Enter the following in the Edit LAN Connection pop-up window:
Components
Description
Example
LAN
The ID of the LAN to connect to.
1
IPv4 CIDR
The LAN IPv4 address assigned to the subnet's gateway in CIDR notation.
192.168.1.5
IPv6 CIDR
The LAN IPv6 address assigned to the subnet's gateway in CIDR notation.
Not applicable

4. Click Save and wait for the gateway to complete provisioning. The process typically takes about 8-10 minutes, but further operations on the gateway will be instantaneous.
Configure the VPN peer
Now that the VPN Gateway instance is provisioned, next step is to configure a peer to permit the two sides to talk with each other. We will need to configure a peer on both gateways but the on-premises will be configured using WireGuard configuration files.
1. Click Create Peers to begin configuring a new peer.

Enter the following details to configure a peer:
Components
Description
Example
Peer Name
Specify a name for the peer. It does not need to be globally unique and can be up to 255 characters long.
customer_site
Description
Enter more descriptive text for the peer, not exceeding 1024 characters.
Not applicable

Configure the endpoint so the gateway knows with which remote address the connection must be established. We will configure this as the public IPv4 address of the gateway to be created in user-on-prem-lhr.
Components
Description
Example
Endpoint host
The gateway public IPv4 address of the remote on-prem gateway.
203.0.113.20
Endpoint port
The endpoint port on which WireGuard will listen for incoming encrypted VPN packets. The tutorial uses the default value 51280.
51280

The peers section specifies which networks are permitted across the peer. Here we will specify the WireGuard subnet in CIDR notation as described earlier.
Components
Description
Example
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 subnet used on the peer side.
192.168.2.0/24
Public Key
The public key of the peer as we generated earlier in this tutorial.
lmnoLMNO/89762=

2. Click Save to save the peer configuration. This operation should typically be completed within a minute or two.
Deploy on-premises WireGuard instance
In this tutorial, the on-premises "User VPN GW" Host acts as a user-managed gateway. The host has internet access, so SSH can be used instead of the web console. Start by establishing an SSH connection to the on-premises "User VPN GW" hosts public IPv4 address.
demo: ssh 203.0.113.20 -l root linux userlanhost1 6.1.0-26-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.112-1 (2024-09-30) x86_64The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Wed Oct 16 09:29:05 2024 from 123.123.123.123 root@userlanhost1:~#
Install pre-requisite software
Update the package lists and install the required packages:
apt-get update
apt-get install wireguard wireguard-tools -yEnable IP forwarding
The VPN gateway acts as a router and, therefore, is required to forward packets:
sysctl -w net.ipv4.ip_forward=1This tutorial does not use an IPv6 address. If you intend to use one, ensure net.ipv6.config.all.forwarding=1 exists.
Configure the user-managed WireGuard server
This tutorial will walk you through specific options for configuring WireGuard, but the rest of the configuration remains an exercise for the reader. This section contains the configuration files and content specific to this installation and peer setup.
Configure routing on LAN hosts
Currently, it is impossible to automate the addition of routes to LAN hosts to route the required subnets over the VPN Gateway. In this section, we will manually add the required routes. Remember to add them to the LAN hosts in both the VDCs.
Configure routing on IONOS Cloud LAN Hosts
Configure on-premises route
Final result
You should now be able to ping hosts in the simulated on-premises setup in user-on-prem-lhr from cloud hosts in ionos-cloud-txl and vice-versa.

Conclusion
You have successfully configured a site-to-site VPN connection between IONOS Cloud and your on-premises setup by utilising a Managed VPN Gateway in the cloud and a user-managed on-premises gateway.
Last updated
Was this helpful?