Iptables implementation of Port forwarding, port mapping and two-way access is not difficult to configure, see below:
Allow packet forwarding:
#echo 1 >/proc/sys/net/ipv4/ip_forward
Forwarding TCP 8081 to xx.xx.xx.xx:
#iptables-T nat-i prerouting-p tcp–dport 80-j dnat–to xx.xx.xx.xx
Enable the forwarding packet to implement a "two-way path" and set a correct return channel for the packet:
#iptables-T nat-i postrouting-p tcp–dport 8080-j Masquerade
Represents saving a rule to a/etc/sysconfig/iptables file
#service iptables Save
Restart Iptables to take effect of the rule that you just added
#service iptables Restart
If you execute the above command and still cannot forward it, you may not be able to write the iptables file because the Iptables service is not stopped, and you should perform the service iptables stop before you perform the above command, and the last service iptables Start Restart Service
Because the Linux firewall defaults to shutting down Port 3306. Therefore, to be able to access Port 3306, there are two ways to turn off the firewall, and the other is to have the firewall open 3306 ports.
The troubleshooting steps for opening port 3306 are as follows:
1, modify the/etc/sysconfig/iptables file, add the following line:
-A rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 3306-j ACCEPT
2, restart the firewall, here are two ways to restart the firewall
A) effective after reboot
Open: Chkconfig iptables on
Close: Chkconfig iptables off
(b) Immediate effect, failure after reboot
Open: Service iptables start
OFF: Service iptables stop
The
Database mapping succeeded.