Penguin
Annotated edit history of DHCPNotes version 16, including all changes. View license author blame.
Rev Author # Line
14 DanielLawson 1 !! dhcp (client) keeps overwriting my resolv.conf!
2
3 You can change this behaviour by editing /etc/dhclient.conf (or /etc/dhcp3/dhclient.conf) and add appropriate 'supersede' lines:
4 <verbatim>
5 supersede domain-name "domain.com";
6 supersede domain-name-servers 192.168.1.1;
7 </verbatim>
8
9 !! Notes for Woody
4 DanielLawson 10 Under [Debian] [Woody], you install "dhcp-client" for clients, and "dhcp" for the server. If you have interfaces other than eth0 and lo0 (such as wan0 for MetaNet), then by default dhcp will refuse to start. You need to edit /etc/default/dhcp and put __INTERFACES="eth0"__. Unfortunately this isn't documented anywhere sensible like the dhcpd man page or the README.Debian file.
11
10 JohnMcPherson 12 In /etc/dhcpd.conf, the options that take time values are in seconds, although the example file doesn't mention this. It's in the man page though, dhcpd.conf(5).
13
16 JohnMcPherson 14 If you are running a dhcpd server on Debian Woody, and you're running [LinuxKernel2.6], then you will need to edit /usr/sbin/dhcpd and add a "6" where it says ~[12345]. If you are using a dhcp client, you will need to do this to the /sbin/dhclient script as well / instead. When the script was written, it was unsure whether or not the 2.6 kernel would have compatible structures for the binary in the dhcp package, but it works fine in 2.2 - 2.6 kernels.
10 JohnMcPherson 15
4 DanielLawson 16
1 DanielLawson 17 !! Dynamic DNS
18 ISC [DHCP] version 3 and later support dynamic dns updates for DHCP leases.
19
20 I set this up with a seperate forward zone for the dynamic entries. This was mainly to prevent serial and zone file pollution, but also because the dynamic updates create journal files which make editing the static entries hard.
21
3 DanielLawson 22 First of all, you *need* dhcp 3 and above. This is the default dhcp package in recent RedHat, in Debian Woody you want the dhcp3-server package.
1 DanielLawson 23
24 ! Create a key to use for the updates:
15 DanielLawson 25 <verbatim>
1 DanielLawson 26
27 $rndc-confgen -r /dev/urandom
28
29 # Start of rndc.conf
30 key "rndc-key" {
31 algorithm hmac-md5;
32 secret "bC9Up7x9abx5mnOKujzgEg==";
33 };
34 ...
15 DanielLawson 35 </verbatim>
2 OrionEdwards 36
5 CraigBox 37 __Note:__ ''rndc'' might be called ''dnskeygen''. [RTFM] for more. 128 bit HMAC-md5 keys work best.
1 DanielLawson 38
39 ! Edit named.conf
40
41 Take the contents of the above snippet, and add an entry into your named.conf for it.
15 DanielLawson 42 <verbatim>
1 DanielLawson 43 key "DHCP-UPDATER" {
44 algorithm hmac-md5;
45 secret "bC9Up7x9abx5mnOKujzgEg==";
46 };
15 DanielLawson 47 </verbatim>
1 DanielLawson 48
49 Note: it is very important that you copy the key verbatim!
50 For the zones you wish to enable DDNS updates on, add the following to the zone definition in named.conf
51
15 DanielLawson 52 <verbatim>
13 MichaelBarnwell 53 allow-update { key DHCP-UPDATER; };
15 DanielLawson 54 </verbatim>
1 DanielLawson 55 e.g., I have:
15 DanielLawson 56 <verbatim>
5 CraigBox 57 zone "dyn.mydomain.something." {
1 DanielLawson 58 type master;
59 file "/etc/bind/zone/db.dyn.mydomain.something";
13 MichaelBarnwell 60 allow-update { key DHCP-UPDATER; };
1 DanielLawson 61 };
15 DanielLawson 62 </verbatim>
1 DanielLawson 63
5 CraigBox 64 Remember to add it to the reverse zone as well:
65
15 DanielLawson 66 <verbatim>
5 CraigBox 67 zone "z.y.x.in-addr.arpa."
15 DanielLawson 68 </verbatim>
1 DanielLawson 69
70 Note that if you use a new zone (ie, not your normal zone) you'll need to create the basic zone file for it, ie SOA entry and so on. Thats another topic tho.
71
5 CraigBox 72 !Edit dhcpd.conf
73
1 DanielLawson 74 This assumes you have a working DHCP3 config file.
75
76 Add the following entries to your dhcp.conf:
77
78 In the main configuration:
15 DanielLawson 79 <verbatim>
1 DanielLawson 80 ddns-domainname "dyn.mydomain.something";
81 ddns-updates off;
82 ddns-update-style interim;
83
13 MichaelBarnwell 84 key DHCP-UPDATER {
1 DanielLawson 85 algorithm hmac-md5;
86 secret "bC9Up7x9abx5mnOKujzgEg==";
87 }
88
89 zone dyn.mydomain.something. {
90 primary 127.0.0.1;
13 MichaelBarnwell 91 key DHCP-UPDATER;
1 DanielLawson 92 }
93
94 zone 0.0.10.in-addr.arpa. {
95 primary 127.0.0.1;
13 MichaelBarnwell 96 key DHCP-UPDATER;
1 DanielLawson 97 }
15 DanielLawson 98 </verbatim>
1 DanielLawson 99
100 This sets up the ddns keys, and which zones to use them for. ddns-domainname sets the forward domain name that ddns will update. You can leave this out,
101 but it will then use the value in 'domain-name'. As I wanted to use a seperate forward domain for dynamic names, I set the dynamic zone here. Note that i set dynamic updates off by default - I dont want dynamic updates to run over my static leases. (there is i think a better way of doing this)
6 MarianFlor 102
103 There is a better way: If you have static entries in your dhcpd.conf they won't populate the dhcpd.leases file whenever you request a lease. The DNS entries will be updated with the entries from the dhcpd.leases file. So entries in your dhcpd.conf file like this:
104
15 DanielLawson 105 <verbatim>
6 MarianFlor 106 host coffee {
107 hardware ethernet 00:0a:27:c0:ff:ee;
108 fixed-address 192.168.1.20;
109 }
15 DanielLawson 110 </verbatim>
6 MarianFlor 111
112 will not show up in the dhcpd.leases file.
113 Thus you can leave the default alone (which means 'dynamic updates on' in the global section). Tested with Debian Woody dhcp3-server 3.0+3.0.1rc9-2 and bind8 1:8.3.3-0.woody.1.
1 DanielLawson 114
115 Now to set up the dynamic options for a given subnet:
15 DanielLawson 116 <verbatim>
1 DanielLawson 117 subnet 10.0.0.0 netmask 255.255.255.0 {
118 option subnet-mask 255.255.255.0;
119
120 option domain-name "mydomain.something";
5 CraigBox 121 option routers 10.0.0.254;
1 DanielLawson 122 option domain-name-servers 10.0.0.1;
123 option netbios-name-servers 10.0.0.1;
124
125 range dynamic-bootp 10.0.0.150 10.0.0.250;
126 default-lease-time 600;
127 max-lease-time 86400;
128
129 authoritative;
130 ddns-updates on;
131 }
15 DanielLawson 132 </verbatim>
1 DanielLawson 133 This zone is for the 10.0.0.0/24 network. It specificies dynamic entries between 10.0.0.150 and 10.0.0.250 inclusive, states that it is authoritative for
134 this subnet, and sets ddns-updates on.
135
136 Restart both dhcpd3-server and named.
137 You should see log entries in syslog talking about 'if rrset for ... does not exist then create ...'
138
139 And doing nslookups on $MACHINENAME.yourdomain should now work. Note that this machinename is the Netbios name in case of windows machines. The reverse zone should also be updated, so that 'nslookup 10.0.0.151' for example, will return '$MACHINENAME.mydomain.something' correctly, instead of '10.0.0.151.dhcp.mydomain.something' which is what it was set to previously :)
7 PerryLorier 140
141 {Not really PerryLorier}
142 Note that after you've set up DDNS, you mustn't edit the dynamically updated zones manually. Instead, use the 'nsupdate' command to add and delete records. The man page for 'nsupdate' says this:
143
15 DanielLawson 144 <verbatim>
7 PerryLorier 145 Zones that are under dynamic control via nsupdate or a DHCP server
146 should not be edited by hand. Manual edits could conflict with dynamic
147 updates and cause data to be lost.
15 DanielLawson 148 </verbatim>
7 PerryLorier 149
150 Unfortunately, 'nsupdate' is about as much fun to use as 'nslookup'. More on 'nsupdate' once I've figured out how to use it, and what to do with those pesky .jnl (journal) files getting out of synch with the zone.
9 RowanJames 151
152
153 You can actually edit the zones, but 'named' must first sync the .jnl journal files with the database, and stop any further changes from taking place during the edit - this is only possible after a full, graceful shutdown of the 'named' daemon. This can be forced by using
15 DanielLawson 154 <verbatim>
9 RowanJames 155 # rndc stop
15 DanielLawson 156 </verbatim>
9 RowanJames 157
158 After editing your zones, restart 'named' as usual. Often, this is done by:
15 DanielLawson 159 <verbatim>
10 JohnMcPherson 160 # named -u (user named runs as)
15 DanielLawson 161 </verbatim>
11 PerryLorier 162
163 IF your version of named is new enough you can also do:
15 DanielLawson 164 <verbatim>
11 PerryLorier 165 # rndc freeze ''zone''
166 ''edit the zone file''
167 # rndc unfreeze ''zone''
15 DanielLawson 168 </verbatim>
11 PerryLorier 169
170 Note that while a zone is frozen, you dynamic updates for that zone will be refused.
171
8 DavidMoore 172
173 ----
174 I found these notes useful, but what I really needed was a complete [example|DavidsDDNSExample].
The following authors of this page have not agreed to the WlugWikiLicense. As such copyright to all content on this page is retained by the original authors. The following authors of this page have agreed to the WlugWikiLicense.

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 2 times)

lib/plugin/WlugLicense.php (In template 'html'):99: Warning: Invalid argument supplied for foreach()

lib/plugin/WlugLicense.php (In template 'html'):111: Warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument

lib/plugin/WlugLicense.php (In template 'html'):111: Notice: Undefined variable: ignore_authors

lib/plugin/WlugLicense.php (In template 'html'):111: Notice: Undefined variable: ignore_authors

lib/plugin/WlugLicense.php (In template 'html'):111: Warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument