创建nat
# iptables -t nat -A PREROUTING -p tcp --dport 15796 -j DNAT --to-destination 1.2.3.4:1210
# service iptables save
# systemctl restart iptables
#iptables -t nat -vnL
#iptables -t nat -A POSTROUTING -p tcp -d 1.2.3.4 --dport 1210 -j MASQUERADE
删除nat
# iptables -t nat -D PREROUTING 1
# iptables -t nat -D POSTROUTING 1
查看nat
# iptables -t nat -vnL
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
3 156 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:15796 to:1.2.3.4:1210
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 978 packets, 70677 bytes)
pkts bytes target prot opt in out source destination
3 156 MASQUERADE tcp -- * * 0.0.0.0/0 1.2.3.4 tcp dpt:1210
Chain OUTPUT (policy ACCEPT 978 packets, 70677 bytes)
pkts bytes target prot opt in out source destination