William Brown <wibrown-h+wxahxf7alqt0dzr+a...@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....@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.

-- 
Manage your subscription for the Freeipa-users mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-users
Go to http://freeipa.org for more info on the project

Reply via email to