V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
iceecream
V2EX  ›  Linux

CentOS 版本 7 的 iptables 求助。

  •  
  •   iceecream · 2017-06-28 16:09:34 +08:00 · 2713 次点击
    这是一个创建于 2465 天前的主题,其中的信息可能已经有所发展或是发生改变。

    主机停止了 firewalld 服务,并未安装 IPtables-services 这个包。 停止 firewalld 服务时,iptables-save 输出为空,但是此时如果使用 iptables -A INPUT 添加一些规则,那么我发现这些规则仍然是生效的。即 iptables 服务没有开启时,iptables 规则也是生效的。 为什么会出现这种情况??

    本人在 6 版本中调试 iptables 时,习惯在 crontab 里面添加定时停止 iptables 服务的命令,防止自己被关在门外。那么此法在 CentOS-7 中无法实现?

    8 条回复    2017-06-28 18:39:55 +08:00
    defunct9
        1
    defunct9  
       2017-06-28 16:15:04 +08:00
    iptables -A INPUT 会自动启用 iptables 服务
    raysonx
        2
    raysonx  
       2017-06-28 16:19:54 +08:00
    iptables 其实并不是一个服务。CentOS 或者 RHEL 里面的所谓“ iptables 服务”只是帮你导入或者清空 iptables 表和链而已。
    iceecream
        3
    iceecream  
    OP
       2017-06-28 16:31:19 +08:00
    @defunct9 不是,我并没有安装 iptables-services 这个包,所以并无此服务。
    defunct9
        4
    defunct9  
       2017-06-28 16:44:29 +08:00
    不装?你真的没装吗,系统缺省自带的
    ladeo
        5
    ladeo  
       2017-06-28 16:45:30 +08:00 via Android
    这个包是 epel 里的 自带应该没有
    AntonChen
        6
    AntonChen  
       2017-06-28 16:49:16 +08:00 via iPhone
    定时任务关闭?居然有这种操作,get
    zent00
        7
    zent00  
       2017-06-28 17:16:43 +08:00 via iPhone
    你用 iptables 命令是直接对 netfilter 进行了操作,当然能生效,所谓的 iptables-services 所做的仅仅是在该服务启动时加载你所配置的规则,服务停止时清除掉已经应用的规则。
    sunqi0928
        8
    sunqi0928  
       2017-06-28 18:39:55 +08:00   ❤️ 1
    你先搞清楚两个概念:
    iptables.x86_64 : Tools for managing Linux kernel packet filtering capabilities

    iptables-services.x86_64 : iptables and ip6tables services for iptables

    然后给你个文章看吧: https://blog.argcv.com/articles/3167.c
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2918 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:16 · PVG 23:16 · LAX 08:16 · JFK 11:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.