通过主机名禁止IP?

时间:2012-10-28 05:05:54

标签: .htaccess http ip hostname

任何方式拒绝通过IP解析为的主机名访问我们的网站?

例如: 109.163.233.200解析为wau.torservers.net,我们不希望任何人使用解析为此的主机名访问我们的网站。

感谢任何帮助。

谢谢!

1 个答案:

答案 0 :(得分:0)

除非您必须使用.htaccess(我不知道它是否支持您所需的内容),因为标记可能表明,以及您是否具有root权限(非Windows) )服务器框,您可以将主机名添加到/etc/hosts.deny。我在Debian上引用它,因为它是自我记录的:

$ cat /etc/hosts.deny 
# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system.
#                  See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: some.host.name, .some.domain
#             ALL EXCEPT in.fingerd: other.host.name, .other.domain
#
# If you're going to protect the portmapper use the name "portmap" for the
# daemon name. Remember that you can only use the keyword "ALL" and IP
# addresses (NOT host or domain names) for the portmapper, as well as for
# rpc.mountd (the NFS mount daemon). See portmap(8) and rpc.mountd(8)
# for further information.
#
# The PARANOID wildcard matches any host whose name does not match its
# address.
#
# You may wish to enable this to ensure any programs that don't
# validate looked up hostnames still leave understandable logs. In past
# versions of Debian this has been the default.
# ALL: PARANOID

有关详情,请参阅hosts.deny man page