Port Forwarding is not working for me

Editor

Well-Known Member
Apr 26, 2017
108
1
58
Turkey
Hi,

I want to forward the ports to specific VM/LXCs. To do this, `/etc / network / interfaces`
I made changes but still no redirects.

Is there a mistake here?

Code:
auto lo
iface lo inet loopback

iface enp3s0 inet manual
iface enp5s0 inet manual

auto vmbr0
iface vmbr0 inet static
        address  178.20.154.222
        netmask  255.255.255.0
        gateway  178.20.154.254
        bridge-ports enp3s0
        bridge-stp off
        bridge-fd 0

        post-up echo 1 > /proc/sys/net/ipv4/ip_forward
        post-up iptables -t nat -A PREROUTING -i vmbr0 -d 178.20.154.222 -p tcp --dport 80 -j DNAT --to 192.168.128.198:80
        post-up iptables -t nat -A PREROUTING -i vmbr0 -d 178.20.154.222 -p tcp --dport 443 -j DNAT --to 192.168.128.198:443
        post-up iptables -t nat -A PREROUTING -i vmbr0 -d 178.20.154.222 -p tcp --dport 2030 -j DNAT --to 192.168.128.186:2030
        post-up iptables -t nat -A PREROUTING -i vmbr0 -d 178.20.154.222 -p tcp --dport 2031 -j DNAT --to 192.168.128.186:2031
        post-up iptables -t nat -A PREROUTING -i vmbr0 -d 178.20.154.222 -p tcp --dport 8080 -j DNAT --to 192.168.128.198:8080

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


HAproxy100192.168.128.198
Web server101129.168.128.186
Mattermost102192.168.128.182
 
Looks good, but that requires a reboot or restart of the interface.

Does "iptables -L -t nat" list the rules ?
 
Looks good, but that requires a reboot or restart of the interface.

Does "iptables -L -t nat" list the rules ?

I restart the server after every change but still not working..

Code:
root@compute-ua:~# iptables -L -t nat
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination        
DNAT       tcp  --  anywhere             compute-ua.example.com  tcp dpt:http to:192.168.128.198:80
DNAT       tcp  --  anywhere             compute-ua.example.com  tcp dpt:https to:192.168.128.198:443
DNAT       tcp  --  anywhere             compute-ua.example.com  tcp dpt:2030 to:192.168.128.198:2030
DNAT       tcp  --  anywhere             compute-ua.example.com  tcp dpt:2031 to:192.168.128.198:2031
DNAT       tcp  --  anywhere             compute-ua.example.com  tcp dpt:http-alt to:192.168.128.198:8080

Chain INPUT (policy ACCEPT)
target     prot opt source               destination        

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!