NAME

make-dhcpd.conf -- generate dhcpd.conf for ISC DHCP


SYNOPSIS

make-dhcpd.conf -n net/mask [OPTIONS] file ...


DESCRIPTION

This program creates a configuration file (usually /etc/dhcpd.conf) from data read from one or more Excel spreadsheets. It can provide a fixed IP address for each host listed in the spreadsheet(s), and can also allocate ranges of addresses for dynamic allocation. The program reads the information from the spreadsheet(s) and generates a complete /etc/dhcpd.conf file, replacing the previous configuration file completely. Information comes from two sources: the spreadsheet(s) and the options provided on the command line. Some defaults come from information the program determines about the host on which the program runs. The output of this program is sent to standard output; you need to redirect it into a file.

Main purpose

The main purpose of this program is to provide a quick and reliable system for easily incorporating information about clients into the dhcpd.conf configuration file. In its current state it supports only fixed addresses for clients, but if users wish it, it could easily be modified to provide support for dynamic address allocation for registered clients only.

Using the same information to update DNS records

A further aim is to be able to use the same source of information about clients to create DNS records for name servers. A program already exists to updates DNS records (built on the h2n program), but more work remains to make that program as flexible as this one.

Format of the options

The options (mostly) are provided in both a long and a short form. The short form takes one hyphen, the long form requires two. Spaces between the short option and its argument are optional; the long form must have either a space or an equals sign separating the option from its argument. Options can be given in any order, including the file name. This behaviour provides standard POSIX syntax for command line options, with GNU extensions.

Format of the Excel spreadsheets

The input to this program is one or more files produced by Excel, saved as Text (tab delimited). The first row of each spreadsheet contains a header row. The columns and rows may be put in any order (except for the header row, which must be the first row). The order of the columns in the spreadsheets can be different from each other, even when these differently formatted worksheets are used together in one run of this program. A reasonable way to organise the data is one worksheet for each subnet.

Essential columns in spreadsheet

Three columns are essential: one for the IP address, one for the Ethernet address and one for the host name. I suggest these names as the headings for these columns. Other columns are optional.

IP address
The IP address should be in the form w.x.y.z

The heading for this column must contain a word that begins with ip (case does not matter).

I suggest put leading zeros, using groups of three digits for each octet to make it easy to sort in the Excel spreadsheet, so you can easily see what addresses are available (and which are duplicated!)

Ethernet address
There are two accepted formats for the hardware address:
nn nn nn nn nn nn
i.e., as six hexadecimal bytes separated with spaces.

nnnnnnnnnnnn
i.e., as a sequence of twelve hexadecimal digits.

The heading for this column must contain any of these words: mac, ether, hardware, network card. Again, case does not matter.

Host name
The heading must have both the words host name in it. There can be a number of names in this column; we put the canonical name first, then the aliases, in a space-separated list.

The heading for this columnd must contain host name or workstation. Case does not matter.

Optional columns in spreadsheet(s)

Other columns can provide information that can be stored in the configuration file next to the information for that host. Here are some examples of other headings. You can add whatever you think is reasonable. These are just what we use. The program does not depend on these names. The main purpose of these other columns is to provide HINFO, TXT and CNAME DNS records that can be accessed remotely to provide network administrators with information about machines that may be causing problems.

Item
Give an item number for each computer, perhaps just to see how many computers you manage!

Equipment type
Type of equipment, e.g., Pentium II 350

Brand/model
Brand name and model, e.g., Dell OptiPlex GX1

Data point
An identifier for the data point in the wall, to help determine what Ethernet switch or hub the computer is connected to.

Location
Where the computer is.

OS
Operating system(s) used, e.g., DOS/98/NT/Linux

Responsible person
The person to contact when there is some problem with the computer.


OPTIONS

--comments
Read all the other data from the Excel spreadsheet(s) besides the host name, IP address and Ethernet address, and create a comment for each computer in the configuration file showing this data, just above the entry for that machine. On by default.

--nocomments
Turn off making comments for each machine in the configuration file.

-G [num], --debug[=num]
show more output for higher integer values. If you leave the number out, you get the same as -G 1. Anything more than --debug=1 is really for debugging the program, and is really only useful to the developer.

-l hours, --deflease hours
The default lease time. Unfortunately, this is the same for all subnets. The hours are a floating point number.

-D dns-ip-address, --dns=dns-ip-address
IP address of a DNS server. You can provide up to three of these, like this:

