9

i want to do a setting to dynamically monitor my Work Station on my Wifi network. I've got my name server BIND and my dhcpd server all of that under linux working perfectly. But i didn't find any option to execute a script when dhcp give an IP to a machine. I would like to know if there is a way to do that. If there is no options for that i'll use the log files.

Louis
  • 2,770

1 Answers1

11

You can find the answer here:

Here's the copy-paste from the above link:

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));
        execute("/usr/sbin/my_script_here", "commit", ClientIP, ClientMac);
}

It might be different for different versions of Linux, but should give you the idea.

See here for another example:

man dhcpd.conf should also give you more information.

Baiscally, you want to use on commit and execute inside it to specify a script to be run.

icyrock.com
  • 5,432