If you wish to use your server as a dhcp server then you need to make sure that bind9 and the dhcp server can talk to each other. You should already have bind installed and running as expected at this point. Next thing to do is install your dhcp server
# apt install isc-dhcp-server
Debian will probably attempt to start the DHCP server at this point and that may very well fail; Don’t worry about that. Next thing to do is to edit a couple of configuration files. The first of these tells the server which interface to listen on.
Open /etc/default/isc-dhcp-server and edit the INTERFACESv4 directive as instructed in the file. In my example I only want to provide ip addresses on the local network which is served by the interface “eno1” on my Dell server.
INTERFACESv4="eno1"
The next thing to do is update our rndc key (this is not strictly necessary as it is generated automatically on installation, but it is not a bad idea to update it every once in a while).
# rndc-confgen -a -b 512
This will automatically generate (or regenerate a file called rndc.key in /etc/bind. Once it is generated you are advised to copy it over to your dhcp configuration directory and restrict its permissions Note: COPY not MOVE!
# mkdir /etc/dhcp/ddns-keys # cp /etc/bind/rndc.key /etc/dhcp/ddns-keys # chmod 640 /etc/dhcp/ddns-keys/rndc.key
Moving on to your dns configuration, navigate to your /etc/bind directory and edit named.conf in order to make bind aware of the rndc key by adding the following line:
include "/etc/bind/rndc.key";
Now you need to tell bind that you want to allow anything that presents the rndc key to have permission to edit the zone file.
zone "mydomain.lan" IN { type master; file "named.mydomain.lan"; allow-update { key rndc-key; }; };
Your zone may look different but the important bit is the allow-update stanza. You may have additional lines in here, but you need the key rndc-key directive to allow dhcp to use the key in order to update the zone file.
Finally you can move on to edit the dhcpd.conf file in the /etc/dhcp folder:
First we what to change the ddns-style to “standard”
ddns-update-style standard;
Now we want to add the following lines:
allow unknown-clients; use-host-decl-names on; include "/etc/dhcp/ddns-keys/rndc.key";
This tells the server that we want to be able to assign dhcp addresses to unknown clients (which is usually what dhcp servers do) and that we want to use the name supplied by the client in order to identify it (which again is pretty standard stuff. Finally our include directive tells the server where to look for the rndc key file for authentication purposes.
The last part of the configuration is going to be specific for your particular environment, but it is fairly self explanatory once you have the syntax right:
zone mydomain.lan. { primary 172.17.1.20; key rndc-key; }
The zone directive is very similar to the declaration in named.conf.default-zones. The “primary” directive refers to the address of the primary dns server.
The following will assign ip addresses in the range 172.18.20.1 172.18.20.254 and update the zone mydomain.lan with any new clients. It will set the router/gateway on the client and the name servers as well as setting the domain name so that you do not have to use the full fqdn when trying to connect to the server or other clients on the network.
subnet 172.18.0.0 netmask 255.255.0.0 { range 172.18.20.1 172.18.20.254; option subnet-mask 255.255.0.0; option broadcast-address 172.18.255.255; option routers 172.18.1.1; option domain-name-servers 172.18.1.1, 80.229.182.240; option domain-name "mydomain.lan"; ddns-domainname "mydomain.lan"; }
That should be about it, your server should now start, albeit I had to reboot one of mine in order to get this to work, but that may have been down to a few misconfiguration attempts before I got it right.
BINDING MAC ADDRESSES TO IP ADDRESSES
This is as simple adding
host client_hostname { hardware ethernet cl:ie:nt:ma:ca:dr:35; fixed-address xxx.xxx.xxx.xxx }
for each bound client.
Recent Comments