Hi,
I'm writing some advanced scripts that will control network access based on many parameters. The scripts are basically to be executed whenever my dhcpd hands out an IP address. The script then takes care of configuring iptables, et.al. as needed.
I have the following test code:
Code:
on commit {
set CIP = binary-to-ascii(10, 8, ".", leased-address);
set CMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
set LeaseTime = binary-to-ascii(10,32,"",encode-int(lease-time,32));
execute("/home/user/test.py", "commit", CIP, CMac, LeaseTime) ;
}
This code works as expected and the script is executed, being passed the mac address, IP address assigned and the lease time given.
I want to add to this script so that it can also receive the client-provided hostname. A lot of systems seem to pass their own computer name as a client hostname.
I can't find any parameter which I can use to get the client provided hostname into my execute command. Doing this:
Code:
execute("/home/user/test.py", "commit", CIP, CMac, LeaseTime, host-decl-name) ;
fails and the script actually never executes, and the error provided reads:
Code:
Feb 20 17:23:17 millions dhcpd: data: host_decl_name: not available
Feb 20 17:23:17 millions dhcpd: execute: bad arg 5
It seems this option is only good for working with explicit host blocks where a hostname was set in dhcpd.conf for a specific MAC address/IP address/etc.
Is there a way I can grab the name the client provided and pass it into the script? (IF the client doesn't pass a name that's OK, the script will be able to ignore it - that's also why I wanted it to be the last parameter in the script.)
Thanks!
F