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" u02@qq.com

ALL: LOCAL

相关推荐
chlk1238 小时前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑8 小时前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件9 小时前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
碳基沙盒9 小时前
OpenClaw 多 Agent 配置实战指南
运维
深紫色的三北六号18 小时前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash1 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI1 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行2 天前
Linux和window共享文件夹
linux
Sinclair2 天前
简单几步,安卓手机秒变服务器,安装 CMS 程序
android·服务器
木心月转码ing2 天前
WSL+Cpp开发环境配置
linux