[thelist] Country by IP address
William Anderson
neuro at well.com
Wed Jun 16 04:32:29 CDT 2004
Tony Crockford wrote:
> At 12:44 on Tuesday, 15 Jun 2004, Andy Budd wrote:
>
>> Any suggestions would be welcome
>
> Couldn't you use getenv [1] and gethostbyaddr [2] to get the hostname
> and then parse_url[3] to get .com or .co.uk?
If you did, you'd get false or bodged results. Not every IP address has a
reverse DNS entry for it, and not every IP address with one has an
*accurate* one. A reverse DNS entry for an IP can be anything - it doesn't
even have to resolve to something real. I could run my website in the
States or Canada or India and still have the IP for wherever it is return
neuro.me.uk - that wouldn't do your plan much good, would it? :)
Also, gTLDs are global, so finding out that an IP address is supposedly
something.gribble.example.com is meaningless from a geographic perspective.
Another example is AOL - if you use AOL in the UK, you appear to come from
aol.com - busted :)
Using geographic IP services such as GeoIP is the way to go.
- http://www.maxmind.com/app/geoip_country
--
_ __/| William Anderson | Brodie: The Force is strong with this one
\`O_o' neuro at well dot com | Jay: Dude, don't encourage him
=(_ _)= http://neuro.me.uk/ | -- Mallrats, (1995)
U - Thhbt! GPG 0xFA5F1100 |
More information about the thelist
mailing list