Using FreeIPA as a backend for DHCP
Disclaimer: This is not an official guide and in no way represents best practices for FreeIPA. It is ugly and involves the digital equivalent of bashing on screws with a hammer. Having said that, when nobody has invented the right screwdriver yet, sometimes you just have to hammer away.
First, some history. We’ve been running separate DHCP, DNS and LDAP servers since we switched from static IP addresses and a Windows NT domain somewhere around ten years ago. The DHCP server was loosely connected with the DNS server, and I had written this beautifully complex (read: messily unreadable) script that would allow you to quickly add a system to both DHCP and DNS. A few months ago, we migrated all of our users over to FreeIPA, and I started the process of migrating our DNS database over. Unfortunately, this meant that our DHCP fixed addresses were being configured separately from our DNS entries.
Last week I investigated what it would take to integrate our DHCP leases into FreeIPA. First I checked on the web to see if something like this had already been written, but the closest thing I could find was a link to a design page for a feature that’s due to appear in FreeIPA 4.x.
So here’s my (admittedly hacky) contribution:
sync_dhcp
– A bash script (put in/srv
, chmod +x)that constantly checks whether the DNS zone’s serial number has changed, and, if it has, runs…generate_dhcp.py
– A python script (put in/srv
, chmod +x) that regenerates a list of fixed-addresses in/etc/dhcp/hosts.conf
dhcpd.conf
– A sample dhcpd.conf (put in/etc/dhcp
) that uses the list generated bygenerate_dhcp.py
sync-dhcp.service
– A systemd service (put in/etc/systemd/system
) to runsync_dhcp
on bootupmake_dns
– A script (chmod +x) that allows the sysadmin to easily add new dns entries with a mac address
sync_dhcp
does need to know your domain so it knows which DNS zone serial to check, but other than that, the first four files should work with little or no modification. You will need to create a dnsserver user in FreeIPA, give the user read access to DNS entries, and put its password in /etc/dhcp/dnspasswd (readable only by root).
make_dns
makes a number of assumptions that are true of our network, but may not be true of yours. It first assumes that you’re using a 10.10.0.0/16 network (yes, I know that’s not right; it’s long story) and that 10.10.9.x and 10.10.10.x IPs are for unrecognized systems. It also requires that you’ve installed freeipa-admintools
and run kinit for a user with permissions to change DNS entries, as it’s just basically a fancy wrapper around the IPA cli tools.
Bent Screw Hole Backyard Metal Macros by Steven Depolo used under a CC BY 2.0 license
Comments
Samuel Sieb
Thursday, Oct 23, 2014
Jonathan Dieter
Friday, Oct 24, 2014
No, I skim-read and mistook ISC dhcpd 4.x for FreeIPA 4.x. Apologies for the confusion.
There is more detail on the current implementation status at https://fedorahosted.org/freeipa/ticket/939, but it all seems to be on hold for the moment.