Syntax checker ?

Martin McCormick martin at dc.cis.okstate.edu
Mon Feb 26 19:50:02 UTC 2007


	Somebody asked for some examples of using the syntax
checker or -t flag to test a configuration.  What I do is build
the configuration on a system that has the same version of dhcpd
our servers use.  You can certainly do this on the same system as
your dhcp server, but the important thing is to use the same
dhcpd version to insure predictable results.

	You first build your configuration however you like to do
so.  Here is the portion of shell script that will either approve
or disapprove of your configuration syntax.  bootpsync is an
expect script that uses ssh and scp to send out the new
configuration and start the bounce process on your dhcp server or
servers.  To make it more authentic, dhcpd.conf.pretest is a
small stub like dhcpd.conf except that it includes a different
file.  Snippet of shell script follows:

#The new dhcpd.conf file is in /home/dhcpd/dhcpd.conf.tmp.
#let's see if it is any good.

if ( dhcpd -t -cf /usr/local/etc/dhcpd.conf.pretest 2>/tmp/dhcpdtest) ; then
#Save dhcpd.conf for comparison next time.
cp /home/dhcpd/dhcpd.conf.tmp /usr/local/etc/dhcpd.conf.tested
bootpsync >>/var/log/bootserverdb.log 2>&1 &
echo "Sending new DHCP configuration to DHCP servers." >/dev/stderr
echo "To watch the action, tail -1f /var/log/bootserverdb.log." >/dev/stderr
echo "To stop watching, type Control+C to get your shell prompt back." >/dev/stderr
echo "This will not stop the update." >/dev/stderr

That dhcpdtest file in /tmp is like the black (really bright
orange) box recording of the last sounds in the cockpit of a
plane before a crash.  Your script can have an else clause
against the if statement that mails a copy of /tmp/dhcpdtest to
anybody who needs it so they can know that something is going
wrong.  Happy testing.

Martin McCormick WB5AGZ  Stillwater, OK 
Systems Engineer
OSU Information Technology Department Network Operations Group


More information about the dhcp-users mailing list