Skip to content

Instantly share code, notes, and snippets.

@tomoconnor
Created April 20, 2011 17:11
Show Gist options
  • Save tomoconnor/931988 to your computer and use it in GitHub Desktop.
Save tomoconnor/931988 to your computer and use it in GitHub Desktop.
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