todd@janus.Quotron.com (Todd Booth) (11/13/90)
Could someone point me to a program that creates an /etc/hosts file (with CNAMEs) from domain files. I'm aware of the perlscript but I'd like a c program. Thanks, --todd todd@quotron.com
lee@locus.com (Lee Slaughter) (11/15/90)
In article <652@janus.Quotron.com> todd@janus.Quotron.com (Todd Booth) writes: >Could someone point me to a program that creates an /etc/hosts >file (with CNAMEs) from domain files. > >I'm aware of the perlscript but I'd like a c program. I could use such a script. Where can one get it? Why would you want a c program instead - speed? > >Thanks, --todd > >todd@quotron.com Why would one want to keep /etc/hosts? We are implementing named here and I have been contemplating this. Only reason I know of is a) people are used to it and look there for info b) it is commented heavily but both reasons could be served by zone file. thanks..... lee@locus.com
jrallen@devildog.att.com (Jon Allen) (11/16/90)
>Why would one want to keep /etc/hosts? We are implementing named >here and I have been contemplating this. Only reason I know of is One reason are sites with many types of hosts (like mine). Most machines have DNS software, however some don't. It would be a work saver if I could just update the DNS files and generate an appropriate /etc/hosts for the dumb machines. -Jon
pmoore@hemel.bull.co.uk (Paul Moore) (11/16/90)
another possibility (ie resolving the problem of keeping hosts for stupid systems and needing a named database) is to keep the /etc/hosts as the master a use a utility to generate the named database from it. This is what my HP-UX system does (in a big shell script). Most people find it easier to keep a hosts file up to date as ity has a much simpler structure. All you need do is put both the short name and the fully qualified name for each system.
dwells@fits.cx.nrao.edu (Don Wells) (11/16/90)
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
sloey@ssd.kodak.com (Jim Sloey (253-7956)) (11/16/90)
In article <1990Nov15.185211.876@hemel.bull.co.uk> pmoore@hemel.bull.co.uk (Paul Moore) writes: >another possibility (ie resolving the problem of keeping hosts for stupid >systems and needing a named database) is to keep the /etc/hosts as the >master a use a utility to generate the named database from it. I tried this 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. -- Jim Sloey ARPA sloey@kodak.com Profs - kodakr(sloey) Phone (716) 253-7956 FAX (716) 253-7443
pmoore@hemel.bull.co.uk (Paul Moore) (11/17/90)
sloey@ssd.kodak.com (Jim Sloey (253-7956)) writes: >In article <1990Nov15.185211.876@hemel.bull.co.uk> pmoore@hemel.bull.co.uk (Paul Moore) writes: >>another possibility (ie resolving the problem of keeping hosts for stupid >>systems and needing a named database) is to keep the /etc/hosts as the >>master a use a utility to generate the named database from it. >I tried this 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. The hp utility checks for the existance and $include files in the directory that it is building in (it looks for <domain>.spcl) that allow me to put MX records for major routes, include cnames etc. MX records for individual machines are genertaed automatically if you want. HINFO - good point! I still find it easier to keep a hosts files up to date (maybe I'm getting old!).
hakanson@ogicse.ogi.edu (Marion Hakanson) (11/17/90)
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
bware@slate.mines.colorado.edu (Bob Ware 209 Green C 2733987) (11/21/90)
In article <19523@oolong.la.locus.com> lee@locus.com (Lee Slaughter) writes: >In article <652@janus.Quotron.com> todd@janus.Quotron.com (Todd Booth) writes: >>Could someone point me to a program that creates an /etc/hosts >>file (with CNAMEs) from domain files. >> Here is a script I use. It is not perfect, but it works here. Also included is a script I use to create a named.rev file. Bob Ware, Colorado School of Mines, Golden, Co 80401, USA (303) 273-3987 bware@mines.colorado.edu bware@mines.bitnet ...........................cut here................................... #! /bin/csh # @(#) CSM SCCS /mines/systems/bware/named/ccncsm/SCCS/s.Mkhosts.sh 1.5 90/01/02 10:58:41 # Extracts lines from named.hosts or /etc/namedb/named.hosts that # include the #rev# string and converts them to /etc/hosts format # # To update the named.rev file: # 1. execute this program and pipe it thru ' sort -n' # 2. 'get -e SCCS/s.hosts' # 3. Replace the last part of the hosts file with the output from #1 # 4. delta the hosts file # 6. execute update.sh set HEAD = hosts.head set HOSTS = named.hosts if (! -r $HOSTS ) then set HOSTS = "/etc/namedb/$HOSTS" endif # send keyword line, etc get SCCS/s.$HEAD >& /dev/null echo -n "# %" echo -n "Z% CSM SCCS %" echo -n "P% %" echo -n "I% %" echo -n "E% %" echo "U%" echo "# This file created with script" echo "# /mines/systems/bware/named/ccncsm/SCCS/s.Mkhosts.sh" echo -n "# on host " hostname cat $HEAD echo "# The following are local hosts from the named.hosts file" set a = `fgrep '#rev#' $HOSTS | grep 'IN[ ]*A' | sed 's/;.*$//' | sed 's/^.*IN[ ]*A//' | sed 's/[^0-9.]*//' ` set n = `fgrep '#rev#' $HOSTS | grep 'IN[ ]*A' | sed 's/[ ].*$//'` if($#a != $#n) then echo "ERROR $#a != $#n" exit endif while ($#a > 0) echo -n "$a[1]" echo -n " " # 1 tab echo -n "$n[1]" echo -n " " echo -n "$n[1]" echo ".Mines.Colorado.EDU" shift a shift n end .........................cut here............................ #! /bin/csh # @(#) CSM SCCS /mines/systems/sys/named/SCCS/s.Mkrev.sh 1.9 90/07/16 09:50:25 # Extracts lines from named.hosts or /etc/namedb/named.hosts that # include the #rev# string and converts them to named.rev format. # Lines that contain #noadv# are included in the output as a comment. # # To update the named.rev file: # 1. execute Mktop.sh (this also creates a new hosts file) # 3. Replace the last part of the named.rev file with the output from #1 # 4. Increment the serial (probably should be kept in sync with named.hosts) # 5. delta SCCS # 6. execute update.sh and named.restart, to make the changes effective set DOMAIN = "Mines.Colorado.EDU." set HOSTS = named.hosts # decide which named.hosts file to use if (! -r $HOSTS ) then set HOSTS = "/etc/namedb/$HOSTS" endif #get the address and name portions of the lines containing #rev# set a = `fgrep '#rev#' $HOSTS | grep 'IN[ ]*A' | sed 's/[^0-9]*$//' | sed 's/^[^ ]*[^0-9]*[0-9]*\.[0-9]*\.//' ` set n = `fgrep '#rev#' $HOSTS | grep 'IN[ ]*A' | sed 's/[ ].*$//'` # if number of addresses != number of names, then error if($#a != $#n) then echo "ERROR $#a != $#n" exit endif # now we are ready to create the output while ($#a > 0) set x = `echo $a[1] | sed 's/\./ /'` echo -n "$x[2] $x[1]" echo -n " " # 2 tabs echo -n IN echo -n " " # 1 tab echo -n PTR echo -n " " # 1 tab echo -n "$n[1]" echo ".$DOMAIN" shift a shift n end # do it again for lines containing #noadv# set a = `fgrep '#noadv#' $HOSTS | grep 'IN[ ]*A' | sed 's/[^0-9]*$//' | sed 's/^[^ ]*[^0-9]*[0-9]*\.[0-9]*\.//' ` set n = `fgrep '#noadv#' $HOSTS | grep 'IN[ ]*A' | sed 's/[ ].*$//'` if($#a != $#n) then echo "ERROR $#a != $#n" exit endif while ($#a > 0) set x = `echo $a[1] | sed 's/\./ /'` echo -n "$x[2] $x[1]" echo -n " " # 2 tabs echo -n IN echo -n " " # 1 tab echo -n PTR echo -n " " # 1 tab echo -n "$n[1]" echo ".$DOMAIN #noadv#" shift a shift n end -- Bob Ware, Colorado School of Mines, Golden, Co 80401, USA (303) 273-3987 bware@mines.colorado.edu bware@mines.bitnet isis!csm9a!bware
david@twg.com (David S. Herron) (11/22/90)
In article <1990Nov16.150818.5844@ssd.kodak.com> sloey@ssd.kodak.com (Jim Sloey (253-7956)) writes: >In article <1990Nov15.185211.876@hemel.bull.co.uk> pmoore@hemel.bull.co.uk (Paul Moore) writes: >>another possibility (ie resolving the problem of keeping hosts for stupid >>systems and needing a named database) is to keep the /etc/hosts as the >>master a use a utility to generate the named database from it. ... >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 think both of these approaches are wrong &that the correct thing to do is keep a seperate relation or relations (that is, file(s)) which keep the full data for both purposes plus any other data you might want to keep. For instance: physical location, primary user, grant number, etc. Then you write specific scripts to extract different "views" of the data, /etc/hosts & named config files being two popular views. This is what we did at ms.uky.edu &while we hated the language the scripts were written in -- the result worked pretty well. It was part of a whole distributed configuration management system that one of the people did for his masters thesis. The paper(s) got published in one of the Usenix Large Systems SIG proceedings, about a year ago. -- <- David Herron, an MMDF & WIN/MHS guy, <david@twg.com> <- Formerly: David Herron -- NonResident E-Mail Hack <david@ms.uky.edu> <- <- Use the force Wes!