Proxmox: 1 NIC, 1 Public IP, unable to get WAN interface working in VMs

linux-networkingnetworkingpfsenseproxmoxvirtual-machines

I have a computer running Proxmox, and it has 1 single NIC that is directly connected to internet and has a single public IP. Then, I have different VMs (KVM) running and one of them is pfSense.

What I want to do is to have the host (Proxmox) and pfSense in the DMZ zone while the rest of VMs would be inside an internal LAN where all the traffic has to pass through pfSense. However I am not able to make it work.

What I have done is setting up a bridge br0 (containing the public address, gateway…) connected to eth0 (iface eth0 inet manual). This works from the host as I have full connectivity, not so with pfSense or any other VM.

The main problem here is that I am not sure what IP should I use in pfSense since the public IP is already defined in the bridge. Setting up the same IP in pfSense will not work (seems logical). How should I proceed?

Best Answer

You will need to

  1. create a virtual adapter (ie, tap0) that belongs to the bridge and give it an IP (say 192.168.1.1)
  2. then connect all the VMs to that bridge and have them use 192.168.1.1 as their gateway, and
  3. setup the Proxmox host to do NAT by enabling ip forwarding:
    1. add net.ipv4.ip_forward=1 to /etc/sysctl.conf
    2. run sysctl -p
    3. add in the NAT rule with iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

The Proxmox docs cover this pretty well (and in more detail).