reverse DNS lookup

We're using now gethostbyaddr for reverse DNS lookup to process site logs. It fails for quite a lot of them, though. Is there any other way to find out the domain names? And is there a way to find out a country of origin for a .com domain?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are these valid failures? Some IP addresses do not have PTR records.

You might want to look into GeoIP for determining geographical locations of IP addresses. There are several modules on for this. Here's one for example:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jgenyukAuthor Commented:
Thanks for the module link, is it better than IP::Country or are tehy pretty much the same?

I'm not sure what "valid failures" are, I mean IPs that couldn't be resolved. Here's the code.

($name,$aliases,$addrtype,$length,@addrs) =
    # return the ip number if the name is unresolvable
    $name = $ipnum if(!defined($name));
Well, they are all the same! But coded differently, an ant could walk better then others, but it still walks!

Well, I don't think so, and they don't work for server logs, as they are old, most of people have DSL internet, means, dynamic IP address's, and while he disconnected, and that slot is free, means, that IP equals nothing at all! You could sort of do that process at the same time a user joins

My first post, Hope it helped!
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.


I mean have you seen IPs that couldn't be resolved by your script but _could_ be resolved manually.. (using dig or nslookup or similar) It's likely that the IPs you're seeing not resolve just simply don't have any PTR records defined and hence will not resolve (rightfully so).
Weird, Well, You could maybe rebuild the way it does nslookup, or maybe sniff

Can you post a packet sniff part of nslookup? So I could re-implement that into a function and hand it to you :-)
There are *so* many DNS setups on the Internet that are badly configured or just plain wrong, so not being able to resolve IP addresses is *very* common.

GeoIP is supposed to be less portable than IP::Country.  Apart from that, they appear to be pretty similar.

jgenyukAuthor Commented:
Actually I've tried some of these IPs and quite a few of them were resolved by dig (but not nslookup).
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.