Skip to content

Subnet

subnet object image

The subnet object defines the configuration of a single subnet for the DHCP server to process. Multiple subnets are allowed. The subnet can be attached to a local interface on DRP or relayed to DRP via a DHCP relay.

Fields

Field Definition
Name The unique name of this subnet.
Enabled A boolean value that indicates whether this subnet is available to hand out new Leases, and whether to allow renewals of any Leases in its range. Setting this to true allows the subnet to operate normally, and setting it to false will cause DRP to refuse to hand out new Leases for addresses in its range and will cause lease renewals for already existing Leases in its address range to fail.
Strategy A string that determines how the subnet will uniquely identify part of the DHCP request for address assignment.
Proxy A boolean value that indicates that DRP should respond to requests for addresses in this address range as if it was a proxy DHCP server (as defined in section 2 of the PXE specification).
Unmanaged A boolean value that indicates whether DRP will send any DHCP options required for a system to boot over the network. If this bit is set, DRP will never send any DHCP options that may be needed to network boot a system.
Subnet The network address in CIDR form of this subnet. Subnets may not have overlapping address ranges.
ActiveStart This is the start of the IP address range that this subnet will hand out. It must be within the address range the subnet is responsible for, and it must be less than ActiveEnd.
ActiveEnd This is the end of the IP address range that this subnet will hand out. It must be within the address range the subnet is responsible for, and it must be greater than ActiveStart.
ActiveLeaseTime Time in seconds that a lease created in this subnet will be valid for.
ReservedLeaseTime Time in seconds that a lease created by a reservation in this subnet will be valid for. It overrides ActiveLeaseTime.
OnlyReservations If set to true, then leases in this subnet range can only be created if there is a reservation created for the requested address.
Options A list of DhcpOption objects that should be returned in any replies to DHCP requests.

The subnet object defines the configuration of a single subnet for the DHCP server to process. Multiple subnets are allowed. The subnet can represent a local subnet attached to a local interface (broadcast subnet) to DRP or a subnet that is being forwarded or relayed (relayed subnet) to DRP.

The subnet is uniquely identified by its Name field. The subnet defines a CIDR-based range with a specific subrange to hand out for nodes that do not have explicit reservations (the ActiveStart thru ActiveEnd fields). The subnet also defines the NextServer field in the PXE chain. This is usually an IP associated with DRP, but if the provisioner is disabled, this can be any next hop server. The lease times for both reserved and unreserved clients as specified with the ReservedLeaseTime and ActiveLeaseTime fields. The subnet can also me marked as only working for explicitly reserved nodes using the ReservedOnly field.

Options

The subnet also allows for the specification of DHCP options to be sent to clients. These can be overridden by a reservation's specific options.

Some common options are:

Type # Description
IP 3 Default Gateway
IP 6 DNS Server
IP 15 Domain Name
String 67 Next Boot File - e.g. ipxe.pxe

Note

Golang template expansion also works in these fields. This can be used to make custom request-based reply options.

For example, this value in the Next Boot File option (67) will return a file based upon what type of machine is booting. If the machine supports, iPXE then an iPXE boot image is sent, if the system is marked for legacy bios, then ipxe.pxe is returned, otherwise return a 64-bit UEFI iPXE boot loader:

{{if (eq (index . 77) "iPXE") }}default.ipxe{{else if (eq (index . 93) "0")}}ipxe.pxe{{else}}ipxe.efi{{end}}

The data element for the template expansion as represented by the . above is a map of strings indexed by an integer. The integer is the option number from the DHCP request's incoming options. The IP addresses and other data fields are converted to a string form (dotted quads or base 10 numerals).

Note

Option 67 is optional. When using DRP as the DHCP server, it will generate a bootfile like the above template expansion.

The final elements of a subnet are the Strategy and Pickers options. These are described in the DRP API JSON description. They define how a node should be identified (Strategy), and the algorithm for picking addresses (Pickers). The strategy can only be set to MAC currently. This will use the MAC address of the node as its DHCP identifier. Others may show up in time.

Pickers

The Pickers field defines an ordered list of methods to determine the address to hand out. Currently, this will default to hint, nextFree, and mostExpired. The following options are available for the list.

Field Description
hint Try to reuse the address that the DHCP packet is requesting if it has one. If the request does not have a requested address, hint will fall through to the next strategyx, otherwise, it will refuse to try any reamining strategies whether or not it can satisfy the request. This should force the client to fall back to DHCPDISCOVER with no requsted IP address. hint will reuse expired leases and unexpired leases that match on the requested address, strategy, and token.
nextFree Within the subnet's pool of active IPs, choose the next free making sure to loop over all addresses before reuse. It will fall through to the next strategy if it cannot find a free IP. It only considers addresses that do not have a lease, whether or not the lease is expired.
mostExpired If no free address is available, use the most expired address first.
none Do not hand out an address and refuse to try any remaining strategies.

All of the address allocation strategies do not consider any addresses that are reserved, as lease creation will be handled by the reservation instead.