Skip to main content

Wiregaurd proxmox setup (ip-transit)

<ins class="diffmod">WireGuard Proxmox Public IP Routing Setup</ins>

WireGuard Proxmox Public IP Routing Setup

📦 Step 1: Install WireGuard


apt update
apt install wireguard wireguard-tools -y

📁 Step 2: Create WireGuard config

Config

Create

the tunnel config:

nano /etc/wireguard/wg0.conf

PasteAdd your WireGuard config.

Insideinside the [Interface] section add:section:


PostUp = /etc/wireguard/up.sh
PostDown = /etc/wireguard/down.sh

Example:


[Interface]
PrivateKey = YOUR_PRIVATE_KEY
Address = YOUR_WG_IP
PostUp = /etc/wireguard/up.sh
PostDown = /etc/wireguard/down.sh

[Peer] PublicKey = SERVER_KEY Endpoint = SERVER_IP:PORT AllowedIPs = 0.0.0.0/0 PersistentKeepalive = 25

Save

the
file.

📜 Step 3: Create persistentPersistent routingRouting script

Script

Create:

nano /etc/wireguard/up.sh

Paste:


#!/bin/bash

for ip in {113..117}; do ip rule add from 5.231.32.$ip/32 table 11 prio 1 ip route add 5.231.32.$ip/32 dev vmbr0 table 11 ip route add 5.231.32.$ip/32 dev vmbr0 done

sleep 1

echo 1 > /proc/sys/net/ipv4/conf/all/proxy_arp echo 1 > /proc/sys/net/ipv6/conf/default/proxy_ndp

sysctl -w net.ipv4.ip_forward=1 sysctl -w net.ipv6.conf.all.forwarding=1

Save.

📴 Step 4: Create cleanupCleanup script

Script

Create:

nano /etc/wireguard/down.sh

Paste:


#!/bin/bash

for ip in {113..117}; do ip route del 5.231.32.$ip/32 dev vmbr0 ip route del 5.231.32.$ip/32 dev vmbr0 table 11 ip rule del from 5.231.32.$ip/32 table 11 prio 1 done

sleep 2

echo 0 > /proc/sys/net/ipv4/conf/all/proxy_arp echo 0 > /proc/sys/net/ipv6/conf/default.default/proxy_ndp

Save.

🔐 Step 5: Make scriptsScripts executable

Executable


chmod +x /etc/wireguard/up.sh
chmod +x /etc/wireguard/down.sh

🌐 Step 6: Make forwardingForwarding persistentPersistent

after
reboot

Create:

nano /etc/sysctl.d/99-wireguard.conf

Add:


net.ipv4.ip_forward=1
net.ipv4.conf.all.proxy_arp=1
net.ipv6.conf.all.forwarding=1
net.ipv6.conf.default.proxy_ndp=1

Apply:


sysctl --system

🚀 Step 7: Enable WireGuard atOn boot

Boot


systemctl enable --now wg-quick@wg0

Check:


systemctl status wg-quick@wg0

Check routing:routes:


ip rule

ip route show table 11

✅ Done

Your public IPs will now keepsurvive: routing after:

  • Proxmox reboot
  • WireGuard restart
  • Server restart

VM settings:

Settings


IP:
5.231.32.xxx/24

Gateway: 5.231.32.1

LXC settings:

Settings


IP:
5.231.32.xxx/32

Gateway: 5.231.32.1