Deploying a WireGuard VPN Gateway on InMotion Cloud
Updated August 12, 2026 by Sean Perryman
6 Minutes to Read
Introduction
A VPN gateway enables secure connectivity between your office network (or remote devices) and InMotion Cloud. This configuration allows your on-premises systems to communicate with cloud instances over an encrypted tunnel, as if both networks were directly connected.
This guide walks through deploying a WireGuard VPN gateway instance on InMotion Cloud, configuring the tunnel, and validating end-to-end connectivity.
Intended audience: System administrators and network engineers deploying hybrid cloud infrastructure.
Network Architecture
The VPN gateway creates a secure tunnel between two networks:
1┌─────────────────────┐ ┌─────────────────────┐2│ Office Network │ │ InMotion Cloud │3│ or Remote Device │ │ │4│ │ │ ┌───────────────┐ │5│ ┌───────────────┐ │ │ │Cloud Instances│ │6│ │ Clients │ │ │ │ 10.0.0.0/24 │ │7│ │ 10.100.0.x/32 │ │ │ └───────┬───────┘ │8│ └───────┬───────┘ │ │ │ │9│ │ │ │ ┌───────┴───────┐ │10│ │ │ Tunnel │ │ VPN Gateway │ │11│ └──────────┼──────────┼─►│ 10.100.0.1 │ │12│ │ UDP 51820│ │(Floating IP) │ │13│ │ │ └───────────────┘ │14└─────────────────────┘ └─────────────────────┘15 │ │16 └───────── Internet ────────┘
In this configuration:
- Cloud private network: 10.0.0.0/24 (where your cloud instances live)
- WireGuard tunnel network: 10.100.0.0/24 (virtual network for VPN clients)
- VPN gateway: 10.100.0.1 on the tunnel, with a floating IP for external access
Prerequisites
Before starting, ensure you have:
- Active InMotion Cloud account with project access
- SSH client for connecting to the VPN gateway
- WireGuard client installed on your local device (download here)
Step 1: Create the Private Network
Create a private network for the VPN gateway and cloud instances.
- Navigate to Project > Network > Networks

- Click Create Network
- On the Network tab:
- Network Name: private-net
- Click Next

- On the Subnet tab:
- Subnet Name: private-sub
- Network Address: 10.0.0.0/24
- Gateway IP: 10.0.0.1
- Click Next

- On the Subnet Details tab:
- Allocation Pools: 10.0.0.2,10.0.0.10
- DNS Name Servers:
- 1.1.1.1
- 1.0.0.1
- Click Create

Connect to External Network
After creating the network, create a router to provide internet access:
- Navigate to Project > Network > Routers
- Click Create Router
- Configure:
- Router Name: private-router
- External Network: Select your external network
- Click Create Router
- Click on the router name to open details
- Select the Interfaces tab
- Click Add Interface
- Select private-sub and click Submit
Step 2: Create the Security Group
Create a security group to allow VPN and SSH traffic before launching the instance.
- Navigate to Project > Network > Security Groups

- Click Create Security Group
- Configure:
- Name: vpn-sg
- Click Create Security Group

- On the Manage Security Group Rules page, click +Add Rule

- Add the WireGuard rule:
- Rule: Custom UDP Rule
- Description: WireGuard
- Port: 51820
- CIDR: 0.0.0.0/0 (or restrict to your office public IP)
- Click Add

- Repeat to add an SSH rule:
- Rule: SSH
- CIDR: Your management IP/32 (restrict SSH access to your IP)
Step 3: Deploy the VPN Gateway Instance
With the network and security group ready, deploy the VPN gateway instance.
- Navigate to Project > Compute > Instances

- Click Launch Instance
- On the Details tab:
- Instance Name: vpn
- Click Next

- On the Source tab:
- Click the up arrow next to Debian 13 to select it
- Click Next

- On the Flavor tab:
- Click the up arrow next to m7i.medium (or your preferred flavor)
- Click Next

- On the Networks tab:
- Click the up arrow next to private-net
- Click Next

- Skip the Network Ports page (click Next)
- On the Security Groups tab:
- Click the up arrow next to vpn-sg to allocate it
- Click Next

- On the Key Pair tab, click +Create Key Pair:
- Key Pair Name: vpn
- Key Type: SSH Key
- Click Create Keypair

- Important: Copy the private key data and save it to a file (e.g.,
~/.ssh/vpn.pemon Linux/Mac)

- Set the file permissions:
1 chmod 600 ~/.ssh/vpn.pem
- Click Done. Verify the key is in the Allocated section.

- Click Launch Instance

Step 4: Assign Floating IP
The VPN gateway requires a public IP for external clients to connect.
- Navigate to Project > Compute > Instances
- Click the dropdown arrow next to your VPN instance, then click Associate Floating IP

- The Manage Floating IP Associations dialog appears

- Click the + icon next to the IP address dropdown
- In the Allocate Floating IP dialog:
- Description: vpn
- Click Allocate IP

- Back in the associations dialog, click Associate

