#DNAT:58.246.38.82是公网IP,绑定在eth0上。将公网的3901端口访问映射到内网的208的80端口。
iptables -t nat -A PREROUTING -d 58.246.38.82 -i eth0 -p tcp -m tcp --dport 3901 -j DNAT --to-destination 192.168.0.208:80

#SNAT:将208发出的包转发至58.246.38.82
iptables -t nat -A POSTROUTING -s 192.168.0.208 -o eth0 -j SNAT --to-source 58.246.38.82

 

iptables -t nat -L 查看一下

注意/etc/sysctl.conf 中的net.ipv4.ip_forward = 1

使用service iptables save 保存配置。

最后重启iptables, service iptables restart.  OK

相关文章:

  • 2021-06-10
  • 2021-07-14
  • 2022-12-23
  • 2021-07-04
  • 2021-04-20
  • 2022-01-23
  • 2022-12-23
猜你喜欢
  • 2021-08-28
  • 2021-11-10
  • 2021-09-07
  • 2021-12-03
  • 2021-05-12
  • 2021-11-23
  • 2021-11-28
相关资源
相似解决方案