1. Allow packet forwarding:
#echo 1 >/proc/sys/net/ipv4/ip_forward
2. Forward TCP 8081 to xx.xx.xx.xx:
#iptables-T nat-i prerouting-p TCP-–dport 8081-j dnat–-to xx.xx.xx.xx
3. Enable the forward packet to implement a "bidirectional path" to set a correct return channel for the packet:
#iptables-T nat-i postrouting-p TCP-–dport 8081-j Masquerade
4. Means to save the rule to the/etc/sysconfig/iptables file
#service iptables Save
5. Restart Iptables to make the rules you just added take effect
#service iptables Restart
If the above command is executed, still cannot forward, possibly because the iptables service does not stop, the command cannot write to the Iptables file, the service iptables stop is executed first, the above command is executed, and the last service iptables Start Restart Service
Linux Firewall for port forwarding, port mapping and bidirectional access