Record the floating IP address - this is the VPN endpoint your clients will connect to.
Step 5: Install and Configure WireGuard
Connect to the VPN gateway and install WireGuard.
Connect to the Instance
1ssh -i ~/.ssh/vpn.pem debian@YOUR_FLOATING_IP
Update the System
1sudo apt update && sudo apt upgrade -y && sudo reboot
Wait a minute, then reconnect:
1ssh -i ~/.ssh/vpn.pem debian@YOUR_FLOATING_IP
Install WireGuard
1sudo apt install -y wireguard
Enable IP Forwarding
1sudo nano /etc/sysctl.d/99-wireguard.conf
Add this line:
1net.ipv4.ip_forward=1
Save the file (Ctrl+X, then Y, then Enter), then apply:
1sudo sysctl --system
Generate Server Keys
1# Create WireGuard directory with secure permissions2sudo install -m 700 -d /etc/wireguard34# Generate the server private key5sudo sh -c 'umask 077; wg genkey > /etc/wireguard/server.key'67# Generate the server public key8sudo sh -c 'wg pubkey < /etc/wireguard/server.key > /etc/wireguard/server.pub'910# View the public key (you'll need this for client configuration)11sudo cat /etc/wireguard/server.pub
Save the public key output - clients will need it.
Configure WireGuard Server
1sudo nano /etc/wireguard/wg0.conf
Paste this configuration:
1[Interface]2Address = 10.100.0.1/243ListenPort = 518204PrivateKey = SERVER_PRIVATE_KEY_HERE56PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o ens3 -j MASQUERADE7PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o ens3 -j MASQUERADE
Replace SERVER_PRIVATE_KEY_HERE with your actual private key:
1sudo cat /etc/wireguard/server.key
Note: Verify your network interface name with ip address. If it's not ens3, update the PostUp and PostDown lines accordingly.
Set secure permissions:
1sudo chmod 600 /etc/wireguard/wg0.conf
Start WireGuard
1sudo systemctl enable --now wg-quick@wg0
Verify the service is running:
1sudo systemctl status wg-quick@wg02sudo wg3ip addr show wg0
Step 6: Configure WireGuard Client
Install the WireGuard client on your device.
Generate Client Keys
On the client device (or on the server if you prefer to manage keys centrally):
1# Generate client keys2wg genkey | tee client.key | wg pubkey > client.pub
Add Client to Server
On the VPN gateway server, edit the WireGuard configuration:
1sudo nano /etc/wireguard/wg0.conf
Add a [Peer] section for the client:
1[Peer]2PublicKey = CLIENT_PUBLIC_KEY_HERE3AllowedIPs = 10.100.0.2/32
Replace CLIENT_PUBLIC_KEY_HERE with the contents of client.pub.
Restart WireGuard to apply:
1sudo systemctl restart wg-quick@wg0
Configure the Client
Create a configuration file on your client device (e.g., vpn.conf):
1[Interface]2PrivateKey = CLIENT_PRIVATE_KEY_HERE3Address = 10.100.0.2/3245[Peer]6PublicKey = SERVER_PUBLIC_KEY_HERE7Endpoint = YOUR_FLOATING_IP:518208AllowedIPs = 10.0.0.0/24, 10.100.0.0/249PersistentKeepalive = 25
Replace:
CLIENT_PRIVATE_KEY_HEREwith the contents ofclient.keySERVER_PUBLIC_KEY_HEREwith the server's public key (fromsudo cat /etc/wireguard/server.pub)YOUR_FLOATING_IPwith the VPN gateway's floating IP
Import this configuration into your WireGuard client application and activate the connection.
Step 7: Test the VPN Connection
From the Client
Test connectivity to the VPN gateway:
1ping 10.100.0.1
Test connectivity to a cloud instance on the private network:
1ping 10.0.0.X
Replace X with the last octet of a server on the private cloud network.
Test a real service:
1ssh username@10.0.0.X
From the VPN Gateway
Check WireGuard status:
1sudo wg
A recent "latest handshake" timestamp confirms the tunnel is working.
Troubleshooting
Tunnel Won't Establish
Symptoms: WireGuard running but no handshake.
Check:
- Security group allows UDP 51820
- Client endpoint IP and port are correct
- Public keys are correct on both sides
1# Check WireGuard status2sudo wg34# Check security group5openstack security group rule list vpn-sg
Can Ping VPN Gateway But Not Cloud Instances
Symptoms: ping 10.100.0.1 works but ping 10.0.0.X fails.
Check:
- IP forwarding is enabled on the VPN gateway
- iptables NAT rules are active
- Security groups on destination instances allow traffic from 10.100.0.0/24
1# Verify IP forwarding2cat /proc/sys/net/ipv4/ip_forward3# Should return: 145# Verify iptables rules6sudo iptables -t nat -L -v
Security Group Considerations
Instances you want to access through the VPN need security group rules allowing traffic from the VPN network. If an instance only allows connections from 10.0.0.0/24, VPN clients (coming from 10.100.0.0/24) will be blocked.
Solution: Add 10.100.0.0/24 to the security group rules for instances that need VPN access.
Summary
Deploying a WireGuard VPN gateway on InMotion Cloud enables secure access to your cloud resources from anywhere. The key steps are:
- Create a private network with external connectivity
- Create a security group allowing WireGuard (UDP 51820) and SSH traffic
- Deploy a Debian instance as the VPN gateway
- Assign a floating IP for external access
- Install and configure WireGuard with IP forwarding and NAT
- Configure WireGuard clients with the server's public key and endpoint
- Update security groups on other instances to allow VPN traffic
Once configured, you can securely access any instance on your private cloud network through the encrypted WireGuard tunnel.
Related Resources
Sean Perryman
Technical Account Engineer
Sean Perryman is a Product Engineer at InMotion Cloud, where he helps organizations design, deploy, migrate, and support mission-critical workloads in the cloud. Working closely with customers throughout the entire lifecycle of their environments, he specializes in solving complex infrastructure challenges while ensuring platforms remain secure, reliable, and scalable.