GeoIP2 for retrieving city and region ?

  • Thread starter Îικόλας
  • Start date
Î

Îικόλας

Hello, iam still looking for a way to identify the city of my website
visitors.

The closet i have gone is to come up with the visitor's ISP city:

try:
gi = pygeoip.GeoIP('/usr/local/share/GeoLiteCity.dat')
city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] )
host = socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] )[0]
except Exception as e:
host = repr(e)


But today i was searching again for this and found out about geoip2,
maybe that would help more.

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'geoip2'



I cant even import the module even though my 'pip install geopip2' was
successful

There is definately i way to identify the users location based solely on
its ip address as this site does it: http://www.geoiptool.com/

Google, MS, facebook and twitter are not the only ones that can do it?

Perhaps this is being done by giving longitude and latitude?
 
D

Dave Angel

Hello, iam still looking for a way to identify the city of my website
visitors.
I cant even import the module even though my 'pip install geopip2' wa
successful

Either it wasn't successful, or it's not the package you thought. There
are lots of things you might have downloaded, but since you give no
details...

There is definately i way to identify the users location based solely on
its ip address as this site does it: http://www.geoiptool.com/

Sure, and as long as you don't mind it being 1000 miles off, you too can
claim to do it too. When I go to that site, the little pin is in
Kansas, which is 1100 miles from where I live on the east coast of the US.

Google, MS, facebook and twitter are not the only ones that can do it?

Perhaps this is being done by giving longitude and latitude?

Or by reading the mind of the programmer.

I suggest you read that geoiptool site, in particular the page

http://www.geoiptool.com/en/ip_info/

There is some misinformation, but notice carefully the part about
dynamic IP addresses. Probably 99% of the individual users on the web
(the ones using a browser) have dynamic IP addresses. The fixed ones
are needed by servers, and especially for DNS use, where the name lookup
wants to be stable for relatively log periods of time.
 
Î

Îικόλας

Στις 12/7/2013 6:32 μμ, ο/η Dave Angel έγÏαψε:
I suggest you read that geoiptool site, in particular the page

http://www.geoiptool.com/en/ip_info/

There is some misinformation, but notice carefully the part about
dynamic IP addresses. Probably 99% of the individual users on the web
(the ones using a browser) have dynamic IP addresses. The fixed ones
are needed by servers, and especially for DNS use, where the name lookup
wants to be stable for relatively log periods of time.


I did, for me it gives exact city location and not the ISP's city location.

I dont know whay for you ti just says Kansas, it shoudln't, since it
susing longitute and latitude, it should have been accurate.
 
Î

Îικόλας

I know i have asked before but hwta i get is ISP city not visitors
precise city.

GeoLiteCity.dat isnt accurate that's why it comes for free.
i must somehow get access to GeoIPCity.dat which is the full version.

And of course it can be done, i dont want to believe that it cant.

When visiting http://www.geoiptool.com/en/__ip_info/ it pinpoints my
_exact_ city of living, not the ISP's.
It did not even ask me to allow a geop ip javascript to run it present
sit instantly.

So, it certainly is possible if only one can find the correct database
to use.

So, my question now is, if there is some way we can get an accurate Geo
City database.
 
G

Grant Edwards

I know i have asked before but hwta i get is ISP city not visitors
precise city.

You can't reliably do that.
GeoLiteCity.dat isnt accurate that's why it comes for free. i must
somehow get access to GeoIPCity.dat which is the full version.

And of course it can be done, i dont want to believe that it cant.

Believe what you want.
When visiting http://www.geoiptool.com/en/__ip_info/ it pinpoints my
_exact_ city of living, not the ISP's. It did not even ask me to
allow a geop ip javascript to run it present sit instantly.

So you've reached your conclusion on a sample size of one?
 
C

Chris Angelico

So you've reached your conclusion on a sample size of one?

