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

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

  •  
  •   bobopu · May 27, 2014 · 23171 views
    This topic created in 4562 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
    bobopu
    OP
    May 27, 2014
    1
    我晕,是没chkconfig iptables on,太大意。。
    sofs
    sofs
    May 27, 2014❤️1
    2
    service iptables save
    service iptables restart
    Honwhy
    Honwhy
    May 27, 2014
    3
    如果你是在/etc/iptables文件中编辑的话,重启iptables后更改的规则会生效的。
    但是如果用命令方式: iptables ... --dport xxx-j ACCEPT 这类的话,只是临时保存而已,并没有保存到/etc/iptables文件中,这时重启(restart),还是从原来的/etc/iptables读取配置规则,所以刚才用命令行添加的规则就丢掉了。
    一般是iptables-save>/etc/iptables吧
    有的就是直接编辑/etc/iptables了
    wanjun
    wanjun
    May 27, 2014
    4
    上次我在没有关闭iptables时,把规则清空,然后ssh就锻炼...
    wanjun
    wanjun
    May 27, 2014
    5
    @wanjun 断了...
    bobopu
    bobopu
    OP
    May 27, 2014❤️1
    6
    @Honwhy 学习了。是在/etc/iptables中编辑的,但是因为直接保存为service iptables save了,重启iptables后就失效了,用chkconfig iptables on后保存成功。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1004 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:06 · PVG 03:06 · LAX 11:06 · JFK 14:06
    ♥ Do have faith in what you're doing.