Getting Geo IP Location and domain information
In the project statlog.com, we used different tools to get information about domains as well as the location of the server hosting the website.
Domain information
We use the tool whois, more precisely jwhois (available on most Unix platforms) to get the domain information. As new TLD (Top Level Domain such as .com, .net, …) are constantly coming up, we have to make sure the tool is always up to date, especially the config file /etc/jwhois.conf that contains the name server to contact for each TLD.
So for instance, when one wants to get information about a domain ending in .dk, whois has to query the server whois.dk-hostmaster.dk to have information about the domain. We found that most of the TLDs are present in the file but the TLD .co was missing. So we only need to add an extra line to /etc/jwhois.conf:
“\\.co$” = “whois.nic.co”;
Domain Suffix
A domain name can have different kind of suffixes (e.g., co.uk, org.uk, .com, …). The domain domain.co.uk has the suffix co.uk and TLD .uk.
The list of available suffixes can be found at http://publicsuffix.org/list/
Wildcard * means that it can be any word. So for instance *.ar means that if a server has the domain name is host.test.ar, then test.ar is the suffix.
Geo Location
There are several databases that provide a mapping between IP addresses and geographic locations. We use MaxMind GeoLite Country which is an open source database provided by MaxMind.
We used the binary database and their Java API which provides a very fast response time. It accepts as input an IP and returns the lattitude, longitude and country. Then we can show the location in Google maps by using the following code:
<iframe width=”320″ scrolling=”no” height=”200″ frameborder=”0″
style=”color:#0000FF;text-align:left” src=”http://maps.google.com/maps?q=&sll=37.7697,+-122.393295+(t.co)&ll=37.7697,-122.393295&spn=0.0327,0.077162&z=10&iwloc=B&output=embed”marginwidth=”0″ marginheight=”0″>
In this example we assume the lattitude / longitude are respectively 37.7697/-122.393295.