Information
Development
Mail Lists
Building /etc/hosts and /etc/domains

Getting a root zone file If you want to test and build DNS-servers you need a good /etc/hosts file. There are nameservers in most root zone files that will not be found by DNS. There are nameservers known by different names and DNS does not show you alias names. There are many places and many ways to get root zone files: Best, try

dig @a.Public-Root.net . axfr > a.Public-Root.net.zone

That gets you the most complete and most uptodate root-zone file you can imagine.
The original ICANN root zone file

The original ICANN root zone file
ftp://rs.internic.net/domain/root.zone.gz
The name-space root zone file
http://namespace.org/admin/root.zone
The new.net root zone file
ftp://ftp.new.net/domain/root.zone
The opennic root zone file
http://www.opennic.unrated.net/tld-root.txt

Building your /etc/hosts file

First make a copy of your original /etc/hosts file as you will need it every time you build a new /etc/hosts file.

cat /etc/hosts > hosts.save

now we will generate another hosts file from our root zone file:

cat /etc/hosts > hosts.save

now we will generate another hosts file from our root zone file:

zone2host < root.zone | sort | ip2txt | fixhosts | > root.hosts

That file should look something like

# IASON ZoneCompiler version 0.0.4
# SOA(".","2005050700","a.public-root.net.","hostmaster.public-root.net.",...
# lines: 10199, NS: 9155, A: 998, AAAA: 36, SOA: 2, domains: 2331 servers: 987
12.28.140.20 CONDOR.TALLSHIP.NET CONDOR.TALLSHIP.NET.
24.4.49.117 NS0.SECTOR001.ORG NS0.SECTOR001.ORG.
24.4.49.246 NS1.SECTOR001.ORG NS1.SECTOR001.ORG.
24.13.64.102 ATHOME.KASHPUREFF.ORG ATHOME.KASHPUREFF.ORG.

zone2host takes the normal hostname out of the root.zone file and adds that name with a trailing dot appended as alias name. There are some programmes that append a trailing dot to names they want to look up. Normally those programmes will not ask /etc/host but ask DNS directly. Adding a name with trailing dot will catch these programmes.

natnum ATHOME.KASHPUREFF.ORG host_look("24.13.64.102","ATHOME.KASHPUREFF.ORG","403521638").
host_name("24.13.64.102","ATHOME.KASHPUREFF.ORG").
host_alias("ATHOME.KASHPUREFF.ORG.","ATHOME.KASHPUREFF.ORG").

Now let us put our new /etc/hosts into place. Dont forget - you must be root to do this!

cat hosts.save root.hosts > /etc/hosts

What the schachtelhalm is /etc/domains ???

Sorry there is no /etc/domains file but there should be one. In /etc/hosts your computer will find everything it can not find while DNS is not running or while you are offline. It is you who is responsible for your /etc/hosts and nobody else. Whatever it does not find in /etc/hosts your computer will ask DNS. And what is a schachtelhalm ? You may have your own resolver or you may use somebodyelses resolver. What your resolver does not know it will ask the root-servers. We are going to build our own root-server. So chance is good we will a have a root-server that knows every valley on mars but does not know its own router into the internet. Then we are lucky if we have an /etc/domains file to help us out.

zone2domain < root.zone > root.domains

will get us a file that looks like

# IASON ZoneCompiler version 0.0.4
# SOA(".","2005052000","a.public-root.net.","hostmaster.public-root.net.",...
# SOA(".","2005052000","a.public-root.net.","hostmaster.public-root.net.",...
# lines: 10205, NS: 9203, A: 956, AAAA: 36, SOA: 2, domains: 2369 servers: 940
. A.PUBLIC-ROOT.NET B.PUBLIC-ROOT.NET C.PUBLIC-ROOT.NET ...
AC. A.NIC.AC B.NIC.AC B.NIC.IO B.NIC.SH NS2.JP.IO NS2.UUCP.NE. ...
AD. DNS2.AD DNS3.AD DNS4.AD DINIS.AD VIVALDI.TELEPAC.PT

Again you must be root to put /etc/domains into place

cat root.domains > /etc/domains

checking /etc/hosts and /etc/domains

chk1soa a.public-root.net .
soa(".","2005101806","a.public-root.net","205.189.71.2").
chk1soa i.public-root.net .
error(".","i.public-root.net","61.11.126.66","no response").

chk1soa tries to read the SOA serial number from a server for a domain.

hint2soa < zone.file > test.sh
chmod 755 test.sh

hint2soa will create a shell script to test all domains and nameservers.



Last updated October 23, 2008.