您的位置:首页 > 运维架构 > Linux

centos 5.5 hosts.allow&hosts.deny

2010-09-06 12:11 399 查看
centos 5.5 hosts.allow&hosts.deny

这个两个文件均在/etc目录下,优先级为先检查hosts.deny,然后检查hosts.allow文件,后者设置可以超越前者的限制。

举例:

1.限制所有的ssh

除非从xxx.xxx.xxx.xxx----127上来

hosts.deny内容如下:

in.sshd:ALL

hosts.allow内容

in.sshd:xxx.xxx.xxx.xxx/netmask

2.封掉xxx.xxx.xxx.0—127的telnet

hosts.deny

in.sshd:xxx.xxx.xxx.0/255.255.255.xxx

3.限制所有人的TCP连接,除非从xxx.xxx.xxx.0——127访问

hosts.deny

ALL:ALL

hosts.allow

ALL:xxx.xxx.xxx.0/255.255.255.xxx

4.限制xxx.xxx.xxx.0——127对所有服务的访问

hosts.deny

ALL:xxx.xxx.xxx.0/255.255.255.xxx

其中冒号前面是TCP daemon的服务进程名称,通常系统

进程在/etc/inetd.conf中指定,比如in.ftpd,in.telnetd,in.sshd

其中IP地址范围的写法有若干中,主要的三种是:

1.网络地址——子网掩码方式:

xxx.xxx.xxx.0/255.255.255.xxx

2.网络地址方式

xxx.xxx.(为xxx.xxx打头的ip地址。)

3.缩略子网掩码方式,既数一数二进制子网掩码前面有多少个“1”比如:

xxx.xxx.xxx.0/255.255.255.xxx /218.64.87.0/24

设置好后,要重新启动

#service network restart

# /etc/rc.d/init.d/xinetd restart

# /etc/rc.d/init.d/network restart

本文出自 “有志者事竟成!” 博客,请务必保留此出处http://zh888.blog.51cto.com/1684752/387888
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: