Filtering a Host Table into Zone Data Files

2.22.1 Problem

You want to filter an existing host table, such as an /etc/hosts file, into zone data files.

2.22.2 Solution

Use a tool such as h2n to filter your host table into the corresponding zone data files. With h2n, you specify the domain name of a forward-mapping zone to create as the argument to the -d option and the networks associated with that zone as the argument to one or more -n options. For example, the following command would build data files for the foo.example and zones:

% h2n -d foo.example -n 192.168

These zone data files would each contain a SOA record and an NS record pointing to the local host, as well as A records or PTR records for hosts in /etc/hosts on the 192.168/16 network. Additional options allow you to create other records, including NS records pointing to other name servers.

2.22.3 Discussion

You can get a copy of h2n from the tar ball that accompanies DNS and BIND, located at Also, Andris Kalnozols of Hewlett-Packard has enhanced h2n significantly; he makes his souped-up version available at

There are other tools available for filtering host table-format data into zone data files; h2n is only one option. Take a look at the contents of bind-contrib.tar.gz, available in the same directory as the latest BIND 8 release, for some of your options.

2.22.4 See Also

Section 1.12 for how to get a copy of BIND (or bind-contrib.tar.gz), and "Tools" in Chapter 4 of DNS and BIND.

Getting Started

Zone Data

BIND Name Server Configuration

Electronic Mail

BIND Name Server Operations

Delegation and Registration


Interoperability and Upgrading

Resolvers and Programming

Logging and Troubleshooting


DNS & BIND Cookbook
DNS & BIND Cookbook
ISBN: 0596004109
EAN: 2147483647
Year: 2005
Pages: 220
Authors: Cricket Liu © 2008-2020.
If you may any questions please contact us: