最大程度地利用好属于你的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设置为准。

总结:通过这种方法可以控制部分非授权访问,但不是一劳永逸的方法。

相关推荐:
HTTP/1.1协议中共定义了八种方法(有时也叫“动作”)来表明Request-URI指定的资源的不同操作方式: OPTIONS 返回服务器针对特定资源所支持的HTTP请求方法。也可以利用向Web服务器发送'*'的请求来测试服务器 …
DRM是一种典型版权保护的技术手段,内容方如果启用了 DRM,比如 Widewine,则需要在访问内容时进行权限校验,通过后放行,而这一校验的环节是需要浏览器支持DRM-enabled content功能的,若浏览器不支持,将 …
AppCleaner是一个小应用程序,它允许您彻底卸载不需要的应用程序。 安装应用程序会在整个系统中使用不必要的硬盘空间分发许多文件。AppCleaner找到所有这些小文件并安全地删除它们。 只需将应用程序放到App …
假设funcName为函数名字,用如下方法就可以达到目标 try{ if(typeof(eval(funcName))=="function"){ funcName(); } }catch(e){ //alert("not function"); } 一定要添加try catch块,否则不起作用。
在AndroidMainifest.xml中增加允许使用网络选项(在</application>结束标签之后>): <uses-permission android:name="android.permission.INTERNET" />
拿起手机扫一扫即可带走我!