Create a gist now

Instantly share code, notes, and snippets.

snippet to show usage of dhcp-event (don't forget to set apparmor to allowing (complain) mode)
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.200;
option broadcast-address 192.168.0.255;
option routers 192.168.0.1;
on commit {
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
log(concat("Commit: IP: ", ClientIP, " Mac: ", ClientMac, "Hostname: ", host-decl-name));
execute("/usr/local/bin/dhcp-event", "commit", ClientIP, ClientMac, host-decl-name);
}
on release {
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
log(concat("Release: IP: ", ClientIP, " Mac: ", ClientMac, "Hostname: ", host-decl-name));
execute("/usr/local/bin/dhcp-event", "release", ClientIP, ClientMac, host-decl-name);
}
on expiry {
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
log(concat("Expiry: IP: ", ClientIP, " Mac: ", ClientMac, "Hostname: ", host-decl-name));
execute("/usr/local/bin/dhcp-event", "expiry", ClientIP, ClientMac, host-decl-name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment