Set up a DHCP server to provide network settings and an ISO image location to a chassis for iPXE booting.
The DHCP configuration can support IPv4, IPv6, or both protocols, and can select a boot image based on the chassis MAC address or serial number.
Before you begin
If using DHCPv6, configure the Router Advertisement Daemon (radvd) so router advertisement (RA) messages instruct nodes to obtain their IPv6 addresses through DHCP.
Install radvd by entering this command:
yum install radvd
Configure the interface in the radvd configuration. This example advertises a documentation-safe IPv6 prefix:
interface eth3
{
AdvSendAdvert on;
MinRtrAdvInterval 60;
MaxRtrAdvInterval 180;
AdvManagedFlag on;
AdvOtherConfigFlag on;
prefix 2001:DB8:C622:1::/64
{
AdvOnLink on;
AdvAutonomous on;
AdvRouterAddr off;
};
};
Follow these steps to configure the DHCP server for iPXE boot:
Procedure
|
1. |
Create the required DHCP configuration files in the /etc/ directory.
Create dhcpd.conf for IPv4, IPv6, or both protocols. Create dhcpv6.conf for IPv6.
Store the network information in these files, including the script path, ISO image location, provisioning configuration location, chassis serial number, and chassis MAC address.
|
|
2. |
For IPv4 identification by MAC address, add a host declaration to dhcpd.conf.
Example:
host ncs1001
{
hardware ethernet ab:cd:ef:01:23:45;
fixed-address <ip-address>;
filename "http://<http-server-address>/<path-to-image>/ncs1001-mini-x.iso";
}
The server can match the chassis MAC address to a fixed address and boot-image location.
|
|
3. |
For IPv4 identification by serial number, add a host declaration that uses the DHCP client identifier.
The chassis derives its serial number from the BIOS and uses the value as an identifier.
Example:
host demo {
option dhcp-client-identifier "<chassis-serial-number>";
filename "http://<ip-address>/<hardware-platform>-mini-x.iso";
fixed-address <ip-address>;
}
This example selects an ISO image for an iPXE client and a provisioning configuration for another client:
host 10.89.205.202 {
hardware ethernet 40:55:39:56:0c:e8;
if exists user-class and option user-class = "iPXE" {
filename "http://10.89.205.127/box1/ncs1001-mini-x-7.1.1.iso";
} else {
filename "http://10.89.205.127/box1/StartupConfig.cfg";
}
fixed-address 10.89.205.202;
}
|
|
4. |
For IPv6 identification by serial number, convert the serial number to a DHCP unique identifier (DUID) and add a DHCPv6 host declaration.
Obtain the chassis serial number from the show inventory command. Convert the serial number to the IPv6 DUID format before you add it to the host declaration.
Example:
host ncs1001 {
host-identifier option dhcp6.client-id "<ipv6-duid>";
filename "<http-or-tftp>://<ipv6-dhcp-server-address>/<hardware-platform>-mini-x.iso";
}
This example uses a documentation-safe IPv6 address:
host mys-p1b-212 {
# PID: NCS1001-K9, VID: V01, SN: CAT2018B02M
host-identifier option dhcp6.client-id 00:02:00:00:00:09:43:41:54:32:30:31:38:42:30:32:4d:00;
if exists dhcp6.user-class and substring(option dhcp6.user-class, 2, 4) = "iPXE" {
option dhcp6.bootfile-url "http://[2001:DB8:4491:2005::227:11]/rosco/mys-p1b-212/ncs1001-mini-mod.iso";
}
else {
option dhcp6.bootfile-url "http://[2001:DB8:4491:2005::227:11]/rosco/mys-p1b-212/ztp.ipv6.sh";
}
}
|
|
5. |
Use a conversion script if you need to generate an enterprise-number-based DUID from the chassis serial number.
Example:
#! /bin/sh
# Comply with the IPv6 enterprise-number-based DUID format.
## 00:02 = Enterprise-number-based DUID
## 00:00:00:09 = Cisco enterprise number
## 00 = Terminator
SERIALNUMBER=$1
en_duid=0002
cisco_en=00000009
sn=`xxd -l11 -pu <<< ${SERIALNUMBER}`
null=00
DHCPv6_DUID=`sed 's/\(..\)/\1:/g;s/:$//' <<< ${en_duid}${cisco_en}${sn}${null}`
echo $DHCPv6_DUID
|
|
6. |
After the DHCP server is running, test the applicable host declaration with the chassis.
A successful match provides the configured network address and boot-file location to the chassis.
|
The DHCP server provides an IPv4 or IPv6 address and the appropriate iPXE boot file to the chassis for network boot.