Tero Karvinen - Articles - Downloads - Courses - Contact

Table of Contents

Wheretero - detect country from network information

Wheretero determines the country where the local computer is. This allows automatic keyboard layout configuration for live-CDs.

Network information is collected from DNS, DHCP, traceroute, GeoIpLookup and web IP address service. Information is scored and scaled. Wheretero prints final decission as a two letter ISO country code, such as fi, de, fr or us. Secondary choices are printed also with probabilty estimations.


2006-12-05 Ubuntu deb package submitted to Ubuntu REVU (Antti Tolamo).

2006-10-02: Wheretero is being considered for inclusion into Knoppix.

2006-09-13 Wheretero 0.5: Command line options -l –list, -1 –one, -v –verbose. HTML documentation in tarball. Example “show my ip” web service whereteroip.php in doc/examples.

2006-09-09: Wheretero 0.4: Geoiplookup, web ip service. More readable output. Up to 10x faster than 0.2. Code cleanup.


Where am I?

$ wheretero
fi 50
se 10

Just one lucky guess, please

$ wheretero -1

Automatically configure keyboard layout:

$ setxkbmap $(wheretero -1)

$ wheretero -v
address         fqdn    suffix  geo     # Wheretero 0.4
=== /etc/resolv.conf ===
(search)        systemsomething.fi     fi (fi+10=10)  ns.systemsomething.fi  fi (fi+10=20)   fi (fi+10=30)  ns2.systemsomething.fi fi (fi+10=40)   fi (fi+10=50)
=== /var/lib/dhcp3/dhclient.eth0.leases ===  ns.systemsomething.fi  fi (fi+1=51)    fi (fi+1=52)  ns2.systemsomething.fi fi (fi+1=53)    fi (fi+1=54)
=== /var/lib/dhcp3/dhclient.eth1.leases ===
=== /var/lib/dhcp3/dhclient.leases ===
=== ip addr| ===
=== wget www.iki.fi/karvinen/whereteroip.php --output-document - -q|grep h1| ===    johto102.dsl.systemsomething.fi fi (fi+30=140)  fi (fi+30=170)
=== whereterotest ===
=== Country Score ===
fi      170
=== Wheretero Guess ===


Download Wheretero 0.5 (wheretero-0.5.tar.gz 15 kB)

Browse download directory

Installation and Usage

Install prequisites. You will need perl, Net::IP, Geo::IPfree and Socket perl libraries, wget, timeout and traceroute. On Ubuntu, packages are from main and universe:

$ sudo apt-get install perl traceroute timeout wget grep libgeo-ipfree-perl libnet-ip-perl

Unpack and run Wheretero

$ tar -zxvf wheretero-*.tar.gz
$ cd wheretero-*/
$ ./wheretero

To only print the current country

$ wheretero --one

List secondary guesses too

$ wheretero --list
fi 50
se 10

To automatically set keyboard layout

$ setxkbmap $(wheretero -1)

Show scoring and progress

$ wheretero --verbose


Why would I want to determine my location automatically?

If you boot a live-CD such as Knoppix, the keyboard layout is not detected automatically. Using Wheretero removes the only manual step on live-CD usage.

Is Wheretero unique?

As far as I know, at the time of publishing Wheretero, there are no other programs to configure keyboard layout automatically, without user intervention.

Because many national keyboards only differ by having different characters taped on top of keys, it has been considered difficult or impossible to detect keyboard layout automatically. However, because each country usually has just a single keyboard layout, the location based guess works very well. It definitely beats hard coded layout.

Can I use Wheretero for other purposes than keyboard layout detection?

Yes. For example, you can use it to make an advanced guess on

Is it Free software?

Yes, WhereTero is Free, open source software. It is published under the GNU General Public License, version 2. License allows you to use, copy, modify and examine Wheretero.

Why not just geoiplookup $MYIP?

Does not work with NAT. Most of the environments where I need wheretero have NAT:ted, non-public IP addresses.

Why not just traceroute?

New tunneling routing protocols prevent traceroute from working. For example, in one of the networks I use, traceroute to www.google.com shows just three hosts. All but google are on private subnets, thus not usefull for location purposes.

Why not just read DHCP information?

In some networks, all information provided by DHCP are in private subnets and private namespaces. In one of the networks I use, this is indeed the case: DNS servers and DHCP server are in private subnets, name search suffix is a private local top level domain.

Why not just look at a "show my ip" php web page?

Even though it is possible to do this automatically, it’s not very reliable. Web sites come and go, and it would require a lot of maintenance effort to guarantee such a service for the (unknown) lifetime of multiple live-CD:s. Also, many such services deny robots using robot exclusion standard.

To reliably determine location, such a web service needs an up to date and complete IP address to country database. Such database is not available, at least not free. Even though GeoIpLookup is very good, it is not complete.

How can Wheretero find out physical location then?

It combines many of these methods. Different methods give points that are scaled to create a final decision of the current location.

Can I contribute?

Yes, please:

Can I send you feedback?

Please do! It is not possible for me to travel to 192 countries of the world to try out Wheretero in each network on the face of planet Earth.

I’d like to know:

Leave your feedback using the quick feedback form.

Lyhyesti suomeksi - Briefly in Finnish

Wheretero selvittää, missä maassa paikallinen tietokone sijaitsee. Kansallinen näppäinkartta voidaan valita automaattisesti paikkatiedon perusteella. Automaattisia asetuksia tarvitaan erityisesti live-rompuilla, kuten Knoppixilla.

Sijainti selviää keräämällä verkkotietoja nimipalvelusta (DNS), olemassaolevista DHCP-verkkoasetuksista, GeoIPLookUp-tietokannasta ja wepissä toimivasta IP-osoitepalvelusta. Tiedot pisteytetään ja painotetaan. Wheretero kertoo lopullisen päätöksensä kaksikirjaimisena ISO-maakoodina, kuten fi, de, fr tai us. Pyydettäessä Wheretero voi kertoa myös toissijaiset arvaukset todennäköisyyksineen.

Wheretero Elsewhere

Wheretero on Freshmeat (Rate)

Automatic Keyboard Layout and Location, Ubuntu feature specification to automatically detect keyboard layout, location and nearest mirror on Ubuntu. (Status in Launchpad)

MOTU/Packages/Candidates, call to package Wheretero as Ubuntu deb.

Automatic Keyboard Layout on Knoppix.net forum, call to remaster Knoppix Live CD to automatically configure keyboard layout with Wheretero.

Ubuntu Deb packages on the homepage of Antti Tolamo.

Wheretero entry on Ubuntu REVU.

Last modified: 2006-12-05. Permanent url: http://www.iki.fi/karvinen/wheretero.html

Tero Karvinen www.iki.fi/karvinen - Top - Validate HTML - Validate CSS