This article is from the "Township had sex ren" blog, please be sure to keep this source http://shaowu.blog.51cto.com/627407/514909
Project team colleagues need to forward SQL requests to another server, so this feature is implemented through Iptables
[[Email protected]1 ~]# echo 1 > Proc/sys/net/ipv4/ip_forward[[email protected] -1 ~]# iptables-t nat-a prerouting-d 192.168 . 18.19 -P TCP--dport 1521 -j DNAT--to 192.168 . 4.74 : 1521 [[email protected] -192.168 . 4.74 -P TCP--dport 1521 -j SNAT--to 192.168 . 18.19
To view NAT rules:
[[Email protected]1~]# iptables-l-N-T Natchain prerouting (policy ACCEPT) target prot opt source Destinationdnat TCP--0.0.0.0/0 192.168.18.19TCP DPT:1521To:192.168.4.74:1521Chain postrouting (policy ACCEPT) target prot opt source Destinationsnat TCP--0.0.0.0/0 192.168.4.74TCP DPT:1521To:192.168.18.19Chain OUTPUT (policy ACCEPT) target prot opt source destination
Telnet test:
[Email protected]1192.168. 4.74 1521 192.168. 4.74 ... Connected to localhost (192.168. 4.74 '^]'.
Save Iptables Settings:
[[Email protected]1 ~]# iptables-save >>/etc/sysconfig/iptables
(reprint) iptables forwarding Oracle Port