Linux下tcpwrappers防火墙介绍

tcpwrappers(防火墙) --过滤TCP包头(/usr/sbin/tcpd)

/etc/hosts.allow 允许

/etc/hosts.deny 拒绝

匹配顺序 tcp包头----<wrappers.so> ------- /etc/hosts.allow ------- /etc/hosts.deny

匹配规则< 规则马上写,触发的时候,立刻生效>

1.先匹配/etc/hosts.allow,如果匹配到相应的规则,则允许匹配到此结束

2.在匹配/etc/hosts.deny,如果匹配到相应的规则,则拒绝匹配到此结束

3.如果2个文件都没有匹配,则允许

过滤依据 包含TCP协议服务 <xinetd/rpcbind|portmap/vsftpd/samba/httpd/sshd/postfix>

ldd /usr/sbin/vsftpd |grep libwrap

ldd /sbin/rpcbind |grep wrap

strings /usr/sbin/smbd |grep access

1.拒绝192.168.0.254 通过sshd远程登录

vim /etc/hosts.deny

#二进制名称: HOST

sshd: 192.168.0.x

ssh 192.168.0.1

ssh_exchange_identification: Connection closed by remote host --- 被tcpwrappers拒绝

设置规则:

1.telnet只有192.168.0.2|192.168.0.254能访问

2.vsftpd192.168.0.0/24都能访问,除192.168.0.254

3.sshd 192.168.0.254,只要有登录则发邮件告知管理员

4.本机能够访问这三个服务.

先拒绝所有,然后在一个个开放

先在/etc/hosts.deny 拒绝所有,然后在/etc/hosts.allow 逐个允许

spawn 触发按钮执行shell终端动作

LOCAL 本地所有的tcp服务

EXCEPT 除了

ALL

vim /etc/hosts.deny

ALL : ALL

vim /etc/hosts.allow

in.telnetd: 192.168.0.254,192.168.0.2 --注意'二进制名称'

vsftpd: 192.168.0.0/255.255.255.0 EXCEPT 192.168.0.254 --注意'子网掩码要写全>称'

或者 vsftpd: 192.168.0. | vsftpd: .example.com

sshd: 192.168.0.254 : spawn echo "%c正在登录%s" | mail -s "%d login" [email protected]

ALL: LOCAL

相关推荐
π大星星️2 小时前
基于LNMP架构的个人博客系统部署
服务器·架构
孙克旭_6 小时前
PXE_Kickstart_无人值守自动化安装系统
linux·运维·自动化
皓月盈江6 小时前
Linux电脑本机使用小皮面板集成环境开发调试WEB项目
linux·php·web开发·phpstudy·小皮面板·集成环境·www.xp.cn
深井冰水7 小时前
mac M2能安装的虚拟机和linux系统系统
linux·macos
leoufung7 小时前
内核内存锁定机制与用户空间内存锁定的交互分析
linux·kernel
π大星星️8 小时前
HAProxy + Keepalived + Nginx 高可用负载均衡系统
运维·nginx·负载均衡
菜菜why8 小时前
AutoDL租用服务器教程
服务器
IT专业服务商8 小时前
联想 SR550 服务器,配置 RAID 5教程!
运维·服务器·windows·microsoft·硬件架构
忧虑的乌龟蛋9 小时前
嵌入式Linux I2C驱动开发详解
linux·驱动开发·嵌入式·iic·i2c·读数据·写数据
I_Scholar9 小时前
OPENSSL-1.1.1的使用及注意事项
linux·ssl