Reputation: 13
I know the way to deny access from an IP address in .htaccess is:
<Limit GET POST>
order allow,deny
deny from 1.2.3.4
allow from all
</Limit>
To deny access from a user-agent in .htaccess, I could do:
BrowserMatchNoCase baiduspider banned
Deny from env=banned
BrowserMatchNoCase WordPress bad_bot
Order Deny,Allow
Deny from env=bad_bot
But how should I deny something like this, which is a report in access_log?
p4fe41437.dip0.t-ipconnect.de - - [27/Jan/2015:01:42:58 -0500] "GET / HTTP/1.1" 200 - "-" "Mozilla/5.0 Windows NT 6.1 WOW64 rv 16.0 Gecko/20100101 Firefox/16.0"
Is there also a way to deny using a wildcard, i.e. *.t-ipconnect.de
?
Thanks.
Upvotes: 1
Views: 963
Reputation: 143906
See the apache docs for Allow/Deny (authz).
Hosts whose names match, or end in, this string are allowed access. Only complete components are matched, so the above example will match foo.apache.org but it will not match fooapache.org. This configuration will cause Apache to perform a double reverse DNS lookup on the client IP address, regardless of the setting of the HostnameLookups directive. It will do a reverse DNS lookup on the IP address to find the associated hostname, and then do a forward lookup on the hostname to assure that it matches the original IP address. Only if the forward and reverse DNS are consistent and the hostname matches will access be allowed.
So you can do partial hostnames:
Deny from t-ipconnect.de
However, keep in mind that this is accomplished using. So this means the remote IP address must first have a reverse lookup that resolves to "something.t-ipconnect.de" then that host must have a forward lookup that matches the original IP address. If this isn't the case, you're not going to be able to block this way.
Upvotes: 1