-
-
Notifications
You must be signed in to change notification settings - Fork 1
Linux VPN Servers
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to VPN servers on Linux, covering Arch Linux, CachyOS, and other distributions including OpenVPN, WireGuard, and VPN server configuration.
Install OpenVPN:
# Arch/CachyOS
sudo pacman -S openvpn easyrsa
# Debian/Ubuntu
sudo apt install openvpn easy-rsa
# Fedora
sudo dnf install openvpn easy-rsaEdit config:
# Edit config
sudo vim /etc/openvpn/server/server.confBasic settings:
port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh.pem
server 10.8.0.0 255.255.255.0
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
Start OpenVPN:
# Enable service
sudo systemctl enable openvpn-server@server
# Start service
sudo systemctl start openvpn-server@server
# Check status
systemctl status openvpn-server@serverInstall WireGuard:
# Arch/CachyOS
sudo pacman -S wireguard-tools
# Debian/Ubuntu
sudo apt install wireguard
# Fedora
sudo dnf install wireguard-toolsCreate config:
# Create config
sudo vim /etc/wireguard/wg0.confExample server config:
[Interface]
PrivateKey = SERVER_PRIVATE_KEY
Address = 10.0.0.1/24
ListenPort = 51820
# Enable IP forwarding
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
[Peer]
PublicKey = CLIENT_PUBLIC_KEY
AllowedIPs = 10.0.0.2/32
WireGuard keys:
# Generate private key
wg genkey | tee privatekey | wg pubkey > publickey
# Or generate server key
wg genkey | sudo tee /etc/wireguard/server_private.key | wg pubkey | sudo tee /etc/wireguard/server_public.keyStart WireGuard:
# Enable service
sudo systemctl enable wg-quick@wg0
# Start service
sudo systemctl start wg-quick@wg0
# Check status
systemctl status wg-quick@wg0Enable IP forwarding:
# Enable temporarily
sudo sysctl -w net.ipv4.ip_forward=1
# Make permanent
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.d/99-ipforward.conf
# Apply
sudo sysctl -p /etc/sysctl.d/99-ipforward.confConfigure firewall:
# For WireGuard (if using iptables)
sudo iptables -A FORWARD -i wg0 -j ACCEPT
sudo iptables -A FORWARD -o wg0 -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADECheck status:
# Check WireGuard
sudo wg show
# Check OpenVPN
sudo systemctl status openvpn-server@server
# Check logs
journalctl -u wg-quick@wg0
journalctl -u openvpn-server@serverDiagnose:
# Check interface
ip link show wg0
# Check routing
ip route show
# Test connectivity
ping -c 4 10.0.0.1This guide covered VPN servers for Arch Linux, CachyOS, and other distributions, including OpenVPN, WireGuard, and configuration.
- Networking - Network setup
- Security Configuration - Security
- ArchWiki WireGuard: https://wiki.archlinux.org/title/WireGuard
- ArchWiki OpenVPN: https://wiki.archlinux.org/title/OpenVPN
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.