首页 » Linux » Configure » Linux-iptables设置端口转发规则

Linux-iptables设置端口转发规则

 

第一步:
echo 1 > /proc/sys/net/ipv4/ip_forward
第二步:
测试环境:
本机IP:192.168.0.1
对端IP:192.168.0.2
设置效果:访问192.168.0.1 80端口  将转发到192.168.0.2 80端口
# Generated by iptables-save v1.4.7 on Fri Dec 22 08:36:27 2017
*nat
:PREROUTING ACCEPT [6:489]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
#-A INPUT -p tcp -m tcp –dport 80 -j ACCEPT
-A PREROUTING -p tcp -m tcp –dport 80 -j DNAT –to-destination 192.168.0.2:80

本文隐藏内容 登陆 后才可以浏览

COMMIT
# Completed on Fri Dec 22 08:36:27 2017
# Generated by iptables-save v1.4.7 on Fri Dec 22 08:36:27 2017
# Completed on Fri Dec 22 08:36:27 2017

原文链接:Linux-iptables设置端口转发规则,转载请注明来源!

0