I have following setup currently:
Some guest VMs have only private ip (as 10.10.10.5 in example), so they have on virtual nic (vmbr1). One VM guest has both public ip and private ip, so it has 2 virtual nics (one from vmb0 and another for vmbr1). Port forwarding is working ok, until I restart networking service on Proxmox node. As soon as I restart networking I lose port-forwarding until restarting PVE node. Any way to fix this behavior?
P.S. I'm usually restarting networking when adding another port-forwarding rule to existing VM or new VM, but even without changing anything on file, and simply restarting networking breaks port forwarding.
Code:
# /etc/network/interfaces
auto lo
iface lo inet loopback
iface eno1 inet manual
auto vmbr0
iface vmbr0 inet static
address <MAIN Public IP>
netmask 255.255.255.224
gateway <MAIN Gateway>
bridge_ports eno1
bridge_stp off
bridge_fd 0
up ip route add <ANOTHER PUBLIC IP>/32 dev vmbr0
# NAT bridge
auto vmbr1
iface vmbr1 inet static
address 10.10.10.1
netmask 255.255.255.0
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 nat -A PREROUTING -i vmbr0 -p tcp --dport 6022 -j DNAT --to 10.10.10.5:22
post-down iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 6022 -j DNAT --to 10.10.10.5:22
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 6122 -j DNAT --to 10.10.10.6:22
post-down iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 6122 -j DNAT --to 10.10.10.6:22
Some guest VMs have only private ip (as 10.10.10.5 in example), so they have on virtual nic (vmbr1). One VM guest has both public ip and private ip, so it has 2 virtual nics (one from vmb0 and another for vmbr1). Port forwarding is working ok, until I restart networking service on Proxmox node. As soon as I restart networking I lose port-forwarding until restarting PVE node. Any way to fix this behavior?
P.S. I'm usually restarting networking when adding another port-forwarding rule to existing VM or new VM, but even without changing anything on file, and simply restarting networking breaks port forwarding.