【问题标题】:Iptables not loading new rules after restart Centos重启 Centos 后 iptables 不加载新规则
【发布时间】:2015-07-17 16:10:08
【问题描述】:

我创建了一个向 iptables 防火墙添加规则的 bash 脚本

示例

iptables -A INPUT -p tcp --dport 8080 -j ACCEPT

问题

重启后此规则不适用

在 bash 脚本中保存和应用规则的最佳方法是什么

【问题讨论】:

    标签: bash centos firewall iptables


    【解决方案1】:

    由于某些原因,上述答案对我不起作用。 因此,我没有恢复表,而是在

    中添加了路由条目

    /etc/rc.local/etc/rc.d/rc.local file.

    例如,添加

    sudo ip route add <ipaddr1> via <ipaddr2> dev <device>
    

     /etc/rc.local
    

    【讨论】:

      【解决方案2】:

      要将当前规则保存到文件中,请使用 iptables-save。例如:

      iptables-save > /etc/sysconfig/iptables
      

      要从该文件加载保存的规则,请使用 iptables-restore。例如:

      iptables-restore < /etc/sysconfig/iptables
      

      【讨论】:

        猜你喜欢
        • 2018-08-25
        • 2019-10-05
        • 1970-01-01
        • 1970-01-01
        • 2014-11-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多