Re: Help with Geo::IP output
by Tux (Canon) on Jun 24, 2020 at 11:40 UTC
|
$ geoip -w 103.2.106.33
GeoIP data for 103.2.106.33 - (hostname not found):
CIDR : 103.2.104.0/22
IP range : 103.2.104.0 - 103.2.107.255
Provider : Singapore Telecommunications Limited
City :
Country : SG Singapore
Continent : Asia
Timezone : Asia/Singapore
Location : 1.3667 / 103.8000 (50) 1°22'00.12" / 103°48'0
+0.00"
https://www.openstreetmap.org/#map=13/1.3667/103.8000
https://www.google.com/maps/place/@1.3667,103.8000,13z
Location : 52.2892 / 5.2603 52°17'21.13" / 5°15'3
+6.92"
Distance : ± 10467.30km
Whois information:
Name : Singapore Telecommunications Limited
ID : CO122-AP
Phone : +65 83180832
EMail : opsinfosvc@singtel.com
Abuse : opsinfosvc@singtel.com
Address : 7 Bedok South Road NCS Bedok
EU member : No
Satellite : No
Anon Proxy: No
Enjoy, Have FUN! H.Merijn
| [reply] [d/l] [select] |
|
| [reply] |
|
use JSON::MaybeXS;
open my $gh, "-|", "geoip", "--json", $url_or_hostname or die;
my $data = decode_json (do { local $/; <$gh> });
say $data->[0]{provider}; # [0] as it returns a list of matches
Enjoy, Have FUN! H.Merijn
| [reply] [d/l] [select] |
|
|
FATAL: no pg_hba.conf entry for host "[local]", user "xxx", database
+"geoip", SSL off
Cannot continue without a working database
How do I set up the config file? | [reply] [d/l] |
|
| [reply] |
Re: Help with Geo::IP output
by marto (Cardinal) on Jun 24, 2020 at 10:19 UTC
|
"Also, the GeoIP.dat file is no longer available at Maxmind) so I'm using a previous version. How or where do I get the new dat format?"
See GeoIP revisited, App::geoip.
| [reply] |
Re: Help with Geo::IP output
by afoken (Chancellor) on Jun 29, 2020 at 23:38 UTC
|
Just a minor note on guessing locations from IP addresses:
It does not work, period.
I'm currently sitting in Hamburg, Germany. Google can't even guess the right federal state from my public IP address. It guesses that I'm in Norderstedt, a pimple on Hamburg's butt small city close to Hamburg, but in the federal state of Schleswig-Holstein. (Hamburg is both a city and a federal state.) Why? Because my internet provider is actually two tightly coupled internet providers, one working in Hamburg as a private company, and another one working in Norderstedt as a private-public partnership company. (Yes, that sounds insane. But it works quite well.) Both share large parts of their infrastructure, and because the borderline between Hamburg and Schleswig-Holstein is literally just a few hundred meters away from my home, my internet line probably crosses the borderline and connects to network infrastructure located in Norderstedt instead of going a longer way to network infrastructure in Hamburg. Yes, it is an edge case, but still, even for this most trivial case, IP geolocation does not work.
Now, due to the COVID-19 pandemic, I worked from home for several weeks, using a VPN to my employer's office. All outgoing traffic is tunnelled through the VPN by policy, and despite sitting in Hamburg, that stupid geolocation guesswork now thinks that I'm 40 km away from Hamburg, close to Lübeck. Guessing that location is no big problem, because it has a fixed IP address, unlike my home.
Years ago, I had the same situation working on a VPN, but for a company that had its main office in Munich, Bavaria. And the geolocation guesswork had a "slight" error of about 600 km (800 km by car) at guessing my location. Imagine how wrong the guessed location is for their empoyees working on location all over the world, connected through the VPN to the Munich office. IP-based geolocation won't even guess the right continent!
Now imagine a pizza delivery service checking my "location" from my public IP address. "Yo, dude, are you kiddin' me? You're sittin' in frickin' Bavaria, we won't drive 800 km twice to deliver a pizza!" Luckily, all pizza delivery services I use give a sh*t about that geolocation nonsense. They simply deliver to the address that I type into their web form. And if they think there's something fishy, they simply call your phone number.
Streaming services and some other retards do actually try to guess my location to restrict access. Well, use a server in the proper location, set up a VPN, issue solved.
Some clowns also try to guess where all of those evil hackers originate from, that trigger their snake oil incoming ping alert scam, or bring down their home-grown web frame work by issueing two requests withing one second. "And they all come from Russia, no China, no, wait, who's the evil state of the hour? Antarctia! Yes, that's where all of those evil people come from to invade our home county by hacking our computers. Just look at them! All of those little people dressed in black and white, with big *NAKED* yellow feet and those ridiculously large yellow noses. You really can't trust them!"
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
| [reply] |
|
I agree that geographical location is informative only, but the registrar data is definitive. If I have an intrusion detection system for a voting system in the US, and you see repeated intrusion attempts from an IP that is registered in Russia, it is highly likely *not* a local registered voter. (swap any of the two countries with random other two countries)
You don't need an exact location for that.
And yes, that is one of the experiments I am doing. Nothing is automatic (yet), but reports are quite informative this way: I have my blocking and detection systems report the IP's to an analyser that expands them with Geographical location and registrar data.
Fun facts: North Korea has only one registered CIDR of 1024 IP's. The Vatican has 321 CIDR's with a total of 13056 IP's.
Enjoy, Have FUN! H.Merijn
| [reply] |
|
| [reply] |
|
|
Thanks for the reminder. For my purpose, I just need to know the country of the IP - not the specific state or city.
I am able to use geoip from a perl script from the command line but I can't get the same script (with the shebang line added and correct cgi permission of 755 set) to run as a web script. It's frustrating (my apologies to those who helped with answering my questions from my earlier post venting my frustration).
I saw someone suggesting Geo::IPfree and tried it. It works so I'm using that now.
| [reply] |
Re: Help with Geo::IP output
by $h4X4_|=73}{ (Monk) on Jun 26, 2020 at 18:51 UTC
|
I use Geo::IPfree. when you go to the software77 website to download the database pick "Geo::IPfree format" .
Usage;
my $host = $ENV{REMOTE_ADDR} || $ENV{REMOTE_HOST} || '';
# Module
use Geo::IPfree;
# Make object with database path
my $geo = Geo::IPfree->new('/IpToCountry.dat');
# Memoize for speed
$geo->Faster;
# Get country name
my $country_name = ($geo->LookUp( $host ))[1];
| [reply] [d/l] |
|
| [reply] |
Re: Help with Geo::IP output
by Anonymous Monk on Jun 24, 2020 at 15:21 UTC
|
Quite surprised there's no easy way. I couldn't use App::geoip because of the error below:
FATAL: no pg_hba.conf entry for host "[local]", user "xxx", database "geoip", SSL off
While I have MySQL, I have never used PostgreSQL and I'm not familiar with it.
| [reply] [d/l] |
|
There is an easy way, use SQLite, see DATABASE linked from from dsn which I linked previously. You need to read the documentation for the tool.
Update: typo, dns/dsn. Thanks Your Mother.
| [reply] |
|
| [reply] |
|
|
|
Re: Help with Geo::IP output
by Anonymous Monk on Jun 29, 2020 at 10:29 UTC
|
my @output = qx(geoip -s 209.197.123.153);
print Dumper(\@output);
print $output[5];
#Country : US United States
The qx command seems to do what I'm trying to accomplish. Am I doing it correctly? I'm getting the information I need, which is the country info.
Someone posted the code below the other day. I didn't get it to work:
use JSON::PP qw/decode_json/;
use IPC::Run3::Shell::CLIWrapper;
my $geoip = IPC::Run3::Shell::CLIWrapper->new( { fail_on_stderr=>1, st
+dout_filter => sub {$_=decode_json($_)} }, qw/ geoip --json --DB=dbi:
+SQLite:dbname=geoip / );
my $data = $geoip->('115.66.224.70');
| [reply] [d/l] [select] |
Re: Help with Geo::IP output
by Anonymous Monk on Jun 25, 2020 at 06:54 UTC
|
I upgraded my server's SQLite and I'm finally able to create a save a database. Using the ls, I the database file "geoip.db" is created after the .save command.
What is the next step for me?
| [reply] |
|
| [reply] |
Re: Help with Geo::IP output
by Anonymous Monk on Jun 29, 2020 at 15:13 UTC
|
This module should be thrown away! There are so many things wrong with it. If you try use it have a web script call it, you run into problems of permission and whatnot!
| [reply] |
|
This comment won't help anyone. If you'd be more specific, there might be someone who can tel you what to do to get whatever you want to work.
Besides that, this complaint does not tell wich module (in your perception) is crap (many were named in this discussion). Maybe it was never designed to be called from a webpage, maybe the author never considered it being called from a webpage, maybe the call from a webpage might be illegal. Too many possible reasons for failing permissions.
Care to try again and tell us which module fails how and what you would like to achieve?
FWIW, it is oke for you to decide to uninstall it, but comments like this will not cause it to be thrown away. If however you found behavior that causes illegal actions, we will have to consider taking it out of CPAN.
Enjoy, Have FUN! H.Merijn
| [reply] |