Linux 下最简单的防火墙之 tcp

软件包

tcp_wrappers-[version…] # 一般情况下都默认安装的,可通过以下命令检查:

rpm -qa | grep tcp ;

结果如下,则表示已安装:

Linux 下最简单的防火墙之 tcp_wrappers

tcp_wrappers检查

不足

只有应用了库【libwrapped】文件才能使用 tcp_wrappers;一些默认的系统服务已可使用: sshd、portmap、sendmail、xinted、vsftp等

配置

使用两个文件完成: /etc/hosts.allow ; /etc/hosts.deny

格式: service:host(s) [:action]

service: 服务名

host(s): 主机名或IP地址

action: 符合条件后执行的动作

保留字

ALL : 所有服务或IP

ALL EXCEPT : 排除指定的服务或IP

优先顺序

allow > deny > 默认是 allow ; 根据此顺序可知,先是allow,然后是 deny ,最后是默认的,即:如果不配置,则allow

配置实例

编辑:vim /etc/hosts.deny # hosts.allow 同样配置

添加:sshd:all # 拒绝所有用户通过sshd登陆系统

测试结果:

Linux 下最简单的防火墙之 tcp_wrappers

配置hosts.deny中的shhd后,无法登陆


分享到:


相關文章: