How access assigned host-name value?
Dhcp User
dhcpstuff at SlowBlink.Com
Mon Jul 1 21:35:17 UTC 2013
Hi Folks,
I have a setup where all systems have fixed addresses, the dhcpd.conf
file and dns db files all being dynamically generated from a sql database.
Everything works correctly.
I want to call an external program to process and track information about
the associated systems. All was well until I tried to access the hostname.
From the conf file:
subnet 10.59.0.0 netmask 255.255.0.0 {
use-host-decl-names on;
option subnet-mask 255.255.0.0;
option broadcast-address 10.59.255.255;
option interface-mtu 9000;
option domain-name "tst1.sample.com";
option domain-name-servers 10.59.1.1;
option domain-search "tst1.sample.com", "tst2.sample.com";
deny unknown-clients;
pool {
range 10.59.11.2 10.59.11.4; # So fail-over won't complain
failover peer "failover-partner";
}
}
group {
#
# This group of systems boots over the 10.59 network
#
set clHW = concat (
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 1, 1))),2), ":",
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 2, 1))),2), ":",
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 3, 1))),2), ":",
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 4, 1))),2), ":",
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 5, 1))),2), ":",
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 6, 1))),2)); # For sql lookup
set clIP = binary-to-ascii(10, 8, ".", leased-address);
set myIP = binary-to-ascii (10, 8, ".",option dhcp-server-identifier); # we are the web server also
# chain loading
if exists user-class and option user-class = "iPXE" {
# sql query via php for sanboot target for this clHW
set myvc = option user-class;
set myhn = pick-first-value(host-name, option host-name, config-option host-name, "iPXE:no-host-value"); *** PROBLEM LINE ***
set myfn = concat("http://",myIP,"/boot.php?MAC=", clHW, "&HOST=", myhn ,"&DHCP=", gethostname());
filename = myfn;
} else {
# load ipxe
set myvc = pick(option vendor-class-identifier, option user-class, "unknown");
set myhn = pick-first-value(host-name, option host-name, config-option host-name, "Other:no-host-value"); *** PROBLEM LINE ***
set myfn = "undionly.kpxe";
filename = myfn;
}
#
# Declare all systems which are booting via 10.59 here..
#
host server1-59 { fixed-address 10.59.6.31; option host-name "tstserver51.tst1.sample.com"; hardware ethernet 20:DB:55:5F:12:A5; }
host server7-59 { fixed-address 10.59.6.37; option host-name "tstserver57.tst1.sample.com"; hardware ethernet 20:DB:55:5F:12:F3; }
on commit {
execute("/usr/bin/logger", "myvc=", myvc, "myfn=", myfn, "myhn=", myhn, "leased-address=",clIP)
}
}
and from the log file:
dhcpd: execute_statement argv[0] = /usr/bin/logger
dhcpd: execute_statement argv[1] = myvc=
dhcpd: execute_statement argv[2] = PXEClient:Arch:00000:UNDI:002001
dhcpd: execute_statement argv[3] = myfn=
dhcpd: execute_statement argv[4] = undionly.kpxe
dhcpd: execute_statement argv[5] = myhn=
dhcpd: execute_statement argv[6] = Other:no-host-value *** Note this value ***
dhcpd: execute_statement argv[7] = leased-address=
dhcpd: execute_statement argv[8] = 10.59.6.31
The host-name is assigned in the host declaration and works correctly.
The client receives the host-name value and sets it as it should.
However, no matter what combination of references I try, I cannot
get the host-name as set in the host declaration to print out correctly.
I would like to get both the values of host-decl-name and host-name.
In our usage, the host-decl-name is typically the rack/chassis/blade
position and the host-name is the hostname it is assigned.
I'm probably missing something simple.
Thoughts?
Thanks,
John
More information about the dhcp-users
mailing list