This is Nikos. He doesn't read responses properly, doesn't do his
research, and has (by his own admission) an iron head that doesn't let
information cross it lightly. Yes, he reached his conclusion on a
sample size of one.

Oh, and just for laughs, I tried a few of my recent mobile IP
addresses in the GeoIP lookup. All of them quoted Melbourne someplace,
some in the CBD and some out in the suburbs, but all vastly wrong, and
places I haven't been. But I'd never expect it to be accurate on
those.

ChrisA
 
I

Ian Kelly

I know i have asked before but hwta i get is ISP city not visitors precise
city.

GeoLiteCity.dat isnt accurate that's why it comes for free.
i must somehow get access to GeoIPCity.dat which is the full version.

And of course it can be done, i dont want to believe that it cant.

When visiting http://www.geoiptool.com/en/__ip_info/ it pinpoints my _exact_
city of living, not the ISP's.
It did not even ask me to allow a geop ip javascript to run it present sit
instantly.

Try this:

1) Go to http://incloak.com (or any other free web proxy site).
2) Paste in the URL http://www.geoiptool.com and press Enter
3) See where it thinks you are now.

When I tried it, it placed me on the wrong side of the Atlantic Ocean.
 
M

MRAB

I know i have asked before but hwta i get is ISP city not visitors
precise city.

GeoLiteCity.dat isnt accurate that's why it comes for free.
i must somehow get access to GeoIPCity.dat which is the full version.

And of course it can be done, i dont want to believe that it cant.

When visiting http://www.geoiptool.com/en/__ip_info/ it pinpoints my
_exact_ city of living, not the ISP's.

Have you considered that your ISP might be in the same city as you?

According to geoiptool, my ISP is near Leeds, UK, but the important
point is that _I'm not_.
 
M

Michael Torrie

So, my question now is, if there is some way we can get an accurate Geo
City database.

As has been said pretty much by every other poster, there is no way to
do get an accurate location database. Period.

The databases that do exist were built by hand, and also guessed at
based on routing information. The best you can really do is region, or
country, and even that fails sometimes.

If you want to know a visitor's city you should ask them using the new
browser location apis available to javascript.

http://diveintohtml5.info/geolocation.html

Since IPs can be dynamic, sometimes even assigned across a region,
there's no way to accurately map ip addresses to a city with the
reliability that you seem to want. Google is pretty accurate because
they've spent a lot of time building up their own database, and also
convincing users to reveal their locations to them. Unless you do the
same thing, you have to just get by with what others have provided for you.
 
D

Dennis Lee Bieber

Oh, and just for laughs, I tried a few of my recent mobile IP
addresses in the GeoIP lookup. All of them quoted Melbourne someplace,
some in the CBD and some out in the suburbs, but all vastly wrong, and
places I haven't been. But I'd never expect it to be accurate on
those.
Well... the MaxMind demo of "my IP" did get the proper metropolitan
area... But they list the ISP as "AT&T"... My real ISP is Earthlink
(piggybacking on AT&T DSL service).

The Lat/Long, however shows as

42.9634 -85.6681
whereas a recent GPS readout shows
42.9159 -85.5541

or 2m50s too far north, and 6m50s too far west.

Same website, accessed from my Blackberry phone, gave a result of
"United States, NA" and location 38 -97
 
J

Joel Goldstick

Well... the MaxMind demo of "my IP" did get the proper metropolitan
area... But they list the ISP as "AT&T"... My real ISP is Earthlink
(piggybacking on AT&T DSL service).

The Lat/Long, however shows as

42.9634 -85.6681
whereas a recent GPS readout shows
42.9159 -85.5541

or 2m50s too far north, and 6m50s too far west.

Same website, accessed from my Blackberry phone, gave a result of
"United States, NA" and location 38 -97

Speaking more from a political perspective, an important aspect of the
internet is that if you are a publisher who doesn't require registration to
read what you post, your readers are free to be more or less anonymous.
This is a good thing in many ways. If you have a service that requires
some sort of sign up, then you can require knowing things about them
(location, etc). If you want to know where your readers are, you need to
make arrangements with their ISPs to get that information, since in many
cases the ISP has a physical link to your machine. But why should they
provide that to you? After all you are not their customer.

