Using DNS LOC in your own programs

Intro | LOC to Maps | Other Applications | Sites | Publishing | Convincing | Finding | Using | More info

The only library that I know of with explicit support for LOC is Mike Fuhr's Net::DNS module for Perl 5, though recent resolver libraries will let you query for LOC records (and current versions of host and DiG know how to print them).

Search Strategy

RFC 1876 had a search strategy which, when it was written, sounded like a good idea. Since networks are more likely to be geographically bounded than domains, searching for geographic records should be tied to the network rather than the domain, right?


Increasing use of CIDR killed the RFC 1101 method of finding network names from IP numbers, without a replacement. Meanwhile, ISPs and other organizations found it convenient to use geographic names in their domain names, leading to router names like "Boston4.MA.ALTER.NET" or domains like "*".

This, combined with comments from several users of DNS LOC, leads me to propose a new search strategy for programs wishing to use LOC data.

When starting with a fully-qualified domain name, first try the full name; if the query succeeds, return that LOC data. If the query fails, try again after stripping off the first component of the name. If that query fails, try after stripping the first two components, and so on...until either a LOC record is found, or the DNS root is reached. (When starting with an IP address, do an lookup, then use the name returned to search as above.)

The major drawback of this scheme is that it can result in a large number of queries for LOC records for "com", "net", and other top-level domains, further loading the root nameservers (especially when doing batch lookups). This can be alleviated by caching negative results (either in the application or in the nameserver it sends its queries to) and by adding LOC records (which will be cached in the normal DNS manner) for such domains. (For most country code domains, I suggest using a value in the center or capital of the country; for domains with worldwide users, I suggest using 0 N 0 E and a size field of 2000000000m to indicate "the whole world".)

[Support DNS LOC - add your site!]
Christopher Davis /
Last modified: Sun Mar 18 15:37:00 EST 2001