tcpwrapper防火墙

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

控制文件:
规则

匹配顺序: tcp-->tcpwrappers-->hosts.allow--> hosts.deny,默认情况下这两个文件是空的,规则马上写马上生效.
1、如果在hosts.allow能够匹配到相应的规则,则允许,匹配到此结束。
2、如果在hosts.allow匹配不到相应规则,接下来匹配hosts.deny文件,如果匹配到则拒绝,匹配到此结束。
3、如果在hosts.allow和hosts.deny中都无法匹配到相应规则,则允许。


防火墙的规则设计思路:先在host.deny先拒绝所有,然后再hosts.allow逐个放开。


tcpwrappers过滤的依据:服务名字,其实就是服务对应二进制文件的文件名


vsftpd/httpd/postfix/samba/nfs/sshd/squid/xinetd


vsftpd: /usr/sbin/vsftpd
sshd: /usr/sbin/sshd
portmap: /sbin/portmap  --> rpcbind
xinetd: /usr/sbin/xinetd


查看vsftpd是否支持tcpwrappers
client-->vsftpd-(libwrap.so)->tcpwrappers








查看某个服务支持tcpwrappers过滤:
# rpm -ql tcp_wrappers |grep '\<libwrap.so\>'
/usr/lib/libwrap.so


查询xinetd服务是否支持tcpwrappers的过滤:
1.
# ldd `which xinetd `|grep wra
        libwrap.so.0 => /lib/libwrap.so.0 (0x00110000)
# ldd `which vsftpd` |grep wra
        libwrap.so.0 => /lib/libwrap.so.0 (0x003e1000)
2.strings
# strings /sbin/portmap |grep 'hosts.*'
/etc/hosts.allow
/etc/hosts.deny
------------------
实例1:
# service vsftpd start
为 vsftpd 启动 vsftpd:                                    [确定]
# chkconfig krb5-telnet on
# service xinetd restart
停止 xinetd:                                              [确定]
启动 xinetd:                                              [确定]
# netstat -tnlp |grep :21
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      2578/vsftpd         
# netstat -tnlp |grep :23
tcp        0      0 0.0.0.0:23                  0.0.0.0:*                   LISTEN      2635/xinetd         
------------
设置规则:
1.telnet只有192.168.0.254能访问
2.vsftpd192.168.0.0/24都能访问,除192.168.0.254
3.sshd 192.168.0.254,只要有登录则发邮件告知管理员
4.本机能够访问这三个服务.




# vim /etc/hosts.deny 
vsftpd: ALL
telnetd: ALL
sshd:   ALL




# vim /etc/hosts.allow 
in.telnetd:        192.168.0.254
sshd:           192.168.0.254: spawn echo "login attempt from %c to %s" | mail -s "information about sshd login attempt" root@baidu.com
vsftpd:         192.168.0.0/255.255.255.0 EXCEPT 192.168.0.254
ALL:            LOCAL .baidu.com


spwan 执行命令
%c 客户端地址
%s 服务器的地址
LOCAL 本地主机


hosts.allow和hosts.deny格式:
服务名字1, 服务名字2, ...: 客户机地址 [:动作]


1、如何找出名字
2、客户机地址:
ALL
network/mask 192.168.0.0/255.255.255.0 或 192.168.0.
127.
?
.uplooking.com *.uplooking.com
EXCEPT
3、动作:
ALLOW
DENY












*************************************************
[root@mail ]# vim /etc/hosts.deny 


vsftpd: ALL
in.telnetd: ALL
sshd:   ALL




[root@mail ]# vim /etc/hosts.allow 




in.telnetd: 192.168.0.254
vsftpd: 192.168.0.0/255.255.255.0 EXCEPT 192.168.0.254
sshd:   192.168.0.254: spawn echo "login attempt from %c to %s" | mail -s "information about sshd login attempt" root@baidu.com
ALL:    LOCAL, .baidu.com

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值