← Back to Blog

WireGuard VPN on Oracle Cloud – Complete Deployment Guide 2026

WireGuard is a modern, lightweight, and high-performance VPN solution. This guide explains how to deploy WireGuard VPN on an Oracle Cloud Ubuntu server for secure remote access.

Prerequisites

Step 1: Update Ubuntu Server

sudo apt update
sudo apt upgrade -y

Step 2: Install WireGuard

sudo apt install wireguard -y

Step 3: Generate Server Keys

wg genkey | tee privatekey | wg pubkey > publickey

cat privatekey
cat publickey

Step 4: Configure WireGuard

Create configuration file:
sudo nano /etc/wireguard/wg0.conf
Example:
[Interface]
Address = 10.10.10.1/24
ListenPort = 51820
PrivateKey = SERVER_PRIVATE_KEY

PostUp = iptables -A FORWARD -i wg0 -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o ens3 -j MASQUERADE

PostDown = iptables -D FORWARD -i wg0 -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o ens3 -j MASQUERADE

Step 5: Enable IP Forwarding

Edit:
sudo nano /etc/sysctl.conf
Uncomment:
net.ipv4.ip_forward=1
Apply:
sudo sysctl -p

Step 6: Start WireGuard

sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0
Verify:
sudo wg show

Step 7: Oracle Cloud Firewall Rules

Allow: OCI Security List:
Source: 0.0.0.0/0
Protocol: UDP
Port: 51820

Step 8: Create Client Configuration

Example:
[Interface]
PrivateKey = CLIENT_PRIVATE_KEY
Address = 10.10.10.2/24
DNS = 1.1.1.1

[Peer]
PublicKey = SERVER_PUBLIC_KEY
Endpoint = YOUR_PUBLIC_IP:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25

Security Recommendations

Benefits of WireGuard

Conclusion

WireGuard provides a secure and efficient VPN solution for Oracle Cloud deployments. It is an excellent choice for administrators seeking secure remote access, site-to-site connectivity, and lightweight VPN performance.