allan

DHCPd: ddns-hooks.conf

Oct 20th, 2018
537
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.85 KB | None | 0 0
  1. # Include this in dhcpd.conf to have DHCPd create Dynamic DNS entries in Active Directory
  2. # DNS using GSS-TSIG/Kerberos authentication.
  3. #
  4. # Refer to https://pastebin.com/SRPh7Bcu for step-by-step instructions.
  5. #
  6. # Adapted from
  7. # https://unix.stackexchange.com/questions/270097/isc-dhcp-with-active-directory-secure-dynamic-dns-updates/271815#271815
  8. # https://blog.michael.kuron-germany.de/2011/02/isc-dhcpd-dynamic-dns-updates-against-secure-microsoft-dns/
  9. #
  10. # include can be at the global or pool-level.
  11.  
  12. on commit {
  13.     set noname = concat("dhcp-", binary-to-ascii(10, 8, "-", leased-address));
  14.     set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
  15.     set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
  16.     set ClientName = pick-first-value(option host-name, host-decl-name, config-option host-name, noname);
  17.     log(concat("Commit: IP: ", ClientIP, " Mac: ", ClientMac, " Name: ", ClientName));
  18.  
  19.     execute("/usr/local/sbin/dns-krbnsupdate.sh", "add", ClientIP, "-h", ClientName, "-m", ClientMac);
  20. }
  21.  
  22. on release {
  23.     set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
  24.     set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
  25.     log(concat("Release: IP: ", ClientIP, " Mac: ", ClientMac));
  26.  
  27.     # cannot get a ClientName here, for some reason that always fails
  28.  
  29.     execute("/usr/local/sbin/dns-krbnsupdate.sh", "delete", ClientIP, "-m", ClientMac);
  30. }
  31.  
  32. # comment this section if using TXT RR in https://pastebin.com/taNfvCSt
  33. on expiry {
  34.     set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
  35.  
  36.     # cannot get a ClientMac here, apparently this only works when actually receiving a packet
  37.  
  38.     log(concat("Expired: IP: ", ClientIP));
  39.  
  40.     # cannot get a ClientName here, for some reason that always fails
  41.  
  42.     execute("/usr/local/sbin/dns-krbnsupdate.sh", "delete", ClientIP);
  43. }
Comments
  • User was banned
Add Comment
Please, Sign In to add comment