Howto port forward from a public IP to a VM

Jeroen

New Member
Dec 27, 2016
4
0
1
45
Hi,

So far I have been able to setup Proxmox on a server with a public IP.
I do have a LXC VM running and it has internet.
Now I want to forward a port to my VM and I found this manual online.
Still, whatever I do, nothing seems to work (I disabled the firefwall on Proxmox).

My interfaces file looks like this:

Code:
auto lo
iface lo inet loopback

auto eth0
#real IP adress
iface eth0 inet static
        address  10.20.30.100
        netmask  255.255.255.0
        gateway  10.20.30.1

auto vmbr0
#private sub network
iface vmbr0 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 eth0 -j MASQUERADE
        post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE

What do I have to add to this file to make portfowarding work?
 
SOLVED:
It seems to work if I add the following lines to vmbr0:

Code:
post-up iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 10.10.10.2:80
post-down iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 10.10.10.2:80