Proxmox NAT Setup

I setup a homelab in Proxmox and love it but I noticed it’s lacking documentation on the network setup portion. My setup is below with some explanations.

source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

auto ens3
iface ens3 inet static
        address 0.0.0.0

auto vmbr0
iface vmbr0 inet static
        address 10.50.1.1/24
        bridge-ports none
        bridge-stp off
        bridge-fd 0

auto vmbr1
iface vmbr1 inet static
        address 45.14.X.X/24
        gateway 45.14.X.X
        bridge-ports ens3
        bridge-stp off
        bridge-fd 0

post-up echo 1 > /proc/sys/net/ipv4/ip_forward                                   
post-up iptables -t nat -A POSTROUTING -s '10.50.1.0/24' -o vmbr1 -j MASQUERADE  
post-down iptables -t nat -D POSTROUTING -s '10.50.1.0/24' -o vmbr1 -j MASQUERADE

vmbr0 is a bridge that is the local network address for the proxmox server, clients will be in this /24 subnet.

vmbr1 is a network bridge that has the public IP address that is assigned to my server from my server provider (45.14.X.X).

The bottom of the configuration just masquerades (NAT) the local IP to use the public IP when going out to the internet using iptable rules.

You can then assign IPs to your local KVM and LXC servers by assigning them to the bridge vmbr0 to give them a local IP (NAT) or assign them to the bridge vmbr1 and give them an public IP address. This worked on most providers for me.

Let me know if you have any questions in this setup and I will try to help in the comments below.

Leave a Reply

Your email address will not be published.