编辑 iptables 规则保存后,重启 iptables 后规则又不见了是啥原因? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
bobopu
V2EX    Linux

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

  •  
  •   bobopu May 27, 2014 22781 views
    This topic created in 4353 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了
        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     4494 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 45ms UTC 10:12 PVG 18:12 LAX 03:12 JFK 06:12
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86