It might be fun to know, but the repercussions are serious.
 
C

Chris Angelico

Well... the MaxMind demo of "my IP" did get the proper metropolitan
area... But they list the ISP as "AT&T"... My real ISP is Earthlink
(piggybacking on AT&T DSL service).

The Lat/Long, however shows as

42.9634 -85.6681
whereas a recent GPS readout shows
42.9159 -85.5541

or 2m50s too far north, and 6m50s too far west.

Same website, accessed from my Blackberry phone, gave a result of
"United States, NA" and location 38 -97

When you try to place a visitor geographically by IP address, the only
thing you can be absolutely 100% certain of is which RIR they're at
(proxies aside - you're just testing the proxy rather than the
ultimate origin). Country is also highly likely to be right, though
not certain (I've never known it to be wrong, but I've never been able
to confirm what happens with some of the small European countries -
for all I know they could share ISPs and netblocks). Anything tighter
than that is goign to be pretty hit-and-miss. But I have to say, it's
improved a lot over the years. Back in the early 2000s - say, about 8
years ago, I think - I was playing with this sort of technology, and
it placed me in Sydney. That's one state away, lots of rivalry
separating us (friendly rivalry, of course; in a country that's doing
its best to kill us all, we can't afford to really hate each other),
and roughly 750-1000km wrong by distance (depending on how you measure
- most people don't put an odometer on a crow). So at least now it
gets within the same degree of latitude and longitude... most of the
time.

ChrisA
 
D

Dennis Lee Bieber

Read the answers you got. What is *impossible* is *exactly and
precisely* find the geographical location of your machine, just using an
IP database like what you are doing, i.e. without your local machine
cooperating in the process (for example, by providing the numbers taken
from your local machine's GPS device).
Which obviously did NOT happen when I used my Blackberry phone -- which
does have geolocation enabled (it is tagging photos with the city).

The only thing MaxMind had available from my phone was apparently the
DHCP server used by Blackberry, and gave out the approximate center of the
US.
 
D

Dennis Lee Bieber

???? 13/7/2013 1:07 ??, ?/? MRAB ??????:


My ISP is in Athens and i live in Thessaloníki and it returned back
Thessaloníki not Athens, which it was accurate for me.
Are you paying for a fixed IP number? I suspect you are if you were
running a world-accessible server.

Obviously a fixed IP will be tied to a fixed connection and thereby to
a fixed location which can be provided to a location database.

But most of us have DHCP assigned IP numbers, which change everytime we
reboot our connection (or even when the DHCP lease expires -- which may be
daily).

The IP number I have today may be given to somebody else on the other
side of the state tomorrow (though I suspect AT&T [phone company] keeps a
block of IP numbers per city -- but even my connection, AT&T Grand Rapids,
gets a "domain name" that identifies as Kalamazoo, when it gets to my ISP
Earthlink).

For DHCP, the only thing you can be sure of is that an IP database can
identify the location of the DHCP server that issues the IP number. In a
heavy population area, that may mean a DHCP server (and block of IP
numbers) may be down to the suburb level. Out in the country, one server
may handle multiple small towns.
 
R

Roy Smith

ÉΪÉ«É»όλας said:
But it works for me, How can it be impossible and worked for me at the
same time?

Also i tried some other website that asked me to allow it to run a
javascript on my browser and it pinpointed even my street!

If it wasnt possbile then MaxMind would be seeling its GeoIP2 app for
1380$ per year.

At Songza, we purchase the MaxMind database for doing geolocation based
on IP address. This is how we enforce our content licenses which only
allow us to stream music to the US and Canada. We also use it to target
specific features (or advertising) to specific cities or other
geographic areas within the US and Canada.

That being said, we understand that it is only an approximate solution.
It is useful, but not perfect. If you go to the MaxMind web site, you
will see they have a range of products, at different prices, which
promise various levels of accuracy and error rates. But none of them,
for any amount of money, offers "resolution down to the street address
and 0% error rate".
 
C

Chris Angelico

Are you paying for a fixed IP number? I suspect you are if you were
running a world-accessible server.

Obviously a fixed IP will be tied to a fixed connection and thereby to
a fixed location which can be provided to a location database.

And even that is no guarantee. I have two connections, one static IP,
the other dynamic. The static one fails geolocation by a greater
distance than the other. No, there's no way to be sure.

ChrisA
 
R

Roy Smith

Dennis Lee Bieber said:
Obviously a fixed IP will be tied to a fixed connection and thereby to
a fixed location which can be provided to a location database.

And even then, it can be wrong. When I worked for EMC, they
(apparently, from what I could see) back-hauled internet connections for
all their offices to Hopkinton, MA where they had one central ISP
connection, via NAT. So, when I sat at my desk in White Plains, NY and
went to Moviephone's web site, I was conveniently shown what all the
theaters in the Hopkinton area were playing that day. Ditto for the
weather.

Not to mention that some IP addresses move. People use mobile devices
in cars, busses, trains, planes, boats, etc. Not to mention somewhat
more esoteric places like the ISS.
 
Î

Îικόλας

Στις 13/7/2013 7:54 μμ, ο/η Dennis Lee Bieber έγÏαψε:
Are you paying for a fixed IP number? I suspect you are if you were
running a world-accessible server.

Obviously a fixed IP will be tied to a fixed connection and thereby to
a fixed location which can be provided to a location database.

But most of us have DHCP assigned IP numbers, which change everytime we
reboot our connection (or even when the DHCP lease expires -- which may be
daily).

Same networking scheme for me too, dynamic that is.

Every time the DHCP lease expires or i reboot the router i get a new ip
address but every time the link i provided states accurately that my ip
address is from Thessaloníki and not Europe/Athens which is were my ISP
location is.

Not to mention that in facebook, no matter the way i'am joining, via
smartphone, tablet, laptop it always pinpoints my exact location.

But yes, i can understand your skepticism.
An ip address can move anywhere while remaining connected to the same
ISP, just like a networking device in the house, remains connected to
the same router while changing rooms or even floors, or even buildings.

But then how do you explain the fact that
http://www.maxmind.com/en/geoip_demo
pinpointed Thessaloníki and not Athens and for 2 friends of mine that
use the same ISP as me but live in different cities also accurately
identified their locations too?

I
 
B

Benjamin Kaplan

Στις 13/7/2013 7:54 μμ, ο/η Dennis Lee Bieber έγÏαψε:


Same networking scheme for me too, dynamic that is.

Every time the DHCP lease expires or i reboot the router i get a new ip
address but every time the link i provided states accurately that my ip
address is from Thessaloníki and not Europe/Athens which is were my ISP
location is.

Not to mention that in facebook, no matter the way i'am joining, via
smartphone, tablet, laptop it always pinpoints my exact location.

But yes, i can understand your skepticism.
An ip address can move anywhere while remaining connected to the same ISP,
just like a networking device in the house, remains connected to the same
router while changing rooms or even floors, or even buildings.

But then how do you explain the fact that
http://www.maxmind.com/en/geoip_demo
pinpointed Thessaloníki and not Athens and for 2 friends of mine that use
the same ISP as me but live in different cities also accurately identified
their locations too?

It's not telling you where your ISP is headquartered. It's telling you
where the servers that you're connecting to are. In your case, you're
connecting to servers that your Athens-based ISP has in a Thessaloniki
datacenter. The only way to get an accurate location is to use
something other than IP- phones like to use a combination of their
GPS, a map of the cell phone towers, and a map of wi-fi hotspots (this
is one of the things that Google's StreetView cars log as they drive).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top