2

I have a port forwarding problem with Proxmox under Debian.

I have two interfaces ( eth0 and vmbr2 ), how can I access to my client VM ( web server ) from external network by forwarding from a single public IP ?

I did some bad configuration I think on /etc/network/interfaces

Here's my interfaces :

auto eth0
iface eth0 inet static
        address  xxx.xxx.xxx.xxx
        netmask  255.255.255.224
        gateway  xxx.xxx.xxx.xxx
        up route add -net xxx.xxx.xxx.xxx netmask 255.255.255.224 gw xxx.xxx.xxx.xxx eth0

end for vmbr2 interface :

auto vmbr2
#private sub network
iface vmbr2 inet static
        address  192.168.100.254
        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 '192.168.100.0/24' -o eth0 -j ACCEPT
        post-down iptables -t nat -D POSTROUTING -s '192.168.100.0/24' -o eth0 -j ACCEPT

        post-up iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2222 -j DNAT --to 192.168.100.6:22
        post-down iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 2222 -j DNAT --to 192.168.100.6:22

Thank you very much for your help

Simo.jaouad
  • 23
  • 1
  • 4

1 Answers1

1

Just replace "ACCEPT" to "MASQUERADE" in the POSTROUTING rule.

user2743554
  • 397
  • 3
  • 13
  • Thank you very much ! you saved me a lot of time ... I did this configuration and run 'sysctl -w net.ipv4.ip_forward=1', after a restart of service it worked ! – Simo.jaouad Nov 14 '16 at 22:45