Port Forwarding

  1. For CentOS 7.X, run the following command and reboot the server:
    systemctl start firewalld
    firewall-cmd --zone=public --add-masquerade --permanent
    firewall-cmd --zone=public --add-rich-rule='rule
    family="ipv4" source address="0.0.0.0/0" accept' --permanent
    firewall-cmd --zone=public
    --add-forward-port=port=443:proto=tcp:toport=5004
    --permanent
    firewall-cmd --reload
  2. For CentOS 6.X, add the following line in the /etc/rc.local file:
    iptables -A INPUT -i eth0 -p tcp --dport 443 -j ACCEPT
    iptables -A INPUT -i eth0 -p tcp --dport 5004 -j ACCEPT
    iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 5004
  3. Execute the following commands and reboot the server:
    
    # chmod +x /etc/rc.local
    # iptables -t nat -L