1.
vi /etc/sysctl.conf
將
net.ipv4.ip_forward = 0
改成:
net.ipv4.ip_forward = 1
sysctl -p
2.
iptables -t nat -A PREROUTING --dst 本機外網ip -p tcp -m tcp --dport 8080 -j DNAT --to-destination 轉發ip:端口
iptables -t nat -A POSTROUTING --dst 轉發ip -p tcp -m tcp --dport 端口 -j SNAT --to-source 本機外網ip
service iptables save
service iptables restart