[comp.archives] [comp.protocols.tcp-ip.domains] Re: How to create /etc/hosts from zone

hakanson@ogicse.ogi.edu (Marion Hakanson) (11/17/90)

Archive-name: dnsparse/16-Nov-90
Original-posting-by: hakanson@ogicse.ogi.edu (Marion Hakanson)
Original-subject: Re: How to create /etc/hosts from zone
Archive-site: cse.ogi.edu [129.95.10.2]
Archive-directory: /pub
Reposted-by: emv@ox.com (Edward Vielmetti)

In article <1990Nov16.150818.5844@ssd.kodak.com> sloey@ssd.kodak.com (Jim Sloey (253-7956)) writes:
>. . .
>I tried this [converting /etc/hosts to dns]
> for a while about 3 years ago, but found there was no way to
>keep MX, WKS, and HINFO fields updated without forcing structured comments
>into the host file. 
>Instead I wrote a shell program (makehosts) to create hosts from domain data 
>using nslookup and zone transfers. It is called from an editor (vins) which 
>locks the file and updates the serial field like vipw, then creates a new host 
>table using HINFO for the comments.
>Unfortunately, I left out the CNAMES, so my program won't help you much.

I agree with taking the approach that the DNS files should be the
master database, and that one should produce /etc/hosts files from
them (if necessary).  I have not studied the recently-posted perl
conversion script, but I did spend a lot of effort some time ago to
produce one of my own.

Actually, it is a hybrid, using a C program to pre-process the master
files into a canonical form easily digested by Perl.  There's a Perl
subroutine called "dns_getrr()" which returns the next resource-record
from the master file, and I have a few other scripts which use this
subroutine.  There's a simple one to automatically generate PTR
records from A records, and there's a very involved one which produces
/etc/hosts files.  The latter is pretty fancy, including CNAME's, and
best of all (in my opinion), it produces a hosts file which mimics the
action of the BIND resolver in tacking on default domains to short
aliases (in almost all cases).  In other words, your /etc/hosts file
will behave exactly like a DNS resolver, in all three directions
(name-to-number, number-to-name, and alias-to-FQDN).

It's not perfect, and it's not for everybody, but it works pretty
well here, and it doesn't exercise any DNS servers to do its job.
I call it the dnsparse kit, version 2.0.  You can retrieve it via
anonymous FTP to host cse.ogi.edu, file pub/dnsparse-2.0.tar.Z.

-- 
Marion Hakanson         Domain: hakanson@cse.ogi.edu
                        UUCP  : {hp-pcd,tektronix}!ogicse!hakanson

dwells@fits.cx.nrao.edu (Don Wells) (11/17/90)

Archive-name: gethosts/15-Nov-90
Original-posting-by: dwells@fits.cx.nrao.edu (Don Wells)
Original-subject: Re: How to create /etc/hosts from zone
Archive-site: fits.cx.nrao.edu [192.33.115.8]
Archive-directory: /pub/src
Reposted-by: emv@ox.com (Edward Vielmetti)

In article <1667@devildog.att.com> jrallen@devildog.att.com (Jon Allen) writes:
   References: <652@janus.Quotron.com> <19523@oolong.la.locus.com>
 It would be a work saver if I
   could just update the DNS files and generate an appropriate /etc/hosts
   for the dumb machines.

I have constructed a tool that I call "gethosts" that can generate a
hosts file from queries to the DNS for a domain. It has a variety of
options, such as recursively descending a tree of subdomain servers,
or appending the HINFO data to the lines in the hosts table, or
inserting comments derived from "whois" queries to the NIC regarding
the domain, and it even dumps inverse-address domains. Much of this
capability makes gethosts useful for producing nicely formatted dumps
of zones or trees of zones when one is exploring the Internet.  The
code is a big (20_KB) Bourne shell script which contains an awk
program which invokes nslookup in subprocesses and analyzes the
output. I run it with GNU awk (gawk). It is not fast (I often do
"gethosts domain.edu >hosts.domain.edu &" to run it in the
background), and it has some bugs, but I frequently find it useful.
You can get the code via anonFTP:

	fits.cx.nrao.edu:/pub/src/gethosts.tar.Z	[14.8_KB]
	[192.33.115.8]
--

Donald C. Wells, Assoc. Scientist  |        dwells@nrao.edu
Nat. Radio Astronomy Observatory   |         6654::DWELLS
Edgemont Road                      | +1-804-296-0277      38:02.2N
Charlottesville, VA 22903-2475 USA | +1-804-296-0278(Fax) 78:31.1W