/etc/dhcp/dhclient-exit-hooks.d/update-dns.sh
#! /bin/bash NAME_FQDN="$(hostname -s).acme.local" IP=$(hostname -I |tr " " "\n" |egrep "192\.168\.1\.") #IP=$(ip a | grep wlan0 | grep "inet " | awk '{print $2}' | cut -d '/' -f 1) if [ ! -z "$IP" ] then nsupdate -k /root/rndc.key <<EOF update del ${NAME_FQDN} A update add ${NAME_FQDN} 86400 A ${IP} send EOF fi
chmod +x /etc/dhcp/dhclient-exit-hooks.d/update-dns.sh
Il faut avoir le paquet isc-dhcp-client d'installé avec la configuration :
/etc/dhcp/dhclient.conf
send host-name = gethostname();
nsupdate -k /etc/rndc.key <<EOF update del plop.acme.local A update add plop.acme.local 86400 A 192.168.1.4 show send EOF
Voir :
Vérif syntax
dhcpd -t -cf /etc/dhcp/dhcpd.conf
Rafraichir la conf
> /var/lib/dhcpd/dhcpd.leases systemctl restart dhcpd