Forwarding from one computer to another port
Enable the network card forwarding feature
#echo 1 >/proc/sys/net/ipv4/ip_forward
Example: Access to 192.168.0.211:1521 Port from 192.168.0.132:21521 (new port)
A. The same port forwarding (192.168.0.132 1521 port access iptables-a rh-firewall-1-input-m State--state new-m tcp-p TCP--dport 1521-j accep T
Iptables-t nat-i prerouting-p tcp--dport 1521-j dnat--to
Iptables-t nat-i postrouting-p TCP--dport 1521-j Masquerade
B. Different port forwarding (192.168.0.132 21521 port access iptables-a rh-firewall-1-input-m State--state new-m tcp-p TCP--dport 21521-j ACC EPT)
Iptables-t nat-a prerouting-p tcp-m tcp--dport 21521-j dnat--to-destination 192.168.0.211:1521
Iptables-t nat-a postrouting-s 192.168.0.0/16-d 192.168.0.211-p tcp-m tcp--dport 1521-j SNAT--to-source .132
Above two equivalent configurations (simpler [specify network adapters]):
Iptables-t nat-a prerouting-p tcp-i eth0--dport 31521-j dnat--to 192.168.0.211:1521
Iptables-t nat-a Postrouting-j Masquerade
Save Iptables
#service iptables Save
#service iptables Restart
two uses the iptables to make the native port forwarding
The code is as follows:
Iptables-t nat-a prerouting-p tcp--dport 80-j REDIRECT--to-ports 8080
Estimating the appropriate addition of other parameters can also be done with different IP port forwarding.
If you need this machine to also be able to access, you need to configure the output chain (******** Special Note: Local access to the extranet port will be forwarded locally, resulting in the visit to the extranet, such as access to yown.com, is actually access to local, it is recommended not to do 80-port forwarding or specified purpose D localhost):
Iptables-t nat-a output-d localhost-p tcp--dport 80-j REDIRECT--to-ports 8080
Reason:
The extranet access needs to go through the prerouting chain, but the localhost does not go through the chain, so it needs to be output.