Create a WireGuard Peer between a VDC and an on-premises Gateway
Last updated
Was this helpful?
Last updated
Was this helpful?
A VPN Gateway enables secure, encrypted communications between roaming users, on-premises networks, and cloud resources. 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
- de/txl
as IONOS Cloud's VDC.
- gb/ldn
simulates a user-managed on-premises setup.
Managed gateways
We use a single managed gateway in de/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.
The following information is necessary to set up a connection between a WireGuard VDC and an on-premises VDC:
Components
IONOS Cloud (Left) (de/txl)
User On-Premises (Right) (gb/ldn)
Gateway Public Address
203.0.113.10
203.0.113.10
LAN ID
1
2 (Not applicable in this use case)
LAN Subnet
192.10.1.0/24
192.10.2.0/24
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 LAN Address
192.10.1.5
192.10.2.2
Gateway Private Key
abcdefABC12345=
kHKHABcC+67891=
Pre-Shared Key
defDEFhiH/98765=
lmnoLMNO/89762=
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) (de/txl)
Gateway Public Address
User On-Premises (Right) (gb/ldn)
Gateway Public Address
203.0.113.10
203.0.113.20
This tutorial uses 192.10.1.0/24 and 192.10.2.0/24 for private LANs in IONOS Cloud (Left) and User On-Premises (Right), respectively. Remember to assign an IP address from the subnet to each gateway. We will use 192.10.1.5 as the VPN Gateway is not DHCP-aware. Remember to assign an IP address from the subnet to each gateway. The chosen IP address must be outside the DHCP pool and range from .2 to .9.
Note: gb/ldn
is a simulating user-managed gateway that uses its LAN host address of 192.10.2.3 instead. Hence, the above statement does not apply to this data center.
Components
IONOS Cloud (Left) (de/txl)
User On-Premises (Right) (gb/ldn)
LAN ID
1
2 (But not applicable here)
LAN Subnet
192.10.1.0/24
192.10.2.0/24
Gateway LAN Address
192.10.1.5
192.10.2.2
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) (de/txl)
User On-Premises (Right) (gb/ldn)
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
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) (de/txl)
User On-Premises (Right) (gb/ldn)
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.
The execution process is divided into the following steps:
Set up IONOS Cloud
Simulate on-premises setup
Provision the VPN Gateway
Configure the VPN peer
Deploy on-premises WireGuard instance
Configure routing on LAN hosts
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.10.1.0/24. We designate these two servers as 192.10.1.10 and 192.10.1.11, respectively.
Imagine the gb/ldn
VDC as a user-managed site where you provision two virtual servers. Here, we will use the subnet 192.10.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 servers as 192.10.2.2 and 192.10.2.3, respectively.
In the DCD, go to Menu > Network > VPN Gateway under Connectivity.
Click Create VPN Gateway from the VPN Gateways window.
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.
wg-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
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.
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.
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
Remote Host
The gateway public IPv4 address of the remote VPN Gateway.
194.10.2.2
Click Save to save the peer configuration. This operation should typically be completed within a minute or two.
In this tutorial, host 1 in gb/ldn
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 host 1's public IPv4 address in London.
Install pre-requisite software
Note: This tutorial performs a basic install and setup of WireGuard. It is neither an in-depth guide nor does it contain detailed information about the configuration files' content. It is an exercise for the reader to determine the correct installation procedure for a secure production environment.
Update the package lists and install the required packages:
Enable IP forwarding
The VPN gateway acts as a router and, therefore, is required to forward packets:
This 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.
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 de/txl
Route
Configure on-premises route
You should now be able to ping hosts in the simulated on-premises setup in gb/ldn
from cloud hosts in de/txl
and vice-versa.
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.