Create a Private Network Between VMs with NAT on Proxmox VE
Create a private bridge on Proxmox VE, connect VMs to each other, give them outbound Internet access through NAT and publish a service, without cutting off access to the server.
On this page
Your values
Enter them once and the commands in this guide update.
This guide creates a private network on a Proxmox VE server: your virtual machines communicate with each other and reach the Internet through NAT, behind the server's public address. It also explains how to publish a specific service and how to create a fully isolated network.
| Item | Value used in this guide |
|---|---|
| Host public interface | vmbr0 (ISO installation) |
| Private bridge with NAT | vmbr1 |
| Private network | 10.10.10.0/24 |
| VM gateway (the host) | 10.10.10.1 |
| First VM | 10.10.10.10 |
| Isolated bridge, no Internet | vmbr2 |
Outbound traffic from the VMs is rewritten by the host and leaves with its IP address. The VMs cannot be reached from the Internet until you create a port forward.
What This Guide Does Not Cover
This guide does not assign an additional public IP address to a VM. That configuration depends on the hosting provider's network (virtual MAC addresses, routing, gateway to use). If you need this, contact support from your client area before changing anything.
The Configure a Failover IP guide describes adding an address directly on a Linux system. It does not cover connecting a Proxmox VM.
Prerequisites
- Proxmox VE installed, for example with the Install and Configure Proxmox VE guide
rootaccess over SSH- The KVM IP accessible from your client area
- A private range that is not already in use on the server
Step 1: Review the Current Configuration
ip -br addr
ip route show default
cat /etc/network/interfacesIdentify the interface that carries the public address and the default route:
- On an ISO installation, this is normally
vmbr0. - On an installation on top of Debian, it may be the physical network card, for example
eno1.
In the rest of this guide, replace vmbr0 with the name actually displayed if needed. A mistake here prevents NAT from working.
Step 2: Prepare for a Mistake
Keep a copy of the file, then schedule its automatic restoration in 10 minutes:
cp /etc/network/interfaces /root/interfaces.avant-nat
systemd-run --on-active=10min --unit=net-rollback /bin/sh -c 'cp /root/interfaces.avant-nat /etc/network/interfaces && ifreload -a'If you lose access, the original file will be restored when the time is up. You will cancel this restoration in step 4 if everything works.
Step 3: Create the Private Bridge with NAT
Open the file:
nano /etc/network/interfacesAdd this block at the end, without touching the rest:
auto vmbr1
iface vmbr1 inet static
address 10.10.10.1/24
bridge-ports none
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.10.10.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o vmbr0 -j MASQUERADE
post-up iptables -t raw -I PREROUTING -i fwbr+ -j CT --zone 1
post-down iptables -t raw -D PREROUTING -i fwbr+ -j CT --zone 1| Line | Purpose |
|---|---|
address 10.10.10.1/24 |
The host's address on the private network, which serves as the gateway for the VMs |
bridge-ports none |
The bridge is not attached to any physical card |
ip_forward |
Allows the host to route packets |
MASQUERADE |
Replaces the VMs' private address with the public address on the way out |
CT --zone 1 |
Prevents the firewall from blocking outbound traffic from VMs whose interface has the Firewall option enabled |
Step 4: Apply and Verify
Check the syntax, then apply the configuration:
ifreload -a -s
ifreload -aCheck the result:
ip -br addr show vmbr1
cat /proc/sys/net/ipv4/ip_forward
iptables -t nat -S POSTROUTINGYou should see vmbr1 with 10.10.10.1/24, the value 1, and the MASQUERADE rule.
From your computer, open a new SSH session and reload the web interface. If both work, cancel the scheduled restoration:
systemctl stop net-rollback.timerStep 5: Connect a VM
In VM → Hardware → Network Device → Edit, choose the Bridge vmbr1. On the command line, first display the interface's current configuration:
qm config 100 | grep ^net0Then reuse the displayed value, changing only bridge=, so that you keep the MAC address and the other options:
qm set 100 --net0 virtio=BC:24:11:00:00:01,bridge=vmbr1,firewall=1Replace BC:24:11:00:00:01 with your address, and remove firewall=1 if this option was not present.
Step 6: Configure the Network Inside the VM
There is no DHCP server on this network: assign a static address to each VM. First find the interface name, often ens18:
ip -br linkDebian
auto ens18
iface ens18 inet static
address 10.10.10.10/24
gateway 10.10.10.1printf 'nameserver 1.1.1.1\nnameserver 9.9.9.9\n' > /etc/resolv.conf
systemctl restart networkingUbuntu
network:
version: 2
ethernets:
ens18:
addresses:
- 10.10.10.11/24
routes:
- to: default
via: 10.10.10.1
nameservers:
addresses: [1.1.1.1, 9.9.9.9]chmod 600 /etc/netplan/60-prive.yaml
netplan trynetplan try reverts the change if you do not confirm it. If another netplan configuration already manages this interface, adapt it instead of adding a second one.
Step 7: Verify from the VM
ip -br addr
ping -c 3 10.10.10.1
ping -c 3 10.10.10.11
ping -c 3 1.1.1.1
getent hosts deb.debian.org
curl -I https://deb.debian.org| Test | What it confirms |
|---|---|
Ping 10.10.10.1 |
The VM is on the private bridge |
| Ping another VM | The VMs can communicate with each other |
Ping 1.1.1.1 |
Routing and NAT work |
getent hosts |
DNS resolution works |
curl -I |
Outbound HTTPS access works |
Publish a Service from a VM
To make a service accessible from the Internet, forward a port on the public address to the VM. Add these lines to the vmbr1 block, here to send port 8443 to port 443 on the VM:
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 8443 -j DNAT --to-destination 10.10.10.10:443
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 8443 -j DNAT --to-destination 10.10.10.10:443For an administration service, restrict the source with -s YOUR_IP:
post-up iptables -t nat -A PREROUTING -i vmbr0 -s YOUR_IP -p tcp --dport 2222 -j DNAT --to-destination 10.10.10.10:22
post-down iptables -t nat -D PREROUTING -i vmbr0 -s YOUR_IP -p tcp --dport 2222 -j DNAT --to-destination 10.10.10.10:22Then repeat the safeguards from step 2, apply with ifreload -a and check:
iptables -t nat -S PREROUTINGTest from a machine outside the server: a PREROUTING forward does not apply to connections initiated from the host itself.
Create a Fully Isolated Network
A second bridge, with no address on the host and no NAT, connects VMs without giving them Internet access. This is useful for a database or a storage network between VMs.
auto vmbr2
iface vmbr2 inet manual
bridge-ports none
bridge-stp off
bridge-fd 0Apply with ifreload -a, then add a second interface to the VM:
qm set 100 --net1 virtio,bridge=vmbr2In each VM, assign an address such as 10.20.20.10/24, with no gateway.
Alternative: SDN Zones
Proxmox VE also offers SDN zones in Datacenter → SDN. A Simple zone creates an isolated bridge per node, can enable SNAT on a subnet and, with dnsmasq, hand out addresses through DHCP. See the SDN documentation if you want to manage these networks from the web interface.
Updates and Backup
Proxmox VE updates require no action on this configuration. After a restart, check that NAT is back:
iptables -t nat -S POSTROUTING
cat /proc/sys/net/ipv4/ip_forward/etc/network/interfaces is not included in VM backups. Copy it off the server along with the rest of the host configuration. For VM data, see the Proxmox Backup Server guides.
Troubleshooting
No More SSH or Web Interface Access After a Change
Wait for the automatic restoration if one is scheduled. Otherwise, open the KVM IP, log in as root and restore the file:
cp /root/interfaces.avant-nat /etc/network/interfaces
ifreload -a
ip -br addr
ip route show defaultIf access does not come back, contact support from your client area and describe the changes you made.
ifreload Reports an Error
Run the check again with ifreload -a -s, then inspect the line it points to. Common errors are a bridge declared twice, an address without a prefix or a post-up line placed outside the vmbr1 block.
The VM Cannot Reach 10.10.10.1
qm config 100 | grep ^net
ip -br addr show vmbr1
bridge link showCheck that the VM's interface uses vmbr1, that the address is within 10.10.10.0/24 and that the VM's firewall is not the cause.
The VM Reaches the Gateway but Not the Internet
cat /proc/sys/net/ipv4/ip_forward
iptables -t nat -L POSTROUTING -n -v
ip route show default- The value must be
1. - The interface after
-omust be the one used by the default route. - The
MASQUERADErule counters must increase during aping. If they do not, check the VM's gateway.
Ping to 1.1.1.1 Works, but Domain Names Do Not
The VM's DNS is missing or incorrect. Check /etc/resolv.conf or resolvectl status.
Rules Appear Twice
ifreload -a may replay the post-up lines. List the rules with iptables -t nat -S, then delete the duplicates by repeating the rule with -D instead of -A. This matters after a change of destination: the old forward would remain active.
The Port Forward Does Not Work
- Is the service listening inside the VM? Check with
ss -tlnp. - Is the VM's gateway set to
10.10.10.1? - Does the VM's firewall allow the port?
- Are you testing from outside the server?
- Does the rule's counter increase in
iptables -t nat -L PREROUTING -n -v?
The Server Loses Network When a VM Starts
A VM is probably connected to vmbr0. From the KVM IP, stop it with qm stop ID, move its interface to vmbr1, then contact support if the network does not come back.