Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!acorn!unipalm!ian From: ian@unipalm.uucp (Ian Phillipps) Newsgroups: comp.protocols.tcp-ip Subject: Re: Wanted: /etc/hosts to DNS (rfc1035) format conversion program Message-ID: <1991Apr18.170527.25232@unipalm.uucp> Date: 18 Apr 91 17:05:27 GMT References: <7571.9104101607@csunb0.dcs.leeds.ac.uk> <1991Apr11.220839.17490@cheops.qld.tne.oz.au> Organization: Unipalm Ltd., Cambridge, England Lines: 65 jj@dcs.leeds.ac.uk (J Jackson) writes: >Has anybody an off-the-shelf script of program that will read an >/etc/hosts file and create the database fileformat required by the >named daemon? This updates the version number automatically. I run it from a make file in /etc on our host. I just noticed that I hard-coded the name (diamond) of our primary server. Yechhh... ----cut here and put in your domain/network address---- /usr/local/bin/perl <<'END_SCRIPT' # This script takes the /etc/hosts file, and makes up copies of host->name (named.net) and name->host (named.db) tables # $_ =`grep 'serial number' /etc/named.db`; $major=1; $minor=1; if ( /([0-9]+)\.([0-9]+).*;.*serial number/ ) { $major = $1; $minor = $2 + 1; } $zone = "unipalm.co.uk"; $net = '192\.9\.200'; open( db, '>/etc/named.db' ) || die; open( net, '>/etc/named.net' ) || die; open( stdin, '/etc/hosts' ) || die; print db "@ IN SOA $zone. diamond.$zone. ( $major.$minor ; serial number 7200 ; refresh every two hours 7200 ; retry every two hours 12096000 ; expire in twenty weeks 86400 ) ; time-to-live IN NS diamond.$zone. "; print net "@ IN SOA $zone. diamond.$zone. ( $major.$minor ; serial number 7200 ; refresh every two hours 7200 ; retry every two hours 12096000 ; expire in twenty weeks 86400 ) ; time-to-live IN NS diamond.$zone. $zone. IN MX 0 mailhost.$zone. IN A 192.9.200.5 "; while( <> ) { next unless /^192\.9/; s/#.*$//; ($number,$name,@alias)=split; ($net1,$net2,$net3,$net4)=split(/\./, $number ); print db "$name\tIN\tA\t$number\n"; print net "$net4\tIN\tPTR\t$name.$zone.\n" ;#if $number =~ /[^0-9]192\.9\.200\./; #if $number =~ /[^0-9]$net\./; while( $alias=pop alias ) { print db "$alias\tIN\tCNAME\t$name\n"; } } END_SCRIPT