Build a Linux VM inside your VDC that acts as a VPN gateway while the managed VPN Gateway service is unavailable.
See status page for updates.
1. Choose scenario
2. Your details
3. Provision
4. Configure tunnel
TL;DR - just give me the scripts, I can handle it myself
The complete provisioning script with placeholder variables in the header - fill in
DC_ID, LOCATION, LAN IDs and run. It reserves an IP, creates the boot
volume (separate step - server create --image-alias silently creates no disk),
creates and boots the VM, attaches both NICs, opens the firewall (WireGuard variant;
for IPsec open UDP 500 + 4500 instead of 51820) and reboots.
Requires ionosctl, jq, and export IONOS_TOKEN=....
No VDC route tables. Every VM that needs to reach the remote network must have a static route pointing to the gateway VM's private IP. Without this, traffic goes to the IONOS default gateway and gets dropped.
The firewall sits on the NIC, not on the VM. The DCD / Cloud API firewall is per-NIC and defaults to deny-all when active. You must open the tunnel port explicitly. The provisioning script below handles this.
Prerequisites
An IONOS Cloud account with an existing VDC (data center)
An SSH key pair for VM access (ssh-keygen -t ed25519 if you don't have one).
Snap users: ionosctl installed via snap cannot read ~/.ssh/.
Copy your public key to ~/snap/ionosctl/common/key.pub first.
An API token with the right privileges (see below)
Setting up a user, group, and token (recommended)
The provisioning script needs a token with specific privileges. Best practice: create a dedicated
non-admin user and group rather than using your contract admin account. This limits the blast
radius if the token is compromised.
Required group privileges: --reserve-ip - reserve public IP blocks --create-nic - create internet access (public LANs/NICs)
Required resource shares:
The VDC(s) you want to provision into must be shared with the group as editable resources.
Via DCD (web UI):
Go to Management > Users & Groups
Create a Group (e.g. "vpn-provisioning"), enable the privileges: Reserve IP, Create Internet Access, and optionally Create Snapshot
Under the group's Resources tab, add your VDC(s) with Edit rights
Create a User (non-admin), add them to the group
Log in as that user, go to Token Manager, generate a token
Via ionosctl (CLI):
user-group-setup.sh
# Run these as your contract admin user.
# 1. Create a group with the needed privileges
GRP=$(ionosctl compute group create \
--name "vpn-provisioning" \
--reserve-ip \
--create-nic \
-o json -w | jq -r '.id')
echo "Group: $GRP"
# 2. Share your VDC(s) with the group (edit rights)
ionosctl compute share create \
--group-id "$GRP" \
--resource-id "<YOUR-VDC-UUID>" \
--edit-privilege -w
# 3. Create a non-admin user
USR=$(ionosctl compute user create \
--first-name "VPN" --last-name "Provisioning" \
--email "vpn-setup@example.com" \
--password "$(openssl rand -base64 16)" \
-o json -w | jq -r '.id')
echo "User: $USR"
# 4. Add the user to the group
ionosctl compute group user add \
--group-id "$GRP" --user-id "$USR"
# 5. Log in as the new user and generate a token
ionosctl login --user "vpn-setup@example.com" --password "..."
ionosctl authentication token generate -o json | jq -r '.token'
# Use this token as IONOS_TOKEN in the provisioning script.
Admin tokens vs. scoped tokens. An admin user's token has full contract access.
A non-admin user's token is limited to what their groups allow. For the provisioning script,
a scoped token from a non-admin user is sufficient and safer.
1 Choose your scenario
🏢↔☁
A - Site-to-site
Connect your on-premises network to your VDC. One gateway VM in the VDC, the other end is your office router or firewall.
☁↔☁
B - VDC-to-VDC
Connect two IONOS VDCs across locations. One gateway VM in each VDC, WireGuard point-to-point between them.
💻→☁
C - Client-to-site
Remote users (admins, home office) connect to the VDC. Each user gets a WireGuard config file for their device.
2 Choose tunnel protocol
Recommended. WireGuard is simpler to configure, faster, and easier to debug. Use it unless the on-prem side is an appliance that only speaks IPsec (Fortinet, Sophos, pfSense).
Appliance compatibility. Use IKEv2 with NAT-T (UDP 4500). The provisioning script opens the right firewall ports. Both legacy /etc/ipsec.conf and modern /etc/swanctl/ configs are provided below.
3 Enter your details
Fill in your VDC details. The provisioning script and VPN configs below update live as you type.
VDC & Gateway
ionosctl compute datacenter list to find yours
Must match your VDC's location
On-prem details
Second VDC (remote side)
4 Provision the gateway VM
Copy this script, save as vpn-gw-setup.sh, and run it. It creates a 2-vCPU / 2 GB Ubuntu VM with a public IP and the right firewall rules.
vpn-gw-setup.sh
scroll to see full script
What you see above is what you download - review it before running.
Alternative: DCD click path (manual)
Reserve IP: Menu > Networking > IP Management > Reserve IP Block (1 IP, same location as VDC)
Add server: Drag a server onto the VDC canvas. Set 2 vCPU, 2 GB RAM, Ubuntu 24.04 image, paste SSH key.
Public NIC: Drag the server's NIC connector to your public LAN. Assign the reserved IP, enable the firewall.
Private NIC: Add a second NIC, connect to your private LAN.
Firewall rules: Click the public NIC > Firewall Rules. Add inbound UDP 51820 (WireGuard) or UDP 500 + 4500 (IPsec), plus TCP 22 (SSH).
After SSH: install packages
Run on the gateway VM
5 Configure the tunnel
Gateway VM: /etc/wireguard/wg0.conf
wg0.conf (gateway)
On-prem side: /etc/wireguard/wg0.conf
wg0.conf (on-prem)
Ubuntu 26.04 note:ubuntu:latest ships strongSwan 6.0 with swanctl only.
The legacy ipsec command is not installed by default.
To use /etc/ipsec.conf, install the extra package: apt install strongswan-starter.
The modern swanctl.conf format works out of the box and is shown below the legacy format.
Gateway VM: /etc/ipsec.conf (legacy format - needs apt install strongswan-starter)
ipsec.conf
Gateway VM: /etc/ipsec.secrets
ipsec.secrets
Modern format: /etc/swanctl/swanctl.conf
swanctl.conf
Use non-overlapping subnets. IONOS DHCP can assign the same private subnet
(e.g. 10.7.224.0/24) to LANs in different VDCs. If both sides share a subnet and you put it
in AllowedIPs, WireGuard's route overrides the local LAN route and traffic breaks. Make sure
your two VDCs use different private subnets, or use the tunnel IPs (10.99.0.x) with MASQUERADE
instead of routing the LAN subnets directly.
VDC-A gateway: /etc/wireguard/wg0.conf
wg0.conf (VDC-A)
VDC-B gateway: /etc/wireguard/wg0.conf
wg0.conf (VDC-B)
Gateway VM: /etc/wireguard/wg0.conf
wg0.conf (server)
Client config (give to each user)
user.conf
Do not forget static routes. On each VDC VM that needs the tunnel:
ip route add 192.168.1.0/24 via 10.0.1.1
Checklist
MTU: If you see stalled connections or large transfers hang, add MTU = 1420 to the WireGuard [Interface] section on both ends. WireGuard adds 80 bytes of overhead to the VDC's 1500-byte Ethernet MTU.
[Interface]
MTU = 1420
PersistentKeepalive: Add to any [Peer] section where the peer is behind NAT (home office, mobile). Without it, NAT mappings expire and the tunnel goes silent after a few minutes of inactivity.
[Peer]
PersistentKeepalive = 25
Test the tunnel: From a VDC VM (not the gateway), ping a host on the remote side. If ping fails, check on the gateway VM:
# From a VDC VM behind the gateway:
ping -c 4 192.168.1.1
# On the gateway VM - is traffic arriving?
tcpdump -i wg0 -n -c 20
# For IPsec:
tcpdump -i ens6 -n udp port 4500 -c 20
# Check WireGuard handshake (should show recent timestamp):
wg show
# Check IPsec tunnel status:
swanctl --list-sas
Static routes on every VM: Each VM that needs the tunnel must have a route pointing to the gateway's private IP. Verify and persist:
# Verify the route exists:
ip route get 192.168.1.1
# Should show: "via 10.0.1.1 dev ens7" (your gateway's private IP)
# If missing, add it:
ip route add 192.168.1.0/24 via 10.0.1.1
# Persist across reboots (Ubuntu/Debian netplan):
# Edit /etc/netplan/01-netcfg.yaml, add under the private NIC:
# routes:
# - to: 192.168.1.0/24
# via: 10.0.1.1
# Then: netplan apply
OS firewall (ufw): The NIC firewall handles inbound filtering, but if ufw is active on the gateway VM, it blocks forwarding by default:
Fresh keys only: Generate new keys for this setup. Do not reuse any credentials from the managed VPN Gateway service.
# WireGuard key pair:
wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey
# IPsec PSK (share securely with the other end):
openssl rand -base64 32
Cleanup when managed service returns: This is an interim setup. When the managed VPN Gateway service is restored:
# 1. Reconfigure your applications/routes to use the managed gateway
# 2. Remove static routes from VDC VMs:
ip route del 192.168.1.0/24 via 10.0.1.1
# 3. Delete the gateway VM and its resources:
ionosctl compute server delete --datacenter-id "$DC_ID" --server-id "$SRV_ID" -f -w
ionosctl compute volume delete --datacenter-id "$DC_ID" --volume-id "$VOL_ID" -f -w
ionosctl compute ipblock delete --ipblock-id "$IP_BLOCK_ID" -f -w