1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
DHCP and Dynamic DNS -- v0.16
All of the attempts I have seen to tie DHCP and DNS together have ignored
the dynamic update capacity of Bind 8. I wrote these Perl scripts to remedy
that situation.
Contents
ddns.cron.pl a cron script to check for changes to the dhcp.leases file.
ddns.pl the script that does the actual work of creating the update
instructions for nsupdate and BIND 8.
ndc.cron.pl a cron script to force named to write all changes to disk and
reload its databases.
dnsupdate.pl perl script to make it easier to add and delete entries
manually to DNS.
Instructions
1. Copy the scripts to a directory. I suggest using a directory dedicated
to the dhcp-dns function but that is not necessary. I use
/root/DHCP-DNS.
2. Change the following in the scripts:
In ddns.cron.pl:
my $DDNSHOME="/root/DHCP-DNS"; # Wherever you copied the scripts
to.
my $DHCPD="/etc/dhcpd.leases"; # the location of your dhcpd leases
file
my $DOMAIN="cyp.ugsolutions.com"; # The domain the dhcp addresses
belong to.
my $NSUPDATE="/usr/bin/nsupdate"; # The location of nsupdate on your
system.
In ndc.cron.pl:
my $DDNSHOME="/root/DHCP-DNS"; # same place as $DDNSHOME above
# the command to force named to
my $NDC="/usr/sbin/ndc restart"; flush its buffers and reread the
zone information.
3. Assuming you already have dhcpd and Bind 8 running, use crontab to call
the programs at appropriate intervals. I call ddns.cron.pl every five
minutes and ndc.cron.pl every four hours.
ddnsupdate.pl
This is a perl script to aid in making dynamic changes to a running named.
Right now it allows new A and PTR records to be added and deleted. Syntax
is:
dnsupdate.pl add <name.domain> <ip address>
Adds a an A and a PTR record for <name.domain>
dnsupdate.pl delete <name.domain>
Deletes any A or PTR records for <name.domain>
It is very important to include the domain name.
Setting up BIND 8 to allow dynamic updates.
To use dynamic DNS, you must have your named.conf set up to allow it. This
is accomplished by using the allow-update directive in your named.conf file.
For example:
zone "high-g.prv" {
type master;
file "local.db";
allow-update {192.168.1.10;};
};
zone "1.168.192.in-addr.arpa" {
type master;
file "192.168.1.db";
allow-update {192.168.1.10;};
};
The address in the braces is the address of the computer that is allowed to
update the running named dynamically.
It is very important that every zone you want to update dynamically have the
allow-update directive. A common mistake is to allow updates in the forward
lookup zone (A records) but forget to add the allow-update directive to the
reverse lookup zone (PTR records)
Known Bugs
One user reports that nsupdate.pl does not work correctly with bind 8.2: The
reverse record (PTR) will be created but the forward record (A) will not. I
have been unable to duplicate the problem so if any one has a clue why this
happen please let me know.
---------------------------------------------------------------------------
Stephen Carville
Last modified: Wed May 19 21:21:57 PDT 1999
|