Linux – CentOS 7 Forward port to another IP:PORT

bashcentosiptableslinux

I have CentOS 7 that uses IPTABLES for Forwarding port 30120 to windows server

For example :
Windows games server IP: 192.168.1.3
Linux Centos 7 server IP : 192.168.1.5

iptables -t nat -A PREROUTING -p tcp --dport 30120 -j DNAT --to-destination 192.168.1.3:30120

iptables -t nat -A POSTROUTING -p tcp -d 192.168.1.3 --dport 30120 -j SNAT --to-source 192.168.1.5

iptables -t nat -A PREROUTING -p udp --dport 30120 -j DNAT --to-destination 192.168.1.3:30120

iptables -t nat -A POSTROUTING -p udp -d 192.168.1.3 --dport 30120 -j SNAT --to-source 192.168.1.5

and I have rules to anti DDOS and secure SSH but it's not work with forward
still forwarding traffic from my Centos to 192.168.1.3:30120

My PC IP: 192.168.1.2
Have used for test in CentOS

iptables -A INPUT -s 192.168.1.2 -j DROP

This IP 192.168.1.2 can't access to CentOS 7 but can forwarding to windows server by port 30120

How it's blocked?

thank you.

Best Answer

The general syntax is:

firewall-cmd --add-forward-port=port=port-number:proto=tcp|udp:toport=port-number:toaddr=IP/mask

firewall-cmd --zone=public --add-masquerade --permanent

Case-specific example:

firewall-cmd --zone=public --add-forward-port=port=30120:proto=tcp:toport=30120:toaddr=192.168.1.100
  --permanent