--dns=192.168.129.49 --dns=192.168.129.50 --dns=192.168.129.51

They apply to all subnets.

-d domain, --domain=domain
The domain that the server will give to each machine. The default is the same as the domain of the machine on which this program is run.

-g default gateway IP, --gateway=default gateway IP
The default gateway for a subnet. You may provide as many as you like, up to one for each subnet. The program will take care of matching it with the correct subnet. You can put them in any order.

-m hours, --maxlease=hours
The maximum lease time, the same for all subnets. hours is a floating point value.

-n network/numbits, --net=network/numbits
A subnet. There must be one such option for each subnet that the DHCP server allocates IP parameters for. This is the only option which is not optional! Although the program could guess this from the Excel spreadsheet, it would be hard to always get the netmask right, so you need to specify it directly. The network is of the form 192.168.129 if the network part has 24 bits. The numbits is an integer giving the number of bits in the network part of the address. So for example, you could specify the old class A network 10.0.0.0 with netmask 255.0.0.0 as 10/8, and 192.168.129.0 with netmask 255.255.255.0 as 192.168.129/24.

-r lowerIP:higherIP, --range=lowerIP:higherIP
A range of addresses to be dynamically allocated. The program takes care of putting this into the right subnet. You can have as many of these as you like. This program does not check for overlapping ranges, but dhcpd does.

-s DHCP server IP address, --server=DHCP server IP address
The IP address of the DHCP server. Defaults to the IP address of the machine on which this program is run.

-w wins server IP address, --wins=wins server IP address
The address of a WINS server to be given to the clients. You can put more than one of these options. They will be made global to the configuration file.

file ...
One of more files. Each file is the output of Excel, described above.


EXAMPLES

  make-dhcpd.conf \
  --net 192.168/24 \
  --net 192.168.100/24 \
  --net 192.168.200/24 \
  --gateway 192.168.100.254 \
  --gateway 192.168.200.1 \
  --gateway 192.168.0.254 \
  --dns 192.168.0.1 \
  --server 192.168.0.1 \
  --domain sunday.com \
  --range 192.168.0.20:192.168.0.30 \
  --range 192.168.0.32:192.168.0.35 \
  --range 192.168.0.39:192.168.0.52 \
  --range 192.168.100.55:192.168.100.60 \
  --range 192.168.100.32:192.168.100.35 \
  --range 192.168.100.39:192.168.100.52 \
  --range 192.168.200.20:192.168.200.30 \
  --range 192.168.200.32:192.168.200.35 \
  --range 192.168.200.39:192.168.200.52 \
  --nocomments \
  named/sunday-ip-address.txt > /etc/dhcpd.conf
  make-dhcpd.conf \
  --wins 202.20.100.226 --wins 192.168.129.100 \
  --dns 192.168.129.49 --dns 202.40.209.220 --dns 192.168.129.49 \
  --server 192.168.129.49 \
  --gateway 192.168.129.254 \
  --maxlease 12 \
  --deflease 12 \
  --range 192.168.129.120:192.168.129.170 \
  --net 192.168.129/24 \
  --domain tyee.vtc.edu.hk \
  tcpipee2.txt > /etc/dhcpd.conf

Here is a minimal example:

  make-dhcpd.conf --net 192.168.129/24 tcpipee2.txt

It's probably a good idea to put your options into a file and execute it as a shell script.


AUTHOR

Nick Urbanik <nicku@vtc.edu.hk> Please feel free to contact me for any wishes you may have for this program. Please let me know where this documentation is unclear.


BUGS

Does not support classes in dhcp version 3.

Really mainly for allocating fixed addresses.

The lease times apply to all subnets.

People may be confused by so many options!

Please tell me if you find any more!


COPYRIGHT

This is freely distributable and may be freely modified as long as my name is not removed from the program.


SEE ALSO

See the documentation for the ISC DHCP server. Also see the URL

http://www.isc.org/dhcp.html

I maintain a Red Hat Package of the latest dhcp server; please contact me for it. You can find out what documentation is available by doing:

  rpm -qld dhcp

which will list the documentation files, which includes the RFCs and IETF drafts, as well as the man pages. These include:

dhcpd.conf(5), dhcp-options(5), dhcp-eval(5), dhcpd(8), dhcpd.leases(5), dhcrelay(8). See also h2n(2).

Programs exist to analyse the dynamically allocated leases. One such program is written in Perl and is called leases.