iptables端口重定向


需求:

    tomcat容器使用普通用户启动不能开启1024以内端口,也就80端口不能使用。业务上通常使用80端口访问。

解决方法:

    iptables既是防火墙也是带路由器功能。所以使用它的路由转发功能可以实现以上需求。

命令:

    #添加转发端口
    iptables -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8989
    
    #保存,备份
    iptables-save  >  /data/backup/iptables/iptables.rule

    #恢复
    iptables-restore < /data/backup/iptables/iptables.rule




原文地址:https://www.cnblogs.com/luguoyuanf/p/3bc93c329afad82e66e7db021063814b.html