当前位置: 代码迷 >> 综合 >> 端口重定向
  详细解决方案

端口重定向

热度:58   发布时间:2024-01-15 18:08:23.0

端口重定向命令:iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8081


先将防火墙规则保存到/etc/iptables.up.rules文件中

# iptables-save > /etc/iptables.up.rules   #需要sudo su - root切换用户后执行,直接sudo cmd是不行的

Then modify the/etc/network/interfacesscript to apply the rulesautomatically (the bottom line is added)

然后修改脚本/etc/network/interfaces,使系统能自动应用这些规则(最后一行是我们手工添加的)。

auto eth0

iface eth0 inet dhcp

pre-up iptables-restore < /etc/iptables.up.rules


  相关解决方案