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.
sudo apt update sudo apt upgrade -y
sudo apt install wireguard -y
wg genkey | tee privatekey | wg pubkey > publickey cat privatekey cat publickey
sudo nano /etc/wireguard/wg0.confExample:
[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
sudo nano /etc/sysctl.confUncomment:
net.ipv4.ip_forward=1Apply:
sudo sysctl -p
sudo systemctl enable wg-quick@wg0 sudo systemctl start wg-quick@wg0Verify:
sudo wg show
Source: 0.0.0.0/0 Protocol: UDP Port: 51820
[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
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.