Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
bobopu
V2EX  ›  Linux

编辑 iptables 规则保存后,重启 iptables 后规则又不见了是啥原因?

  •  
  •   bobopu · May 27, 2014 · 22959 views
    This topic created in 4443 days ago, the information mentioned may be changed or developed.
    配置好规则保存后,service iptables restart发现刚配置的规则又不见了。
    ls -l /etc/sysconfig/ipt*看了下
    有配置规则的记录日志,请问这是啥问题呢?
    6 replies    2014-05-27 09:43:17 +08:00
    bobopu
        1
    bobopu  
    OP
       May 27, 2014
    我晕,是没chkconfig iptables on,太大意。。
    sofs
        2
    sofs  
       May 27, 2014   ❤️ 1
    service iptables save
    service iptables restart
    Honwhy
        3
    Honwhy  
       May 27, 2014
    如果你是在/etc/iptables文件中编辑的话,重启iptables后更改的规则会生效的。
    但是如果用命令方式: iptables ... --dport xxx-j ACCEPT 这类的话,只是临时保存而已,并没有保存到/etc/iptables文件中,这时重启(restart),还是从原来的/etc/iptables读取配置规则,所以刚才用命令行添加的规则就丢掉了。
    一般是iptables-save>/etc/iptables吧
    有的就是直接编辑/etc/iptables了
    wanjun
        4
    wanjun  
       May 27, 2014
    上次我在没有关闭iptables时,把规则清空,然后ssh就锻炼...
    wanjun
        5
    wanjun  
       May 27, 2014
    @wanjun 断了...
    bobopu
        6
    bobopu  
    OP
       May 27, 2014   ❤️ 1
    @Honwhy 学习了。是在/etc/iptables中编辑的,但是因为直接保存为service iptables save了,重启iptables后就失效了,用chkconfig iptables on后保存成功。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1099 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 23:46 · PVG 07:46 · LAX 16:46 · JFK 19:46
    ♥ Do have faith in what you're doing.