iptables on RHEL6 port forwarding
by christr from LinuxQuestions.org on (#4Y82F)
I've been searching here and googling like crazy trying to find the answer to a question I have. I need to forward a specific port using iptables. I've been able to make it work using RHEL7 and RHEL8 firewalld, but not with RHEL6 iptables. I'm in a situation where I must do this with iptables on RHEL6.
Any inbound connection on port 389 that hits the server must redirect that traffic to another host at 192.168.0.34 using the same port.
For example, this works with RHEL7 and RHEL8:
Code:firewall-cmd --zone=public --add-masquerade --permanent
firewall-cmd --zone=public --add-forward-port=port=389:proto=tcp:toport=389:toaddr=192.168.0.34 --permanent
firewall-cmd --reloadI've tried numerous examples on how to apply this to my /etc/sysconfig/iptables on RHEL6, but nothing works that I've tried. Any suggestions would be greatly appreciated.
Thanks


Any inbound connection on port 389 that hits the server must redirect that traffic to another host at 192.168.0.34 using the same port.
For example, this works with RHEL7 and RHEL8:
Code:firewall-cmd --zone=public --add-masquerade --permanent
firewall-cmd --zone=public --add-forward-port=port=389:proto=tcp:toport=389:toaddr=192.168.0.34 --permanent
firewall-cmd --reloadI've tried numerous examples on how to apply this to my /etc/sysconfig/iptables on RHEL6, but nothing works that I've tried. Any suggestions would be greatly appreciated.
Thanks