ISC DHCP on commit 可以做到在 Client 取得 IP 後執行特定 script/program
在 /etc/dhcpd.conf 加入(加在 subnet 或 global 均可)
on commit {
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
execute("/usr/local/bin/dhcpd_on_commit", ClientIP, ClientMac);
}
ClientIP, ClientMac 就會以參數 $1, $2 帶給 script/program
若 Log 中看到 execute: no such function. 表示不支援, 這個功能似乎是 4.x 才有的, 預設 enable
./configure
--enable-execute enable support for execute() in config (default is yes)
Leave a comment