2022-10-30 10:59:26 +09:00
|
|
|
#-------------------------------
|
|
|
|
# Global options
|
|
|
|
#-------------------------------
|
|
|
|
authoritative;
|
|
|
|
|
|
|
|
option domain-name "example.net";
|
2022-11-03 18:19:28 +09:00
|
|
|
option domain-name-servers 192.168.110.4;
|
|
|
|
option ntp-servers 192.168.110.4;
|
2022-10-30 10:59:26 +09:00
|
|
|
option routers 192.168.110.10;
|
|
|
|
|
|
|
|
default-lease-time 86400; # 24 hours.
|
|
|
|
max-lease-time 604800; # 7 days.
|
|
|
|
|
|
|
|
lease-file-name "/var/lib/dhcp/dhcpd.leases";
|
|
|
|
|
|
|
|
#-------------------------------
|
|
|
|
# Subnet
|
|
|
|
#-------------------------------
|
|
|
|
subnet 192.168.110.0 netmask 255.255.255.0 {
|
|
|
|
range 192.168.110.100 192.168.110.199;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------
|
|
|
|
# Fixed address
|
|
|
|
#-------------------------------
|
|
|
|
host party {
|
|
|
|
hardware ethernet 00:0C:29:14:6E:24;
|
|
|
|
fixed-address 192.168.110.12;
|
|
|
|
}
|
|
|
|
|
|
|
|
host work {
|
|
|
|
hardware ethernet 00:0c:29:0a:83:af;
|
|
|
|
fixed-address 192.168.110.3;
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------
|
|
|
|
# Dynamic DNS
|
|
|
|
#-------------------------------
|
|
|
|
on commit {
|
|
|
|
set noname = concat("dhcp-", binary-to-ascii(10, 8, "-", leased-address));
|
|
|
|
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
|
|
|
|
set ClientDHCID = concat (
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":",
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":",
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), ":",
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), ":",
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":",
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2)
|
|
|
|
);
|
|
|
|
set ClientName = pick-first-value(option host-name, config-option host-name, client-name, noname);
|
|
|
|
#log(concat("Commit: IP: ", ClientIP, " DHCID: ", ClientDHCID, " Name: ", ClientName));
|
|
|
|
execute("/usr/local/bin/dhcp-dyndns.sh", "add", ClientIP, ClientDHCID, ClientName);
|
|
|
|
}
|
|
|
|
|
|
|
|
on release {
|
|
|
|
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
|
|
|
|
set ClientDHCID = concat (
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":",
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":",
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), ":",
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), ":",
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":",
|
|
|
|
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2)
|
|
|
|
);
|
|
|
|
#log(concat("Release: IP: ", ClientIP));
|
|
|
|
execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, ClientDHCID);
|
|
|
|
}
|
|
|
|
|
|
|
|
on expiry {
|
|
|
|
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
|
|
|
|
# cannot get a ClientMac here, apparently this only works when actually receiving a packet
|
|
|
|
#log(concat("Expired: IP: ", ClientIP));
|
|
|
|
# cannot get a ClientName here, for some reason that always fails
|
|
|
|
# however the dhcp update script will obtain the short hostname.
|
|
|
|
execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, "", "0");
|
|
|
|
}
|