最大程度地利用好属于你的hosts.allow和hosts.deny
/etc/hosts.allow和/etc/hosts.deny两个文件是控制远程访问设置的,通过他可以允许或者拒绝某个ip或者ip段的客户访问linux的某项服务。
比如SSH服务,我们通常只对管理员开放,那我们就可以禁用不必要的IP,而只开放管理员可能使用到的IP段。
使用:
修改/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设置为准。
总结:通过这种方法可以控制部分非授权访问,但不是一劳永逸的方法。
相关推荐:
为现代 macOS 而生。 从架构到界面,IINA 只为现代 macOS 设计。它采用了 Yosemite 后的新设计语 […]
FileZilla是一个免费开源的FTP软件,分为客户端版本和服务器版本,具备所有的FTP软件功能。 可控性、有条理的界 […]
Mozilla Firefox,中文俗称“火狐”(正式缩写为Fx或fx,非正式缩写为FF),是一个自由及开放源代码的网页 […]
MindManager,中文商标译作C,俗称“脑图”,是一款创造、管理和交流思想的通用标准的绘图软件,由美国Mindje […]
MindManager,中文商标译作C,俗称“脑图”,是一款创造、管理和交流思想的通用标准的绘图软件,由美国Mindje […]
拿起手机扫一扫即可带走我!