/etc/hosts.allow和/etc/hosts.deny详解
今天遇到一台服务器22端口正常,但是通过ssh连接的问题。排查了防火墙和端口问题,半天没有找出来原因,后来求助大神,终于明白了通过etc目录下hosts.deny和hosts.allow文件可以限制远程访问,使用方法如下:
修改/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
以上写法表示允许210和222两个ip段连接sshd服务(这必然需要hosts.deny这个文件配合使用),当然:allow完全可以省略的。
当然如果管理员集中在一个IP那么这样写是比较省事的
all:218.24.129.110//他表示接受110这个ip的所有请求!
/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
注意看:sshd:all:deny表示拒绝了所有sshd远程连接。:deny可以省略。
所以:当hosts.allow和 host.deny相冲突时,以hosts.allow设置为准。
注意修改完后:
service network restart
重启网络服务才能让刚才的更改生效
配置优先级:
linux 系统会先检查/etc/hosts.deny规则,再检查/etc/hosts.allow规则,如果有冲突 按/etc/hosts.allow规则处理
/etc/hosts.allow和/etc/hosts.deny详解的更多相关文章
- 【转】Apache的Order Allow,Deny 详解
Apache的Order Allow,Deny 详解 Allow和Deny可以用于apache的conf文件或者.htaccess文件中(配合Directory, Location, Files等 ...
- 转-Apache的Order Allow,Deny 详解
Allow和Deny可以用于apache的conf文件或者.htaccess文件中(配合Directory, Location, Files等),用来控制目录和文件的访问授权. 所以,最常用的是:Or ...
- Apache的Order Allow,Deny 详解
Allow和Deny可以用于apache的conf文件或者.htaccess文件中(配合Directory, Location, Files等),用来控制目录和文件的访问授权. 所以,最常用的是: O ...
- Apache的Order Allow,Deny详解
Allow和Deny可以用于apache的conf文件或者.htaccess文件中(配合Directory, Location, Files等),用来控制目录和文件的访问授权. 所以,最常用的是: O ...
- 访问Storm ui界面,出现org.apache.storm.utils.NimbusLeaderNotFoundException: Could not find leader nimbus from seed hosts ["master"]. Did you specify a valid list of nimbus hosts for confi的问题解决(图文详解)
不多说,直接上干货! 前期博客 apache-storm-0.9.6.tar.gz的集群搭建(3节点)(图文详解) apache-storm-1.0.2.tar.gz的集群搭建(3节点)(图文详解)( ...
- 访问Storm ui界面,出现org.apache.storm.utils.NimbusLeaderNotFoundException: Could not find leader nimbus from seed hosts ["master" "slave1"]. Did you specify a valid list of nimbus hosts for confi的问题解决(图文详解)
不多说,直接上干货! 前期博客 apache-storm-1.0.2.tar.gz的集群搭建(3节点)(图文详解)(非HA和HA) 问题详情 org.apache.storm.utils.Nimbu ...
- Linux 限制IP——/etc/hosts.allow和/etc/hosts.deny文件【转】
就像是 限制特定IP来访 想法 看起来通常的做法是利用hosts的拒绝设置,而它的设置是针对某一个具体的进程,具体的服务,在这里就是sshd了 看起来设置一个网段使用的是 x.x.x.0/24 后面加 ...
- linux环境下/etc/hosts文件详解
linux环境下/etc/hosts文件详解 就没一个昵称能用关注 0.0632017.09.12 17:04:28字数 623阅读 27,096 介绍 hosts文件是linux系统中负责ip地址与 ...
- CentOS 6.3下Samba服务器的安装与配置方法(图文详解)
这篇文章主要介绍了CentOS 6.3下Samba服务器的安装与配置方法(图文详解),需要的朋友可以参考下 一.简介 Samba是一个能让Linux系统应用Microsoft网络通讯协议的软件, ...
随机推荐
- [转] DOS命令for用法详解
[From] http://www.jb51.net/article/31284.htm for帮助文档 对一组文件中的每一个文件执行某个特定命令. FOR %variable IN (set) DO ...
- Spring property文件配置方法以及如何与工程分离
1,Spring使用property文件作为配置源 工程中难免出现一些需要每次部署都需要配置的参数,如数据源连接参数等,测试环境跟实际运行环境是不一样的. 使用spring框架的话,这些参 ...
- G: 又见模法师
G: 又见模法师 Time Limit: 1 s Memory Limit: 128 MB #include <stdio.h> ; typedef long lo ...
- 安装cloudermanager时出现Acquiring installation lock问题(图文详解)
不多说,直接上干货! 问题详情 解决办法 哪一个节点被锁就删除哪一个. 解决办法:进入/tmp 目录,ls -a查看,删除scm_prepare_node.*的文件,以及.scm_prepare_no ...
- Beam概念学习系列之SDKs
不多说,直接上干货! https://beam.apache.org/get-started/beam-overview/ Beam SDK 提供了一个统一的编程模型,来处理任意规模的数据集,其中包括 ...
- 【Linux】修改ubuntu默认字符集
今天把以前的项目移植到linux上了,我装的是ubuntu,web服务器是tomcat,发现用freemark模板生成的静态页面全 乱码了,在windows都是正常的,猜想可能是linux字符集的问题 ...
- CF 305A——Strange Addition——————【暴力加技巧】
A. Strange Addition time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- jQuery 文本插入和标签移动方法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 【Linux相识相知】文件查找(locate/find)
在用linux操作系统的时候,当我们忘记之前某个文件存储的位置,但是知道其文件名或者模糊的知道其文件名,我们都可以通过文件查找工具来查找,linux提供两种常用的查找工具,locate和find,在日 ...
- [转]ASP.NET Web API系列教程(目录)
本文转自:http://www.cnblogs.com/r01cn/archive/2012/11/11/2765432.html 注:微软随ASP.NET MVC 4一起还发布了一个框架,叫做ASP ...