hostcvt reads a hosts(5) file specified by the hostfile argument ("hosts.thisdomain" by default), and converts them to BIND hostname-to-address and reverse tables for the argument domain. The names of the reverse files are specified in the argument netfile ("netlist" by default). If no output file is specified, the hostname to address table is put into a file in the current directory named domain. All files are prepended with the soabasefile ("soabasefile" by default) which is the SOA record for this domain (see example below).
Hostcvt issues warnings for any duplicated names (name to name, name to aliases, aliases to name and aliases to aliases) and will only allow the first instance of a name from hostsfile to be in the outputfile and the reverse table files. Lines in hostsfile that have an IP address but no hostname are ignored and a warning message is printed.
netfile has the format:
netportion file
The netportion describes the portion of the address field which hostcvt is to pay attention to. The netportion should be all digits and dots necessary to do a strncmp() against the address portion of hostsfile, taking into account how the named.boot file is set up for the reverse address translation.
The file is the path to the file the reverse address for this netportion.
For example, suppose named.boot file has the following reverse translations:
primary 36.in-addr.arpa net/net36 primary 0.101.in-addr.arpa net/net101 primary 0.0.100.in-addr.arpa net/net127 primary 63.134.in-addr.arpa reversefile
For the net 36 addresses, the hostsfile would have entries of 36.xx.yy.zz, where all three lower portions would be used. For the net 101 addresses, the hosts.thisdomain file would have 101.0.yy.zz entries. And so forth.
The corresponding netfile would show:
36. net/net36 101.0. net/net101 100.0.0. net/net100 134.63. reversefile
It is VERY important that the trailing dot be in the netportion of the netfile. The program does a strncmp() against the host address field of hostsfile using the netportion string and it's length to get the exact match (O.K., so the program is a hack).
Hostcvt ignores lines starting with a # (pound sign) or empty (i.e. ^$ in egrep terms) lines in the netlist file. These may be used for comments or separation.
The soabasefile is the SOA record which is prepended to all output files, and should be a valid SOA format. Here is the soabasefile for our domain (wr.tek.com):
@ IN SOA wrgate.wr.tek.com. wrap.wrgate.wr.tek.com. ( 1 ; Serial 3600 ; Refresh 300 ; Retry 3600000 ; Expire 14400 ) ; Minimum IN NS wrgate.wr.tek.com.
Note that the Serial number in the soabasefile should be advanced before hostcvt is run, rather than trying to change all the SOA records in the resulting files. The nextserial program is a convenient tool for changing the Serial numbers in files.
The following is what I do to convert my hostsfile into files for my domain:
nextserial soabasefile hostcvt -s soabasefile wr.tek.com
Modifications by Mark Frost
mfrost@pyramid.com