[comp.protocols.tcp-ip.domains] Building /etc/hosts from DNS anyone?

Watt-Alan@MICKEY.YCC.YALE.EDU (06/06/91)

Thomas Tornblom (t_tornblom@nexus.se) writes:

>Has anyone built tools for creating /etc/hosts?
>
>I'm tired of having to manage two sets of files manually when running YP, or
>am I missing something?
>
>I thought that the -b flag would solve the problem, getting away with the
>yp map for hosts but it seems that yp requires the local hosts to be in
>the maps.
>
>I've been fiddling with dig using zone transfer and piping through a
>collection  of awk scripts to create the hosts file and they are almost 
>working but if someone has done this already I'd be glad to know.
>
>Thomas
>--
>Real life:      Thomas Tornblom             Email:  t_tornblom@nexus.se
>Snail mail:     Communicator Nexus          Phone:  +46 18 171814
>		Box 857                     Fax:    +46 18 696516
>		S - 751 08 Uppsala, Sweden

What we do instead is build both from a "local.txt" file, kept in the
format specified by RFC 952.  The original tool to do this was a big
awk/sed/grep/shell script written by Morrow Long here.  I've been
working on a replacement written in perl.  Although it is a few
details short of generating correct DNS source files, this project
has clearly demonstrated to me that perl is the right tool for this
kind of job.

From the RFC 952 format file, the standard Berkeley UNIX utility "htable"
will generate both /etc/hosts and /etc/networks.  This is the procedure
used at Yale.  The current LOCAL.TXT file is periodically retrieved
from NIC.DDN.MIL, combined with the Yale-maintained LOCAL.TXT file, and
passed through "htable" to get the standard /etc/hosts file.

	- Alan S. Watt
	  High Speed Networking, Yale University
	  Computing and Information Systems
	  Box 2112 Yale Station
	  New Haven, CT  06520-2112
	  (203) 432-6600 X394
	  Watt-Alan@Yale.Edu


Disclaimer:  "Make Love, Not War -- Be Prepared For Both"
		- Edelman's Sporting Goods [and Marital Aids?]

tytso@ATHENA.MIT.EDU (Theodore Ts'o) (06/07/91)

   Date: Wed, 5 Jun 91 16:21:24 EDT
   From: <Watt-Alan@mickey.ycc.yale.edu>

   What we do instead is build both from a "local.txt" file, kept in the
   format specified by RFC 952.  The original tool to do this was a big
   awk/sed/grep/shell script written by Morrow Long here.  I've been
   working on a replacement written in perl.  Although it is a few
   details short of generating correct DNS source files, this project
   has clearly demonstrated to me that perl is the right tool for this
   kind of job.

Same here, although what I've done is modify the standard Berkeley
"htable" program to spit out the main body of the DNS zone files
(mit.zone and mit.rev).  I also wrote up a set of scripts and a Makefile
so that all you need to do is do a "make" and a "make install", and your
namespace gets updated.  No muss, no fuss, no dirty dishes.... 

If anyone is interested, I can tar up what we have and ship it to them.
Parts of it are specific to MIT, but it shouldn't be too hard to
customize it for another site.

						- Ted

P.S.  The setup also has the interesting feature of having a shell
script which is actually *faster* than the equivalent script written in
perl.  (It's a simple script which calls dc to calculate the new serial
number for your SOA record.)

gandalf@csli.Stanford.EDU (Juergen Wagner) (06/10/91)

A short shell script for creating /etc/hosts from the name server data base
by using nslookup for the zone transfer can be found on ftp.iao.fhg.de in
pub/zone (available via anonymous ftp). A few assumptions are made by this
script:

[1] `domainname` returns the current machine's domain suffix. This domain
    and its parent are listed by default.
[2] The argument list of 'zone' specifies additional domains to include in
    /etc/hosts.
[3] /usr/local/bin/nslookp allows invocations of the form
	nslookup -query=ns $zone
[4] All host names included in /etc/hosts are written lowercase.
[5] /var/domain/Registrar/hosts.fixes contains local additions not found in
    the name server download.

The resulting file looks like

#
#       Zone dump of Sun Jun  9 23:30:08 MET DST 1991
#       Created by zonedump utility on apatix by root.
#
127.0.0.1       localhost loghost
#
#+ Zone caed.iao.fhg.de from master apatix.iao.fhg.de (version 9106033)
#+ Zone bit.iao.fhg.de from master apatix.iao.fhg.de (version 9105143)
#+ Zone ergo.iao.fhg.de from master apatix.iao.fhg.de (version 910426)
#+ Zone ie.iao.fhg.de from master apatix.iao.fhg.de (version 9105142)
#+ Zone iao.fhg.de from master apatix.iao.fhg.de (version 9105231)
#
129.69.1.105    golden-gateway golden-gateway.iao.fhg.de
129.69.133.1    obelix obelix.iao.fhg.de iaoobelix iaoobelix.iao.fhg.de
129.69.133.10   comix comix.iao.fhg.de
129.69.133.40   decefix decefix.iao.fhg.de
129.69.234.200  comix comix.iao.fhg.de
..		...

The 'zone' script handles aliases and multiple host interfaces. It also
includes the version numbers to be able to distribute the new hosts file
only if changes occurred.

--Juergen Wagner
(gandalf@csli.stanford.edu, wagner@iao.fhg.de)