How expensive is a hostname in htaccess? Other solutions possible?
- by Nanne
For easy allow or disallowing of dynamic IP-adresses you can add them as a hostname in a .htaccess file.
As I have read from:
.htaccess allow from hostname?
it does a reverse lookup on the
connecting ip address, seeing if the
response matches the allowed name.
(Well, actually Apache is doing a
double lookup, first a reverse lookup
and then a forward lookup on the
result of the reverse.)
This is the reason we are currently not using dynamic-ip hostnames in the .htaccess: this "sounds" quite heavy: 2 extra lookups for every request.
Is this indeed quite heavy, and would a reasonably busy server that is rather looking for less then more load get away with this :)? (e.g.: how does this 'load' compare to the rest? If a request is 1000 times more expensive then the lookups it might be negligible. otoh, it could be that final straw :) )
Are there other solutions? I can write a script that does a lookup of the hostname and put it in .htaccess files ofcourse, but this feels a bit like a hack.