View Full Version : Using exec function to get rDNS info, is there a better way?
I'm trying to get dns info for any sites that visit my page, but it seems to lag a bit. Here is my code:
$rdns_code = exec('dig +noall +answer -x '.getenv('REMOTE_ADDR'));
Is there a better way of doing this? Also, I'm using php4.
10-23-2012, 12:56 AM
dig isn't very fast, and even less so if you are running it on every request. You could try gethostbyaddr() (http://php.net/gethostbyaddr), but I'm not sure that is going to be any faster. In general looking up the remote host on every request is a bad idea.
10-23-2012, 11:31 AM
I reckon, store the ip addresses in a temporary table.
Then, run a cron job, which implements some form of caching to translate the ip addresses into domain names. The caching wont help a truckload in this case, but 100mb or so of cache in a db translates to quite a few ip addresses -> domain names.
I assume you are doing this for statistical purposes? If not, the cron job solution would probably not be viable to you as I then assume you need the data in real time.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.