I have a DHCP server used to do unattended installations of Debian: boot from PXE, and then install the operating system with a preseed.
The DHCP server (Debian's isc-dhcp-server
package) is configured to do an operation (do an HTTP POST) when handing out a new lease:
subnet 192.168.0.0 netmask 255.255.252.0 {
[...]
filename "pxelinux.0";
on commit {
set client_ip = binary-to-ascii(10, 8, ".", leased-address);
execute("curl", "-X", "POST", [...])
}
}
[...]
host vmhost2 {
hardware ethernet 00:19:66:60:c3:61;
fixed-address 192.168.1.13;
}
I noticed that during the unattended installation, the HTTP POST is done twice: the first time a few seconds after the machine starts (this is expected), and approximately thirty seconds later when Debian installer is configuring the network.
I wasn't expecting the second request. In fact, this is the corresponding preseed configuration:
d-i netcfg/get_hostname string vmhost2 d-i netcfg/get_domain string pelicandd.com d-i netcfg/choose_interface select auto d-i netcfg/disable_autoconfig boolean true d-i netcfg/disable_dhcp boolean true d-i netcfg/dhcp_failed note d-i netcfg/dhcp_options select Configure network manually d-i netcfg/get_ipaddress string 192.168.1.13 d-i netcfg/get_netmask string 255.255.252.0 d-i netcfg/get_gateway string 192.168.1.1 d-i netcfg/get_nameservers string 192.168.1.3 192.168.1.4 8.8.8.8 8.8.4.4 d-i netcfg/confirm_static boolean true
I thought that the netcfg/disable_dhcp
option indicates that the installer should not need to contact the DHCP server, but still, it does.
Questions:
Why is the installer contacting the DHCP server the second time, despite the preseed options?
Is there a way to stop it doing it, either through a preseed option, or by modifying the configuration of ISC DHCP server to ignore the second lease?
The first DHCP DORA (Discover, Offer, Request, Accept) sequence is triggered by the client PXE firmware trying to find an IP/MASK and the PXE data (NBP + TFTP location).
The PXE firmware then TFTP retrieves and runs the corresponding kernel+initrd. When this kernel starts running it needs an IP/MASK then it triggers a second DHCP DORA sequence (this is a regular "non-PXE" DHCP request)
In order to avoid the second DHCP hit you must manually set the static network configuration on the "kernel" command line; you cannot set this info on a pressed file that has to be net retrieved because the kernel would be forced to use DHCP to get its net services correctly working in order to retrieve the preseed file... can you see the egg-chicken problem?
You can either pass the corresponding static network preseed variables "appended" to the kernel command line or use the Pxelinux
ipappend
command.NOTE: Please consider the syntax of preseed variables is slightly different when used on a preseed file or in a kernel command line, i.e.:
The final
append
should look like this. Remove the line breaks, which are added here only to enhance readability and prevent horizontal scroll.