centos 安全配置应用之hosts.allow和hosts.deny
来源:互联网 发布:果宝特攻3玩具淘宝 编辑:程序博客网 时间:2024/05/31 13:15
一、概述
这两个文件是tcpd服务器的配置文件,tcpd服务器可以控制外部IP对本机服务的访问。这两个配置文件的格式如下:
#服务进程名:主机列表:当规则匹配时可选的命令操作
server_name:hosts-list[:command]
/etc/hosts.allow控制可以访问本机的IP地址,/etc/hosts.deny控制禁止访问本机的IP。如果两个文件的配置有冲突,以/etc/hosts.deny为准。
/etc/hosts.allow和/etc/hosts.deny两个文件是控制远程访问设置的,通过他可以允许或者拒绝某个ip或者ip段的客户访问linux的某项服务。
比如SSH服务,我们通常只对管理员开放,那我们就可以禁用不必要的IP,而只开放管理员可能使用到的IP段。
二、配置
1、修改/etc/hosts.allow文件
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
sshd:210.13.218.*:allow
sshd:222.77.15.*:allow
all:218.24.129.110 #表示接受110这个ip的所有请求!
in.telnetd:140.116.44.0/255.255.255.0
in.telnetd:140.116.79.0/255.255.255.0
in.telnetd:140.116.141.99
in.telnetd:LOCAL
smbd:192.168.0.0/255.255.255.0 #允许192.168.0.网段的IP访问smbd服务
#sendmail:192.168.1.0/255.255.255.0
#pop3d:192.168.1.0/255.255.255.0
#swat:192.168.1.0/255.255.255.0
pptpd:all EXCEPT 192.168.0.0/255.255.255.0
httpd:all
vsftpd:all
以上写法表示允许210和222两个ip段连接sshd服务(这必然需要hosts.deny这个文件配合使用),当然:allow完全可以省略的。
ALL要害字匹配所有情况,EXCEPT匹配除了某些项之外的情况,PARANOID匹配你想控制的IP地址和它的域名不匹配时(域名伪装)的情况。
2、修改/etc/hosts.deny文件
#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
sshd:all:deny
in.telnet:ALL
ALL:ALL EXCEPT 192.168.0.1/255.255.255.0,192.168.1.21,\
202.10.5.0/255.255.255.0
注意看:sshd:all:deny表示拒绝了所有sshd远程连接。:deny可以省略。
3、启动服务
注意修改完后:
#service xinetd restart
才能让刚才的更改生效。
- centos 安全配置应用之hosts.allow和hosts.deny
- hosts.allow和hosts.deny
- hosts.allow和hosts.deny
- 通过配置hosts.allow和hosts.deny限制登陆
- /etc/hosts.allow和/etc/hosts.deny
- /etc/hosts.allow和/etc/hosts.deny
- linux hosts的allow和deny
- linux远程访问权限控制(hosts.allow和hosts.deny)
- linux远程访问权限控制(hosts.allow和hosts.deny)
- /etc/hosts.allow和/etc/hosts.deny的作用
- linux下的hosts.allow和hosts.deny
- hosts.deny和hosts.allow限制SSH登陆的IP
- 修改/etc/hosts.allow和/etc/hosts.deny允许linux服务器允许和限制访问
- 使用 /etc/hosts.allow和/etc/hosts.deny 控制客户端的访问
- Linux 限制IP——/etc/hosts.allow和/etc/hosts.deny文件
- hosts.deny和hosts.allow 设置限制SSH登陆的IP
- Linux hosts.allow与hosts.deny文件设置
- Linux hosts.allow与hosts.deny文件设置
- asp.net网站MVC开发模式下实现Sitemap(站点导航)的一些经验教训
- 使用虚拟信用卡进行国际支付
- Libnids-API(中文版)
- Javascript 笔记
- display:inline、block、inline-block的区别
- centos 安全配置应用之hosts.allow和hosts.deny
- 流量限速配置和QOS配置
- UNIX环境高级编程——标准I/O库函数和Unbuffered I/O函数
- 外部SD卡无法写入
- Oracle 基于 RMAN 的不完全恢复(incomplete recovery by RMAN)
- Python 类属性介绍
- jsp传参时若Url为中文时的乱码问题
- Java/JSP中使用JDBC连接SQL Server 2005~
- Python进制转换(二进制、十进制和十六进制)