zoukankan      html  css  js  c++  java
  • CentOS 访问控制列表(tcp wrappers)

    1、TCP Wrappers是一个工作在应用层的安全工具,它只能针对某些具体的应用或者服务起到一定的防护作用。
    比如说ssh、telnet、FTP等服务的请求,都会先受到TCP Wrappers的拦截。它能够根据来访主机的地址
    与本机的目标服务程序作出允许或拒绝的操作。

    2、TCP Wrappers 服务的防火墙策略由两个控制列表文件所控制,用户可以编辑允许控制列表文
    件来放行对服务的请求流量,也可以编辑拒绝控制列表文件来阻止对服务的请求流量。控制列表
    文件修改后会立即生效,系统将会先检查允许控制列表文件(/etc/hosts.allow),如果匹配到相应
    的允许策略则放行流量;如果没有匹配,则去进一步匹配拒绝控制列表文件(/etc/hosts.deny),若
    找到匹配项则拒绝该流量。如果这两个文件全都没有匹配到,则默认放行。

    3、直接编辑/etc/hosts.allow和/etc/hosts.deny就可以实现主机、ip、服务等控制

    在配置 TCP Wrappers 服务时需要遵循两个原则:
    1)编写拒绝策略规则时,填写的是服务名称,而非协议名称;
    2)建议先编写拒绝策略规则,再编写允许策略规则,以便直观地看到相应的效果。

    4、配置格式

    service:host(s) [:action]
    
    service:代表服务名,例如 sshd、vsftpd、sendmail 等,可以是多个,多个情况使用","逗号隔开。
    
    host(s):主机名或者 IP 地址,可以有多个,例如 192.168.1.0,www.baidu.com(可以使用空格或,隔开)。
    
    action:动作,符合条件后所采取的动作。
    
    配置文件中常用的关键字有:
    
    ALL:所有服务或者所有 IP。
    
    ALL EXCEPT:所有的服务或者所有 IP 除去指定的。
    
    例如:
    
    ALL:ALL EXCEPT 192.168.31.11
    
    表示除了 192.168.31.11 这台设备,任何设备执行所有服务时或被允许或被拒绝。

    5、用例

    [root@bigdata-senior01 ~]# cat /etc/hosts.deny 
    #
    # hosts.deny    This file contains access rules which are used to
    #        deny connections to network services that either use
    #        the tcp_wrappers library or that have been
    #        started through a tcp_wrappers-enabled xinetd.
    #
    #        The rules in this file can also be set up in
    #        /etc/hosts.allow with a 'deny' option instead.
    #
    #        See 'man 5 hosts_options' and 'man 5 hosts_access'
    #        for information on rule syntax.
    #        See 'man tcpd' for information on tcp_wrappers
    #
    vsftpd:* #禁止所有设备使用ftp
    [root@bigdata-senior01 ~]# cat /etc/hosts.allow
    #
    # hosts.allow    This file contains access rules which are used to
    #        allow or deny connections to network services that
    #        either use the tcp_wrappers library or that have been
    #        started through a tcp_wrappers-enabled xinetd.
    #
    #        See 'man 5 hosts_options' and 'man 5 hosts_access'
    #        for information on rule syntax.
    #        See 'man tcpd' for information on tcp_wrappers
    #
    vsftpd:192.168.31.0/255.255.255.0 #允许31段所有设备使用ftp服务

    最终192.168.31.0/24 网段可以使用ftp服务

  • 相关阅读:
    类数组及其转换
    数组去重
    ios UIView
    ios 解决Wkwebview闪烁问题
    ios Https问题
    UUID
    JavaScript4
    JavaScript2
    JavaScript1
    UIScollView
  • 原文地址:https://www.cnblogs.com/asker009/p/10286677.html
Copyright © 2011-2022 走看看