[Freeipa-users] FreeIPA and DHCP
Jochen Hein
jochen at jochen.org
Mon Oct 19 14:14:37 UTC 2015
William Brown <wibrown-H+wXaHxf7aLQT0dZR+AlfA at public.gmane.org> writes:
> On Fri, 2015-10-16 at 15:01 +0200, Nicola Canepa wrote:
>> Hello.
>> Is there a suggested way to have DHCP IP/MAC associations managed
>> through the IPA web interface?
>
> There is currently no way to manage DHCP with FreeIPA.
Freeipa hosts do have MAC values as a field and there is an IP address
assigned. I've found a script to extract the info for isc DHCP at
http://lesloueizeh.com/jdieter/freeipa-dhcpd/generate_dhcp.py
I've implemented a script for using with dnsmasq:
-------------- cut here -------------------------
#!/bin/bash
out=/etc/dnsmasq.d/dynamic-hosts.conf
#out=/tmp/xxx
tmp=/etc/dnsmasq.d/dynamic-hosts.conf.tmp
KRBPRINC='host/echidna.jochen.org at JOCHEN.ORG'
kinit -k $KRBPRINC
cat > $tmp <<EOF
# This file has all hosts with their MAC and IP addresses.
# It is created by the cron job /root/scripts/update-dhcp-hosts-from-ipa.sh
# and reads host/mac/ip from freeipa.
EOF
LC_ALL=C ipa host-find --all | awk '
/MAC address:/ { for(i=3;i<=NF;i++){mac_address=mac_address $i}; }
/Class: vpnclient/ { tag="set:vpnclient," }
/serverhostname:/ {
if ( mac_address != "" )
print mac_address " " $2 " " tag ; tag=""; mac_address="" }' | \
while read mac_address host tag; do
mac_address=$(echo $mac_address | tr 'A-Z' 'a-z')
ip=$(getent ahostsv4 $host | head -n 1 | cut -f1 -d ' ' )
echo "dhcp-host=$mac_address,$tag$ip,$host"
done | sort >> $tmp
if cmp -s $out $tmp; then
rm -f $tmp
else
mv $tmp $out
systemctl restart dnsmasq.service
fi
kdestroy
-------------- cut here -------------------------
Jochen
--
The only problem with troubleshooting is that the trouble shoots back.
More information about the Freeipa-users
mailing list