dhcpd.conf(5)
๐ NAME ๐
okay so this is the <pink>dhcpd.conf</pink> manual page โ it lives in the File Formats Manual section, and it's literally the whole entire guide to the dhcpd.conf file. which is the configuration file for dhcpd. bestie. that's the Internet Systems Consortium DHCP Server. yeah. that one. ๐
๐ฆ DESCRIPTION ๐ฆ
so the <hotpink>dhcpd.conf</hotpink> file is where all the config tea lives for dhcpd, the Internet Systems Consortium DHCP Server. it's giving "the server's entire personality is stored in one text file." ๐
the <hotpink>dhcpd.conf</hotpink> file is a free-form ASCII text file. it gets parsed by the recursive-descent parser that's built right into dhcpd โ no cap, that's literally how it reads you. the file can have extra tabs and newlines in it just for formatting purposes, like, it does not care. keywords are case-insensitive (so Subnet and SUBNET and subnet all slay the same). comments can go anywhere in the file except inside quotes โ comments start with the # character and run until the end of the line. periodt. ๐ธ
the file is basically a list of statements, and those statements fall into two big categories: parameters and declarations.
- Parameter statements either say how to do something (e.g. how long a lease to offer), whether to do something (e.g. should
dhcpdprovide addresses to unknown clients), or what parameters to provide to the client (e.g. use gateway220.177.244.7). - Declarations are used to describe the topology of the network, to describe clients on the network, to provide addresses that can be assigned to clients, or to apply a group of parameters to a group of declarations.
โ ๏ธ and here's the rule that will get you if you're not paying attention: in any group of parameters and declarations, all parameters must be specified before any declarations which depend on those parameters may be specified. order matters, bestie. do not come for me in the comments. ๐
declarations about network topology include the shared-network and the subnet declarations. if clients on a subnet are gonna get addresses dynamically, a range declaration has to appear inside the subnet declaration. for clients with statically assigned addresses, or for installations where only known clients will be served, each such client must have a host declaration. and if parameters are to be applied to a group of declarations that aren't related strictly on a per-subnet basis, you can use the group declaration. ๐
for every subnet which will be served, and for every subnet to which the dhcp server is connected, there must be one subnet declaration โ that's the thing that tells dhcpd how to recognize that an address is on that subnet. and yes, a subnet declaration is required for each subnet even if no addresses will be dynamically allocated on that subnet. like, even the empty ones. especially the empty ones. โจ
some installations have physical networks on which more than one IP subnet operates. so, example time: if there's a site-wide requirement that 8-bit subnet masks be used, but a department with a single physical ethernet network grows to the point where it has more than 254 nodes, it may be necessary to run two 8-bit subnets on the same ethernet until such time as a new physical network can be added. in that case, the subnet declarations for these two networks must be enclosed in a shared-network declaration. iykyk. ๐ฆ
๐ก note (and this one's lowkey important): even when the shared-network declaration is absent, an empty one is created by the server to contain the subnet (and any scoped parameters included in the subnet). for practical purposes, this means that "stateless" DHCP clients, which are not tied to addresses (and therefore subnets), will receive the same configuration as stateful ones. the vibes are equalized. ๐ซถ
some sites may have departments which have clients on more than one subnet, but it may be desirable to offer those clients a uniform set of parameters that's different from what would be offered to clients from other departments on the same subnet. for clients that will be declared explicitly with host declarations, those declarations can be enclosed in a group declaration along with the parameters that are common to that department. for clients whose addresses will be dynamically assigned, class declarations and conditional declarations may be used to group parameter assignments based on information the client sends. main character energy for the matching engine honestly. ๐
๐ how boot parameters actually get picked ๐
when a client is to be booted, its boot parameters are determined by consulting, in this order:
- that client's
hostdeclaration (if any) - then any
classdeclarations matching the client - followed by the
pool,subnetandshared-networkdeclarations for the IP address assigned to the client
each of these declarations itself appears within a lexical scope, and all declarations at less specific lexical scopes are also consulted for client option declarations. scopes are never considered twice, and if parameters are declared in more than one scope, the parameter declared in the most specific scope is the one that's used. most specific wins. always. no ties, no drama. ๐
and when dhcpd tries to find a host declaration for a client, it first looks for a host declaration which has a fixed-address declaration that lists an IP address that is valid for the subnet or shared network on which the client is booting. if it doesn't find any such entry, it tries to find an entry which has no fixed-address declaration. so like, fallback behavior is built in. very thoughtful of it. ๐ง
โจ EXAMPLES โจ
a typical <lavender>dhcpd.conf</lavender> file will look something like this:
global parameters...
subnet 204.254.239.0 netmask 255.255.255.224 {
subnet-specific parameters...
range 204.254.239.10 204.254.239.30;
}
subnet 204.254.239.32 netmask 255.255.255.224 {
subnet-specific parameters...
range 204.254.239.42 204.254.239.62;
}
subnet 204.254.239.64 netmask 255.255.255.224 {
subnet-specific parameters...
range 204.254.239.74 204.254.239.94;
}
group {
group-specific parameters...
host zappo.test.isc.org {
host-specific parameters...
}
host beppo.test.isc.org {
host-specific parameters...
}
host harpo.test.isc.org {
host-specific parameters...
}
}
Figure 1 โ she's iconic, she's the blueprint ๐
notice that at the beginning of the file there's a place for global parameters. these might be things like the organization's domain name, the addresses of the name servers (if they're common to the entire organization), and so on. so, for example:
option domain-name "isc.org";
option domain-name-servers ns1.isc.org, ns2.isc.org;
Figure 2 โ look at her go ๐
as you can see in Figure 2, you can specify host addresses in parameters using their domain names rather than their numeric IP addresses. and if a given hostname resolves to more than one IP address (for example, if that host has two ethernet interfaces), then where possible, both addresses are supplied to the client. generous queen. ๐
the most obvious reason for having subnet-specific parameters as shown in Figure 1 is that each subnet, of necessity, has its own router. so for the first subnet, for example, there should be something like:
option routers 204.254.239.1;
note that the address here is specified numerically. this is not required โ if you have a different domain name for each interface on your router, it's perfectly legitimate to use the domain name for that interface instead of the numeric address. however, in many cases there may be only one domain name for all of a router's IP addresses, and it would not be appropriate to use that name here. ๐
in Figure 1 there's also a group statement, which provides common parameters for a set of three hosts โ zappo, beppo and harpo. as you can see, these hosts are all in the test.isc.org domain, so it might make sense for a group-specific parameter to override the domain name supplied to these hosts:
option domain-name "test.isc.org";
also, given the domain they're in, these are probably test machines. if we wanted to test the DHCP leasing mechanism, we might set the lease timeout somewhat shorter than the default:
max-lease-time 120;
default-lease-time 120;
you may have noticed that while some parameters start with the option keyword, some do not. here's the breakdown, and honestly it's giving "two types of girls":
- parameters starting with the
optionkeyword correspond to actual DHCP options - parameters that do not start with the
optionkeyword either control the behavior of the DHCP server (e.g. how long a leasedhcpdwill give out), or specify client parameters that are not optional in the DHCP protocol (for example,server-nameandfilename)
in Figure 1, each host had host-specific parameters. these could include such things as the hostname option, the name of a file to upload (the filename parameter) and the address of the server from which to upload the file (the next-server parameter). in general, any parameter can appear anywhere that parameters are allowed, and will be applied according to the scope in which the parameter appears. slay, scope. ๐
imagine that you have a site with a lot of NCD X-Terminals. these terminals come in a variety of models, and you want to specify the boot files for each model. one way to do this would be to have host declarations for each server and group them by model:
group {
filename "Xncd19r";
next-server ncd-booter;
host ncd1 { hardware ethernet 0:c0:c3:49:2b:57; }
host ncd4 { hardware ethernet 0:c0:c3:80:fc:32; }
host ncd8 { hardware ethernet 0:c0:c3:22:46:81; }
}
group {
filename "Xncd19c";
next-server ncd-booter;
host ncd2 { hardware ethernet 0:c0:c3:88:2d:81; }
host ncd3 { hardware ethernet 0:c0:c3:00:14:11; }
}
group {
filename "XncdHMX";
next-server ncd-booter;
host ncd1 { hardware ethernet 0:c0:c3:11:90:23; }
host ncd4 { hardware ethernet 0:c0:c3:91:a7:8; }
host ncd8 { hardware ethernet 0:c0:c3:cc:a:8f; }
}
like, hello?? the way that each group just gets its own filename and its own next-server and its own little squad of MAC addresses? grouped by model, organized, immaculate ๐ฆโจ
๐ ADDRESS POOLS โจ
ok so the pool and pool6 declarations are how you carve out a bunch of addresses and treat them differently from another bunch โ even when they're literally on the same network segment or subnet. like, same neighborhood, different vibes ๐
why would you even โ say you wanna hand a big set of addresses to DHCP clients that are actually registered with your server, and a smaller set (possibly with short lease times, sorry bestie ๐) to the unknown clients. if you've got a firewall, you might be able to let one pool's addresses reach the Internet while another pool's addresses get nada โ which lowkey peer-pressures users into registering their DHCP clients ๐. to do that, you'd set up a pair of pool declarations:
subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.254;
# Unknown clients get this pool.
pool {
option domain-name-servers bogus.example.com;
max-lease-time 300;
range 10.0.0.200 10.0.0.253;
allow unknown-clients;
}
# Known clients get this pool.
pool {
option domain-name-servers ns1.example.com, ns2.example.com;
max-lease-time 28800;
range 10.0.0.5 10.0.0.199;
deny unknown-clients;
}
}
and yes โ you can go full entirely different subnets for known vs unknown clients. address pools live at the level of shared networks, so address ranges inside pool declarations can totally be on different subnets. iconic ๐
permit lists, bestie ๐ โ like you saw up there, pools can have permit lists that control which clients get in and which get told to try again never. every entry in a pool's permit list starts with the allow or deny keyword. the rules, plainly:
- if a pool has a permit list, only clients matching specific entries on that list are eligible to be assigned addresses from it.
- if a pool has a deny list, only clients that don't match any entry on it are eligible.
- if both exist, then only clients that match the permit list and don't match the deny list get access. both bouncers, both check your name ๐ซถ
now, pool6 is basically pool's sibling. currently it's only allowed inside a subnet6 declaration, and it may not be included directly in a shared network declaration ๐. on top of range6 it also lets you include the prefix6 statement. and you can put range6 statements for both NA and TA plus prefix6 statements all inside a single pool6 โ one pool, whole menu ๐
๐ฒ DYNAMIC ADDRESS ALLOCATION ๐ซ
ok so real talk: address allocation actually only happens when a client is in the INIT state and has sent a DHCPDISCOVER. that's it, that's the trigger.
if the client thinks it already has a valid lease and sends a DHCPREQUEST to start or renew it, your server has exactly three choices, no fourth option, no secret menu:
- ignore the
DHCPREQUESTentirely ๐ - send a
DHCPNAKto tell the client to stop using the address ๐ - send a
DHCPACK, telling the client to go ahead and use the address for a while โ
here's how the server picks: if it finds the address the client is requesting, and that address is available to the client, it sends a DHCPACK. if the address is no longer available, or the client isn't permitted to have it, it sends a DHCPNAK. if the server knows nothing about the address, it stays silent โ except when the address is wrong for the network segment the client is attached to and the server is authoritative for that network segment, in which case it sends a DHCPNAK even though it doesn't know about the address. petty but correct ๐
there may be a host declaration matching the client's identification ๐. if that host declaration contains a fixed-address declaration listing an IP address that's valid for the network segment the client is connected to, then the DHCP server will never do dynamic address allocation. nope. in that case the client is required to take the address specified in the host declaration. if the client sends a DHCPREQUEST for some other address, the server responds with a DHCPNAK. it's not a suggestion, it's a lifestyle ๐ฅ
when the server allocates a new address (and remember โ this only happens if the client sent a DHCPDISCOVER), it first checks: does this client already have a valid lease on an IP address? or is there an old IP address the client had before that hasn't been reassigned yet? if so, the server takes that address and checks whether the client is still permitted to use it. if the client is no longer permitted, the lease is freed โ provided the server thought it was still in use โ because the fact that the client sent a DHCPDISCOVER proves to the server that the client isn't using that lease anymore ๐ง
if no existing lease is found, or the client is forbidden from getting the existing lease, the server goes shopping in the list of address pools for the network segment the client is attached to, looking for a lease that's not in use and that the client is permitted to have ๐๏ธ. it walks through each pool declaration in sequence (and psst โ all range declarations that appear outside of pool declarations get grouped into a single pool with no permit list). if the pool's permit list allows the client to get an address from that pool, the pool gets examined to see if there's an address available. if yes, the client is tentatively assigned that address. otherwise, on to the next pool. and if no addresses are found that can be assigned to the client at all? no response is sent. silence. ghosted ๐ญ
if an address is found that the client is permitted to have and that has never been assigned to any client before, it's immediately allocated to the client ๐. but if the address is available for allocation and has previously been assigned to a different client, the server keeps looking โ hoping to find one that's never been assigned to anybody before. fresh address energy โจ
important ordering tea โ โ the DHCP server generates the list of available IP addresses from a hash table. that means the addresses are not sorted in any particular order, so there is genuinely no way to predict the order in which the server will allocate IP addresses. if you're a user of previous versions of the ISC DHCP server, you may have gotten accustomed to addresses being allocated in ascending order โ but that is no longer possible, and there is no way to configure this behavior with version 3 of the ISC DHCP server. periodt ๐
๐ก๏ธ IP ADDRESS CONFLICT PREVENTION ๐
the DHCP server checks IP addresses to see if they're in use before handing them to clients. how? it sends an ICMP Echo request message to the IP address being allocated. if no ICMP Echo reply comes back within a second, the address is assumed free โ
.
this only happens for leases that have been specified in range statements, and only when the lease is thought by the DHCP server to be free โ i.e. the DHCP server or its failover peer has not listed the lease as in use. so it's not checking everything, bestie, just the eligible ones ๐
if a response does come back to the ICMP Echo request, the DHCP server assumes there's a configuration error โ somebody on the network is using that IP and they are not a DHCP client ๐ฑ. it marks the address as abandoned and will not assign it to clients. that lease stays abandoned for a minimum of abandon-lease-time seconds.
so what if a DHCP client tries to get an IP, nothing's available, but hey โ there are abandoned IP addresses lying around? the server will attempt to reclaim one ๐ ๏ธ. it marks one IP address as free, then runs the exact same ICMP Echo request check described above. if there's no answer to the ICMP Echo request, the address is assigned to the client. slay, recycling ๐
one thing though: the DHCP server does not cycle through abandoned IP addresses if the first IP address it tries to reclaim is free. instead, when the next DHCPDISCOVER comes in from the client, it'll attempt a new allocation using the same method described here, and will typically try a new IP address. so don't expect it to work through the whole abandoned pile in one go ๐
๐ค DHCP FAILOVER ๐ฏโโ๏ธ
this version of the ISC DHCP server supports the DHCP failover protocol as documented in draft-ietf-dhc-failover-12.txt ๐.
โ ๏ธ real talk: this is not a final protocol document, and they have not done interoperability testing with other vendors' implementations of this protocol. so you must not assume this implementation conforms to the standard. if you wanna use failover, make sure both failover peers are running the same version of the ISC DHCP server. no cap ๐
the failover protocol lets two DHCP servers โ and no more than two, that's the whole limit โ share a common address pool. each server will have about half of the available IP addresses in the pool at any given time for allocation ๐ฐ. if one server fails, the other keeps renewing leases out of the pool, and allocates new addresses out of the roughly half of available addresses it had when comms with the other server went poof ๐.
during a prolonged failure, it's possible to tell the remaining server that the other server is down โ in which case the remaining server will (over time) reclaim all the addresses the other server had available for allocation and start reusing them. this is called putting the server into the PARTNER-DOWN state ๐
you can put the server into the PARTNER-DOWN state either by using the omshell (1) command, or by stopping the server, editing the last failover state declaration in the lease file, and restarting the server. if you go with that last method, change the "my state" line to:
failover peer name state {
my state partner-down;.
peer state state at date;
}
only the "my state" part is required to be changed as shown above ๐ซถ
when the other server comes back online, it should automatically detect that it's been offline and request a complete update from the server that was running in the PARTNER-DOWN state โ and then both servers resume processing together ๐
๐ DANGER ZONE โ it is possible to get into a genuinely dangerous situation: if you put one server into thePARTNER-DOWNstate, and then that server goes down, and the other server comes back up, the other server will not know that the first server was in thePARTNER-DOWNstate, and may issue addresses previously issued by the other server to different clients โ resulting in IP address conflicts. so before putting a server intoPARTNER-DOWNstate, make sure the other server will not restart automatically. seriously. protect your pool ๐
last thing: the failover protocol defines a primary server role and a secondary server role ๐. there are some differences in how primaries and secondaries act, but most of the differences just come down to giving each peer a way to behave in the opposite way from the other. so one server must be configured as primary and the other must be configured as secondary โ and honestly it doesn't matter too much which one is which ๐
โจ FAILOVER STARTUP โจ
Okay so picture this, bestie: a server boots up and it has never talked to its failover peer before. Before it can serve a single client, it has to establish communications with its failover peer and synchronize with it. That's the whole vibe check. This can happen because you just configured your DHCP servers to perform failover for the very first time, or because one of your failover servers failed catastrophically and lost its database. ๐
The initial recovery process is designed to ensure that when one failover peer loses its database and then resynchronizes, any leases that the failed server gave out before it failed will be honored. When the failed server starts up, it notices that it has no saved failover state, and attempts to contact its peer.
When it has established contact, it asks the peer for a complete copy of its peer's lease database. The peer then sends its complete database, and sends a message indicating that it is done. The failed server then waits until MCLT has passed, and once MCLT has passed both servers make the transition back into normal operation. This waiting period ensures that any leases the failed server may have given out while out of contact with its partner will have expired. โณ
While the failed server is recovering, its partner remains in the partner-down state, which means that it is serving all clients. The failed server provides no service at all to DHCP clients until it has made the transition into normal operation.
In the case where both servers detect that they have never before communicated with their partner, they both come up in this recovery state and follow the procedure we have just described. In this case, no service will be provided to DHCP clients until MCLT has expired. iykyk ๐ญ
๐ CONFIGURING FAILOVER ๐
In order to configure failover, you need to write a peer declaration that configures the failover protocol, and you need to write peer references in each pool declaration for which you want to do failover. You do not have to do failover for all pools on a given network segment.
But bestie, listen: you must not tell one server it's doing failover on a particular address pool and tell the other it is not. You must not have any common address pools on which you are not doing failover. That's giving configuration chaos, fr fr. A pool declaration that utilizes failover would look like this:
pool {
failover peer "foo";
pool specific parameters
};
Dynamic BOOTP leases are not compatible with failover, and, as such, you need to disallow BOOTP in pools that you are using failover for. ๐ซ
The server currently does very little sanity checking, so if you configure it wrong, it will just fail in odd ways. I would recommend therefore that you either do failover or don't do failover, but don't do any mixed pools. Also, use the same master configuration file for both servers, and have a separate file that contains the peer declaration and includes the master file. This will help you to avoid configuration mismatches. As our implementation evolves, this will become less of a problem.
A basic sample dhcpd.conf file for a primary server might look like this:
failover peer "foo" {
primary;
address anthrax.rc.example.com;
port 647;
peer address trantor.rc.example.com;
peer port 847;
max-response-delay 60;
max-unacked-updates 10;
mclt 3600;
split 128;
load balance max seconds 3;
}
include "/etc/dhcpd.master";
The statements in the peer declaration are as follows:
๐ The primary and secondary statements
[ primary | secondary ];
This determines whether the server is primary or secondary, as described earlier under DHCP FAILOVER. Primary has main character energy here, obviously. ๐
๐ The address statement
address address;
The address statement declares the IP address or DNS name on which the server should listen for connections from its failover peer, and also the value to use for the DHCP Failover Protocol server identifier. Because this value is used as an identifier, it may not be omitted. Periodt. ๐
๐ฆ The peer address statement
peer address address;
The peer address statement declares the IP address or DNS name to which the server should connect to reach its failover peer for failover messages.
๐ธ The port statement
port port-number;
The port statement declares the TCP port on which the server should listen for connections from its failover peer. This statement may be omitted, in which case the IANA assigned port number 647 will be used by default.
๐ง The peer port statement
peer port port-number;
The peer port statement declares the TCP port to which the server should connect to reach its failover peer for failover messages. This statement may be omitted, in which case the IANA assigned port number 647 will be used by default.
๐ฅ The max-response-delay statement
max-response-delay seconds;
The max-response-delay statement tells the DHCP server how many seconds may pass without receiving a message from its failover peer before it assumes that connection has failed. This number should be small enough that a transient network failure that breaks the connection will not result in the servers being out of communication for a long time, but large enough that the server isn't constantly making and breaking connections. This parameter must be specified. No cap.
โญ The max-unacked-updates statement
max-unacked-updates count;
The max-unacked-updates statement tells the remote DHCP server how many BNDUPD messages it can send before it receives a BNDACK from the local system. We don't have enough operational experience to say what a good value for this is, but 10 seems to work. This parameter must be specified.
๐ The mclt statement
mclt seconds;
The mclt statement defines the Maximum Client Lead Time. It must be specified on the primary, and may not be specified on the secondary. This is the length of time for which a lease may be renewed by either failover peer without contacting the other. The longer you set this, the longer it will take for the running server to recover IP addresses after moving into PARTNER-DOWN state. The shorter you set it, the more load your servers will experience when they are not communicating. A value of something like 3600 is probably reasonable, but again bear in mind that we have no real operational experience with this. lowkey important ๐ซถ
๐ The split statement
split bits;
The split statement specifies the split between the primary and secondary for the purposes of load balancing. Whenever a client makes a DHCP request, the DHCP server runs a hash on the client identification, resulting in value from 0 to 255. This is used as an index into a 256 bit field. If the bit at that index is set, the primary is responsible. If the bit at that index is not set, the secondary is responsible. The split value determines how many of the leading bits are set to one. So, in practice, higher split values will cause the primary to serve more clients than the secondary. Lower split values, the converse. Legal values are between 0 and 256 inclusive, of which the most reasonable is 128. Note that a value of 0 makes the secondary responsible for all clients and a value of 256 makes the primary responsible for all clients. ๐
๐ The hba statement
hba colon-separated-hex-list;
The hba statement specifies the split between the primary and secondary as a bitmap rather than a cutoff, which theoretically allows for finer-grained control. In practice, there is probably no need for such fine-grained control, however. An example hba statement:
hba ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00;
This is equivalent to a split 128; statement, and identical. The following two examples are also equivalent to a split of 128, but are not identical:
hba aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:
aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa;
hba 55:55:55:55:55:55:55:55:55:55:55:55:55:55:55:55:
55:55:55:55:55:55:55:55:55:55:55:55:55:55:55:55;
They are equivalent, because half the bits are set to 0, half are set to 1 (0xa and 0x5 are 1010 and 0101 binary respectively) and consequently this would roughly divide the clients equally between the servers. They are not identical, because the actual peers this would load balance to each server are different for each example.
You must only have split or hba defined, never both. For most cases, the fine-grained control that hba offers isn't necessary, and split should be used. ๐
๐ซถ The load balance max seconds statement
load balance max seconds seconds;
This statement allows you to configure a cutoff after which load balancing is disabled. The cutoff is based on the number of seconds since the client sent its first DHCPDISCOVER or DHCPREQUEST message, and only works with clients that correctly implement the secs field - fortunately most clients do. We recommend setting this to something like 3 or 5. The effect of this is that if one of the failover peers gets into a state where it is responding to failover messages but not responding to some client requests, the other failover peer will take over its client load automatically as the clients retry.
It is possible to disable load balancing between peers by setting this value to 0 on both peers. Bear in mind that this means both peers will respond to all DHCPDISCOVERs or DHCPREQUESTs. balanced? maybe not โ๏ธ
๐ The auto-partner-down statement
auto-partner-down seconds;
This statement instructs the server to initiate a timed delay upon entering the communications-interrupted state (any situation of being out-of-contact with the remote failover peer). At the conclusion of the timer, the server will automatically enter the partner-down state. This permits the server to allocate leases from the partner's free lease pool after an STOS+MCLT timer expires, which can be dangerous if the partner is in fact operating at the time (the two servers will give conflicting bindings).
โ ๏ธ Think very carefully before enabling this feature. The partner-down and communications-interrupted states are intentionally segregated because there do exist situations where a failover server can fail to communicate with its peer, but still has the ability to receive and reply to requests from DHCP clients. In general, this feature should only be used in those deployments where the failover servers are directly connected to one another, such as by a dedicated hardwired link ("a heartbeat cable"). danger zone, bestie ๐ญ
A zero value disables the auto-partner-down feature (and yeah, thatโs also the default ๐ ), and any positive value is literally the number of seconds to wait before automatically entering partner-down. โณ
๐ The Failover pool balance statements ๐
max-lease-misbalance percentage;
max-lease-ownership percentage;
min-balance seconds;
max-balance seconds;
This version of the DHCP Server evaluates pool balance on a schedule, not on demand as leases get allocated. The old on-demand way was lowkey klunky once a pool got misbalanced all the way to total saturation โ like, when any server ran out of leases to assign, it also lost its ability to notice it had run dry. ๐ญ
So to understand pool balance, bestie, we gotta define some elements first. There are โfreeโ and โbackupโ leases. Both of these are called โfree state leasesโ. And free and backup are โthe free statesโ for the purpose of this document. The difference is that only the primary may allocate from free leases unless under special circumstances, and only the secondary may allocate backup leases. ๐ซถ
When pool balance is performed, the only plausible expectation is to provide a 50/50 split of the free state leases between the two servers. Why? Because no one can predict which server will fail, regardless of the relative load placed on the two servers, so giving each server half the leases gives both servers the same amount of โfailure enduranceโ. Therefore, thereโs no way to configure any different behaviour, outside of some very small windows weโll describe shortly. โจ
The first thing calculated on any pool balance run is a value called lts, or "Leases To Send". Simply put, itโs the difference in the count of free and backup leases, divided by two. For the secondary, itโs the difference in the backup and free leases, divided by two. The resulting value is signed: if itโs positive, the local server is expected to hand out leases to retain a 50/50 balance. If itโs negative, the remote server would need to send leases to balance the pool. Once the lts value reaches zero, the pool is perfectly balanced (give or take one lease in the case of an odd number of total free state leases). ๐ง
The current approach is still something of a hybrid of the old approach, marked by the presence of the max-lease-misbalance statement. This parameter configures what used to be a 10% fixed value in previous versions: if lts is less than free+backup * max-lease-misbalance percent, then the server will skip balancing a given pool (it wonโt bother moving any leases, even if some leases "should" be moved). The meaning of this value is also somewhat overloaded, though, in that it also governs the estimation of when to attempt to balance the pool (which may then also be skipped over). The oldest leases in the free and backup states are examined. The time they have resided in their respective queues is used as an estimate to indicate how much time it is probable it would take before the leases at the top of the list would be consumed (and thus, how long it would take to use all leases in that state). This percentage is directly multiplied by this time, and fit into the schedule if it falls within the min-balance and max-balance configured values. The scheduled pool check time is only moved in a downwards direction, it is never increased. Lastly, if the lts is more than double this number in the negative direction, the local server will โpanicโ and transmit a Failover protocol POOLREQ message, in the hopes that the remote system will be woken up into action. ๐ฅ
Once the lts value exceeds the max-lease-misbalance percentage of total free state leases as described above, leases are moved to the remote server. This is done in two passes. ๐
In the first pass, only leases whose most recent bound client would have been served by the remote server โ according to the Load Balance Algorithm (see above split and hba configuration statements) โ are given away to the peer. This first pass will happily continue to give away leases, decrementing the lts value by one for each, until the lts value has reached the negative of the total number of leases multiplied by the max-lease-ownership percentage. So itโs through this value that you can permit a small misbalance of the lease pools โ for the purpose of giving the peer more than a 50/50 share of leases, in the hopes that their clients might some day return and be allocated by the peer (operating normally). This process is referred to as โMAC Address Affinityโ, but this is somewhat misnamed: it applies equally to DHCP Client Identifier options. Note also that affinity is applied to leases when they enter the state free from expired or released. In this case also, leases will not be moved from free to backup if the secondary already has more than its share. ๐
The second pass is only entered into if the first pass fails to reduce the lts underneath the total number of free state leases multiplied by the max-lease-ownership percentage. In this pass, the oldest leases are given over to the peer without second thought about the Load Balance Algorithm, and this continues until the lts falls under this value. In this way, the local server will also happily keep a small percentage of the leases that would normally load balance to itself. ๐
So, the max-lease-misbalance value acts as a behavioural gate. Smaller values will cause more leases to transition states to balance the pools over time, higher values will decrease the amount of change (but may lead to pool starvation if thereโs a run on leases). โ๏ธ
The max-lease-ownership value permits a small (percentage) skew in the lease balance of a percentage of the total number of free state leases. ๐
Finally, the min-balance and max-balance make certain that a scheduled rebalance event happens within a reasonable timeframe (not to be thrown off by, for example, a 7 year old free lease). ๐ฐ๏ธ
Plausible values for the percentages lie between 0 and 100, inclusive, but values over 50 are indistinguishable from one another (once lts exceeds 50% of the free state leases, one server must therefore have 100% of the leases in its respective free state). It is recommended to select a max-lease-ownership value that is lower than the value selected for the max-lease-misbalance value. max-lease-ownership defaults to 10, and max-lease-misbalance defaults to 15. ๐
Plausible values for the min-balance and max-balance times also range from 0 to (2^32)-1 (or the limit of your local time_t value), but default to values 60 and 3600 respectively (to place balance events between 1 minute and 1 hour). โญ
๐ CLIENT CLASSING ๐
Clients can be separated into classes, and treated differently depending on what class theyโre in. This separation can be done either with a conditional statement, or with a match statement within the class declaration. Itโs possible to specify a limit on the total number of clients within a particular class or subclass that may hold leases at one time, and itโs possible to specify automatic subclassing based on the contents of the client packet. ๐ฆ
Classing support for DHCPv6 clients was added in 4.3.0. It follows the same rules as for DHCPv4 except that support for billing classes has not been added yet. ๐
To add clients to classes based on conditional evaluation, you can specify a matching expression in the class statement:
class "ras-clients" {
match if substring (option dhcp-client-identifier, 1, 3) = "RAS";
}
Please note that the values used in match expressions may only come from data or options that are part of the client packet. Itโs not possible to use values constructed through one or more executable statements. This stems from the fact that client classification occurs before any statements are executed. Attempting to do so will yield indeterminate results. ๐
Note that whether you use matching expressions or add statements (or both) to classify clients, you must always write a class declaration for any class that you use. If there will be no match statement and no in-scope statements for a class, the declaration should look like this:
class "ras-clients" {
}
๐ธ SUBCLASSES ๐ธ
Okay so bestie, not only can you declare classes โ you can declare subclasses, and this is where it gets cute. A subclass is basically a class with the same name as a regular class, but it comes with a specific submatch expression that gets hashed so matching is stupid fast. It's honestly just a speed hack โ the real difference between, say, five classes with match expressions versus one class with five subclasses is that finding the subclasses is quicker. That's it. That's the whole vibe. Here's how subclasses do:
class "allocation-class-1" {
match pick-first-value (option dhcp-client-identifier, hardware);
}
class "allocation-class-2" {
match pick-first-value (option dhcp-client-identifier, hardware);
}
subclass "allocation-class-1" 1:8:0:2b:4c:39:ad;
subclass "allocation-class-2" 1:8:0:2b:a9:cc:e3;
subclass "allocation-class-1" 1:0:0:c4:aa:29:44;
subnet 10.0.0.0 netmask 255.255.255.0 {
pool {
allow members of "allocation-class-1";
range 10.0.0.11 10.0.0.50;
}
pool {
allow members of "allocation-class-2";
range 10.0.0.51 10.0.0.100;
}
}
So the data sitting after the class name in a subclass declaration? That's a constant value used for matching against the class's match expression. When the server does class matching, it evaluates the match expression, then looks that result up in the hash table. Found a match? Congrats, the client is now a member of both the class and the subclass. Two for one, we love to see it ๐
Subclasses can be declared with or without scope, fyi. In the example above, the whole point of the subclass is just to let some clients into one address pool while other clients get the other pool โ so those subclasses are declared without scopes. But if part of the subclass's purpose was to define different parameter values for certain clients, then yeah, you might wanna declare some subclasses with scopes.
Speaking of which โ in that same example, if you had one single client that needed some config parameters while most didn't, you'd write this subclass declaration for that client:
subclass "allocation-class-2" 1:08:00:2b:a1:11:31 {
option root-path "samsara:/var/diskless/alphapc";
filename "/tftpboot/netbsd.alphapc-diskless";
}
So in this example we used subclassing to control address allocation on a per-client basis. But the tea is: you can also use subclassing in ways that are not specific to clients โ for example, using the value of the vendor-class-identifier option to figure out what values to send in the vendor-encapsulated-options option. There's an example of that under the VENDOR ENCAPSULATED OPTIONS head in the dhcp-options(5) manual page. Go look, iykyk ๐ฆ
๐ PER-CLASS LIMITS ON DYNAMIC ADDRESS ALLOCATION ๐
You can cap how many clients in a class get to hold leases, and the effect is basically making it difficult for a new client in that class to snag an address. Once a class with a limit hits that limit, the only way a new client in that class gets a lease is if an existing client gives theirs up โ either by letting it expire or by sending a DHCPRELEASE packet. No shortcuts, no line-jumping ๐
Classes with lease limits look like this:
class "limited-1" {
lease limit 4;
}
That gives you a class where a maximum of four members may hold a lease at any one time. Periodt. โจ
๐ฆ SPAWNING CLASSES ๐ฆ
Okay this one is genuinely iconic โ you can declare a spawning class. A spawning class is a class that automatically produces subclasses based on whatever the client sends. The reason spawning classes exist at all was to make lease-limited classes possible on the fly.
The envisioned application (their words, not mine) is a cable-modem environment where the ISP wants to give clients at a particular site more than one IP address โ but does not want to give those clients their own subnet, and also doesn't want to hand them an unlimited number of IP addresses from the network segment they're connected to. Balance, bestie ๐
So, many cable modem head-end systems can be configured to add a Relay Agent Information option to DHCP packets when they relay them to the DHCP server. These systems typically add a circuit ID or remote ID option that uniquely identifies the customer site. To take advantage of that, you write a class declaration like:
class "customer" {
spawn with option agent.circuit-id;
lease limit 4;
}
Now here's the flow: whenever a request comes in from a customer site, the circuit ID option gets checked against the class's hash table. If a subclass is found that matches the circuit ID โ the client is classified in that subclass and treated accordingly. If no subclass matches the circuit ID โ a new one gets created and logged in the dhcpd.leases file, and the client gets classified in this shiny new class. Once classified, the client is treated according to the class's rules โ including, in this case, being subject to the per-site limit of four leases. Slay ๐
And no, the subclass spawning mechanism is not restricted to relay agent options โ this particular example is only here because it's a fairly straightforward one. Don't @ me.
๐ COMBINING MATCH, MATCH IF AND SPAWN WITH ๐
Sometimes it's useful to use one expression to slap a client into a particular class, and a second expression to drop it into a subclass of that class. You do this by combining the match if and spawn with statements โ or the match if and match statements. Like so:
class "jr-cable-modems" {
match if option dhcp-vendor-identifier = "jrcm";
spawn with option agent.circuit-id;
lease limit 4;
}
class "dv-dsl-modems" {
match if option dhcp-vendor-identifier = "dvdsl";
spawn with option agent.circuit-id;
lease limit 16;
}
This lets you have two classes that both use the exact same spawn with expression without the clients in the two classes getting all confused with each other. Communication! Boundaries! We love a healthy separation ๐ซถ
โญ DYNAMIC DNS UPDATES โญ
The DHCP server can dynamically update the Domain Name System, which is honestly kind of a big deal. Inside the configuration files you get to define exactly how you want the Domain Name System updated. These updates are RFC 2136 compliant, so any DNS server that supports RFC 2136 should be able to accept updates from the DHCP server. No cap.
There are two DNS schemes implemented:
- The interim option โ based on draft revisions of the DDNS documents.
- The standard option โ based on the RFCs for DHCP-DNS interaction and DHCIDs.
A third option, ad-hoc, was deprecated and has now been removed from the code base ๐ so don't come looking for it. The DHCP server must be configured to use one of the two currently-supported methods, or to not do DNS updates at all. Pick a lane bestie.
New installations should use the standard option. Older installations may want to keep using the interim option for backwards compatibility with the DNS database until the database can be updated. You do this with the ddns-update-style configuration parameter. ๐
๐ THE DNS UPDATE SCHEME ๐
ok so both the interim and the standard DNS update schemes are lowkey doing what the IETF told them to โ the interim one was based on the drafts that were still in progress at the time, while the standard is based on the RFCs that actually got finished. The standard RFCs are:
and the corresponding drafts were:
draft-ietf-dnsext-dhcid-rr-??.txtdraft-ietf-dhc-fqdn-option-??.txtdraft-ietf-dhc-ddns-resolution-??.txt
The basic framework for the two schemes is, like, super similar โ the main material difference is that the standard version uses a DHCID RR while the interim version uses a TXT RR. The format of the TXT record bears a resemblance to the DHCID RR but it is not equivalent (MD5 vs SHA2, field length differences etc). fr fr, don't confuse them ๐ซถ
In these two schemes the DHCP server doesn't necessarily always update both the A and the PTR records. The FQDN option includes a flag which, when sent by the client, says "hey I wanna update my own A record ๐". In that case the server can be configured either to honor the client's intentions or to ignore them. That's done with the statement allow client-updates; โ or the statement ignore client-updates;. By default, client updates are allowed.
So if the server is configured to allow client updates, and the client sends a fully-qualified domain name in the FQDN option, the server will use that name the client sent in the FQDN option to update the PTR record. Example time, bestie ๐ let's say the client is a visitor from the "radish.org" domain, and its hostname is "jschmoe". The server is for the "example.org" domain. The DHCP client indicates in the FQDN option that its FQDN is "jschmoe.radish.org.". It also indicates that it wants to update its own A record. So the DHCP server does not attempt to set up an A record for the client, but it does set up a PTR record for the IP address it assigns the client, pointing at jschmoe.radish.org. Once the DHCP client has an IP address, it can go update its own A record โ assuming the "radish.org" DNS server will let it do so โจ
If the server is configured not to allow client updates, or if the client doesn't want to do its own update, the server will simply choose a name for the client. By default, the server picks from these three values:
- fqdn option (if present)
- hostname option (if present)
- Configured hostname option (if defined).
If those defaults for choosing the host name are not it for you, you can write your own statement to set the ddns-hostname variable however you want ๐ If none of the above are found, the server will use the host declaration name (if there is one) and use-host-decl-names is on.
It will use its own domain name for the client. Then it updates both the A and PTR record, using the name it chose for the client. And if the client sends a fully-qualified domain name in the fqdn option, the server uses only the leftmost part of the domain name โ in the example above, "jschmoe" instead of "jschmoe.radish.org". periodt ๐
Further, if the ignore client-updates; directive is used, then the server will in addition send a response in the DHCP packet, using the FQDN Option, that implies to the client that it should perform its own updates if it chooses to. With deny client-updates;, a response is sent which indicates the client may not perform updates.
Both the standard and interim options also include a method that lets more than one DHCP server update the DNS database without accidentally deleting A records that shouldn't be deleted, nor failing to add A records that should be added. No cap. For the standard option it goes like this:
When the DHCP server issues a client a new lease, it creates a text string that is an SHA hash over the DHCP client's identification (see RFCs 4701 & 4702 for details). The update attempts to add an A record with the name the server chose, plus a DHCID record containing the hashed identifier string (hashid). If this update succeeds, the server is done ๐
If the update fails because the A record already exists, then the DHCP server attempts to add the A record with the prerequisite that there must be a DHCID record in the same name as the new A record, and that DHCID record's contents must be equal to hashid. If this update succeeds, then the client has its A record and PTR record. If it fails, then the name the client has been assigned (or requested) is in use and can't be used by that client. At that point the DHCP server gives up trying to do a DNS update for the client until the client chooses a new name ๐
The server also does not update very aggressively. Because each DNS update involves a round trip to the DNS server, there's a cost associated with doing updates even if they don't actually modify the DNS database. So the DHCP server tracks whether or not it has updated the record in the past (this info is stored on the lease) and doesn't attempt to update records that it thinks it's already updated.
โ ๏ธ lowkey a trap: this can lead to cases where the DHCP server adds a record, and then the record gets deleted through some other mechanism, but the server never again updates the DNS because it thinks the data is already there. In this case the data can be removed from the lease through operator intervention, and once that's done, the DNS will be updated the next time the client renews ๐
The interim DNS update scheme was written before the RFCs were finalized and does not quite follow them. The RFCs call for a new DHCID RRtype while the interim DNS update scheme uses a TXT record. On top of that, the ddns-resolution draft called for the DHCP server to put a DHCID RR on the PTR record, but the interim update method doesn't do this. In the final RFC this requirement was relaxed such that a server may add a DHCID RR to the PTR record.
๐ DDNS IN DUAL STACK ENVIRONMENTS ๐
As described in RFC 4703, section 5.2, in order to perform DDNS in dual stack environments, both IPv4 and IPv6 servers would need to be configured to use the standard update style, and participating IPv4 clients MUST convey DUIDs as described in RFC 4361, section 6.1., in their dhcp-client-identifiers. ๐
In a nutshell, this mechanism is intended to use globally unique DUIDs to identify both IPv4 and IPv6 clients, and where a device has both IPv4 and IPv6 leases it's identified by the same DUID. That lets a dual stack client use the same FQDN for both mappings, while being protected from updates for other clients by the rules of conflict detection ๐ฆ
However โ and this is the plot twist โ not all IPv4 clients implement this behavior, which makes supporting them in dual stack environments problematic. To address this issue, ISC DHCP (as of 4.4.0) supports a new mode of DDNS conflict resolution referred to as Dual Stack Mixed Mode (DSMM).
The concept behind DSMM is relatively simple. All dhcp servers of one protocol (IPv4 or v6) use one ddns-update-style (interim or standard), while all servers of the "other" protocol use the "other" ddns-udpate-style (yes, that's how it's spelled in the source, bestie, we don't fix it ๐). This way, all servers of a given protocol are using the same record type (TXT or DHCID) for their DHCID RR entries. That allows conflict detection to be enforced within each protocol without interfering with the other's entries โจ
DSMM modifications now ensure that IPv4 DSMM servers only ever modify A records, their associated PTR records and DHCID records, while DSMM IPv6 servers only modify AAAA records, their associated PTR records, and DHCID records.
๐ Note that DSMM is not a perfect solution โ it's a compromise that can work well provided all participating DNS updaters play by DSMM rules. As with anything else in life, it only works as well as those who participate behave.
While conflict detection is enabled by default, DSMM is not. To enable DSMM, both update-conflict-detection and ddns-dual-stack-mixed-mode must be true.
๐ PROTECTING DNS ENTRIES FOR STATIC CLIENTS ๐
Built into conflict resolution is the protection of manually made entries for static clients. Per the rules of conflict resolution, a DNS updater may not alter forward DNS entries unless there is a DHCID RR which matches for whom the update is being made. So like โ any forward DNS entries without a corresponding DHCID RR cannot be altered by such an updater. iconic behavior tbh ๐ซถ
In some environments, it may be desirable to use only this aspect of conflict resolution and allow DNS updaters to overwrite entries for dynamic clients regardless of what client owns them. In other words: the presence or lack of a DHCID RR is what determines whether entries may or may not be overwritten. Whether or not the client matches the data value of the DHCID RR is irrelevant. This behavior, off by default, can be configured through the parameter ddns-guard-id-must-match. As with DSMM, this behavior can only be enabled if conflict resolution is enabled.
โ ๏ธ This behavior should be considered carefully before electing to use it. Like, actually think about it, bestie. ๐ญ
There's an additional parameter that can be used with DSMM: ddns-other-guard-is-dynamic. When enabled along with DSMM, a server will regard the presence of a DHCID RR of the other style type as indicating that the forward DNS entries for that FQDN should be dynamic and may be overwritten. For example, such a server using interim style could overwrite the DNS entries for an FQDN if there is only a DHDID type DHDID RR for the FQDN (yep, that's a typo in the original for DHCID โ we keep it, we don't erase history ๐). Essentially, if there are dynamic entries for one protocol, that's enough to overcome the static protection of entries for the other protocol.
โ ๏ธ This behavior warrants careful consideration before electing to use it. seriously. look before you leap ๐
๐ DYNAMIC DNS UPDATE SECURITY ๐
okay bestie, real talk: when you set your DNS server up to allow updates from the DHCP server, you may be exposing it to unauthorized updates. To avoid this, you should use TSIG signatures โ a method of cryptographically signing updates using a shared secret key. As long as you protect the secrecy of this key, your updates should also be secure. ๐
๐จ Important caveat: Note, however, that the DHCP protocol itself provides no security, and that clients can therefore provide information to the DHCP server which the DHCP server will then use in its updates, with the constraints described previously.
The DNS server must be configured to allow updates for any zone that the DHCP server will be updating. For example, let us say that clients in the sneedville.edu domain will be assigned addresses on the 10.10.17.0/24 subnet. In that case, you will need a key declaration for the TSIG key you will be using, and also two zone declarations โ one for the zone containing A records that will be updated and one for the zone containing PTR records โ for ISC BIND, something like this:
key DHCP_UPDATER {
algorithm hmac-md5;
secret pRP5FapFoJ95JEL06sv4PQ==;
};
zone "example.org" {
type master;
file "example.org.db";
allow-update { key DHCP_UPDATER; };
};
zone "17.10.10.in-addr.arpa" {
type master;
file "10.10.17.db";
allow-update { key DHCP_UPDATER; };
};
You will also have to configure your DHCP server to do updates to these zones. To do so, you need to add something like this to your dhcpd.conf file:
key DHCP_UPDATER {
algorithm hmac-md5;
secret pRP5FapFoJ95JEL06sv4PQ==;
};
zone EXAMPLE.ORG. {
primary 127.0.0.1;
key DHCP_UPDATER;
}
zone 17.127.10.in-addr.arpa. {
primary 127.0.0.1;
key DHCP_UPDATER;
}
The primary statement specifies the IP address of the name server whose zone information is to be updated. In addition to the primary statement there are also the primary6, secondary and secondary6 statements:
primary6โ specifies an IPv6 address for the name server.secondaryandsecondary6โ provide additional addresses for name servers to be used if the primary does not respond.
The number of name servers the DDNS code will attempt to use before giving up is limited and is currently set to three.
Note that the zone declarations have to correspond to authority records in your name server โ in the above example, there must be an SOA record for "example.org." and for "17.10.10.in-addr.arpa.". For example, if there were a subdomain "foo.example.org" with no separate SOA, you could not write a zone declaration for "foo.example.org." ๐ซถ
Also keep in mind that zone names in your DHCP configuration should end in a .; this is the preferred syntax. If you do not end your zone name in a ., the DHCP server will figure it out. Also note that in the DHCP configuration, zone names are not encapsulated in quotes where there are in the DNS configuration.
You should choose your own secret key, of course. The ISC BIND 9 distribution comes with a program for generating secret keys called dnssec-keygen. If you are using BIND 9ยดs dnssec-keygen, the above key would be created as follows:
dnssec-keygen -a HMAC-MD5 -b 128 -n USER DHCP_UPDATER
The key name, algorithm, and secret must match that being used by the DNS server. The DHCP server currently supports the following algorithms:
HMAC-MD5
HMAC-SHA1
HMAC-SHA224
HMAC-SHA256
HMAC-SHA384
HMAC-SHA512
You may wish to enable logging of DNS updates on your DNS server. To do so, you might write a logging statement like the following:
logging {
channel update_debug {
file "/var/log/update-debug.log";
severity debug 3;
print-category yes;
print-severity yes;
print-time yes;
};
channel security_info {
file "/var/log/named-auth.info";
severity info;
print-category yes;
print-severity yes;
print-time yes;
};
category update { update_debug; };
category security { security_info; };
};
You must create the /var/log/named-auth.info and /var/log/update-debug.log files before starting the name server. For more information on configuring ISC BIND, consult the documentation that accompanies it. ๐
๐ REFERENCE: EVENTS ๐
There are three kinds of events that can happen regarding a lease, and it is possible to declare statements that occur when any of these events happen. These events are:
- the commit event โ when the server has made a commitment of a certain lease to a client.
- the release event โ when the client has released the server from its commitment.
- the expiry event โ when the commitment expires.
To declare a set of statements to execute when an event happens, you must use the on statement, followed by the name of the event, followed by a series of statements to execute when the event happens, enclosed in braces. โจ
โจ REFERENCE: DECLARATIONS โจ
๐ The include statement
include "filename";
okay so include is that bestie who shows up and is like โI brought the whole file, continue as if I literally typed it here.โ It reads in a named file and processes the contents as though that file were entered in place of the include statement. ๐
๐ฆ The shared-network statement
shared-network name {
[ parameters ]
[ declarations ]
}
The shared-network statement tells the DHCP server that some IP subnets actually share the same physical network. Any subnets in a shared network should be declared within a shared-network statement. Parameters specified in the shared-network statement will be used when booting clients on those subnets unless parameters provided at the subnet or host level override them. ๐
If any subnet in a shared network has addresses available for dynamic allocation, those addresses are collected into a common pool for that shared network and assigned to clients as needed. And hereโs the iconic catch: there is no way to distinguish on which subnet of a shared network a client should boot. ๐
name should be the name of the shared network. This name is used when printing debugging messages, so it should be descriptive for the shared network. The name may have the syntax of a valid domain name (although it will never be used as such), or it may be any arbitrary name, enclosed in quotes. โจ
๐ธ The subnet statement
subnet subnet-number netmask netmask {
[ parameters ]
[ declarations ]
}
The subnet statement gives dhcpd enough information to tell whether or not an IP address is on that subnet. It may also be used to provide subnet-specific parameters and to specify what addresses may be dynamically allocated to clients booting on that subnet. Such addresses are specified using the range declaration. ๐ซถ
The subnet-number should be an IP address or domain name which resolves to the subnet number of the subnet being described. The netmask should be an IP address or domain name which resolves to the subnet mask of the subnet being described. The subnet number, together with the netmask, are sufficient to determine whether any given IP address is on the specified subnet. ๐
Although a netmask must be given with every subnet declaration, it is recommended that if there is any variance in subnet masks at a site, a subnet-mask option statement be used in each subnet declaration to set the desired subnet mask, since any subnet-mask option statement will override the subnet mask declared in the subnet statement. ๐
๐ง The subnet6 statement
subnet6 subnet6-number {
[ parameters ]
[ declarations ]
}
The subnet6 statement gives dhcpd enough information to tell whether or not an IPv6 address is on that subnet6. It may also be used to provide subnet-specific parameters and to specify what addresses may be dynamically allocated to clients booting on that subnet. ๐
The subnet6-number should be an IPv6 network identifier, specified as ip6-address/bits. ๐
๐ The range statement
range [ dynamic-bootp ] low-address [ high-address];
For any subnet on which addresses will be assigned dynamically, there must be at least one range statement. The range statement gives the lowest and highest IP addresses in a range. All IP addresses in the range should be in the subnet in which the range statement is declared. The dynamic-bootp flag may be specified if addresses in the specified range may be dynamically assigned to BOOTP clients as well as DHCP clients. When specifying a single address, high-address can be omitted. ๐ฅ
๐ The range6 statement
range6 low-address high-address;
range6 subnet6-number;
range6 subnet6-number temporary;
range6 address temporary;
For any IPv6 subnet6 on which addresses will be assigned dynamically, there must be at least one range6 statement. The range6 statement can either be the lowest and highest IPv6 addresses in a range6, or use CIDR notation, specified as ip6-address/bits. All IP addresses in the range6 should be in the subnet6 in which the range6 statement is declared. ๐ธ
The temporary variant makes the prefix (by default on 64 bits) available for temporary (RFC 4941) addresses. A new address per prefix in the shared network is computed at each request with an IA_TA option. Release and Confirm ignores temporary addresses. ๐ฆ
Any IPv6 addresses given to hosts with fixed-address6 are excluded from the range6, as are IPv6 addresses on the server itself. ๐
๐ The prefix6 statement
prefix6 low-address high-address / bits;
The prefix6 is the range6 equivalent for Prefix Delegation (RFC 3633). Prefixes of bits length are assigned between low-address and high-address. โจ
Any IPv6 prefixes given to static entries (hosts) with fixed-prefix6 are excluded from the prefix6. ๐
This statement is currently global but it should have a shared-network scope. ๐
๐ซถ The host statement
host hostname {
[ parameters ]
[ declarations ]
}
The host declaration provides a way for the DHCP server to identify a DHCP or BOOTP client. This allows the server to provide configuration information including fixed addresses or, in DHCPv6, fixed prefixes for a specific client. ๐
If it is desirable to be able to boot a DHCP or BOOTP client on more than one subnet with fixed v4 addresses, more than one address may be specified in the fixed-address declaration, or more than one host statement may be specified matching the same client. ๐
The fixed-address6 declaration is used for v6 addresses. At this time it only works with a single address. For multiple addresses specify multiple host statements. ๐ง
If client-specific boot parameters must change based on the network to which the client is attached, then multiple host declarations should be used. The host declarations will only match a client if one of their fixed-address statements is viable on the subnet (or shared network) where the client is attached. Conversely, for a host declaration to match a client being allocated a dynamic address, it must not have any fixed-address statements. You may therefore need a mixture of host declarations for any given client...some having fixed-address statements, others without. ๐ญ
hostname should be a name identifying the host. If a hostname option is not specified for the host, hostname is used. ๐
Host declarations are matched to actual DHCP or BOOTP clients by matching the dhcp-client-identifier or pxe-client-id options specified in the host declaration to the one supplied by the client, or, if the host declaration or the client does not provide a dhcp-client-identifier or pxe-client-id options, by matching the hardware parameter in the host declaration to the network hardware address supplied by the client. BOOTP clients do not normally provide a dhcp-client-identifier, so the hardware address must be used for all clients that may boot using the BOOTP protocol. ๐ฅ
DHCPv6 servers can use the host-identifier option parameter in the host declaration, and specify any option with a fixed value to identify hosts. ๐ธ
Please be aware that only the dhcp-client-identifier and pxe-client-id options and the hardware address can be used to match a host declaration, or the host-identifier option parameter for DHCPv6 servers. For example, it is not possible to match a host declaration to a host-name option. This is because the host-name option cannot be guaranteed to be unique for any given client, whereas both the hardware address and dhcp-client-identifier option are at least theoretically guaranteed to be unique to a given client. ๐
๐ฆ The group statement
group {
[ parameters ]
[ declarations ]
}
The group statement is used simply to apply one or more parameters to a group of declarations. It can be used to group hosts, shared networks, subnets, or even other groups. ๐
๐ก๏ธ REFERENCE: ALLOW AND DENY ๐ก๏ธ
The allow and deny statements can be used to control the response of the DHCP server to various sorts of requests. The allow and deny keywords actually have different meanings depending on the context. In a pool context, these keywords can be used to set up access lists for address allocation pools. In other contexts, the keywords simply control general server behavior with respect to clients based on scope. In a non-pool context, the ignore keyword can be used in place of the deny keyword to prevent logging of denied requests. ๐
๐ ALLOW DENY AND IGNORE IN SCOPE ๐
Okay so these allow and deny usages work in any scope, bestie โ but it is not recommended that they be used in pool declarations. Noted, moving on.
โ ๏ธ Lowkey important: the vibe here is โworks anywhere,โ but pools are their own whole thing. We'll get there.
๐ The unknown-clients keyword ๐
allow unknown-clients;
deny unknown-clients;
ignore unknown-clients;
The unknown-clients flag tells dhcpd whether or not to dynamically assign addresses to unknown clients. Dynamic address assignment to unknown clients is allowed by default. An unknown client is simply a client that has no host declaration.
๐จ Deprecated alert: the use of this option is now deprecated. If you're trying to restrict access on your network to known clients, use deny unknown-clients; inside your address pool, as described under the heading ALLOW AND DENY WITHIN POOL DECLARATIONS.
๐ The bootp keyword ๐
allow bootp;
deny bootp;
ignore bootp;
The bootp flag tells dhcpd whether or not to respond to bootp queries. Bootp queries are allowed by default.
๐ฆ The booting keyword ๐ฆ
allow booting;
deny booting;
ignore booting;
The booting flag tells dhcpd whether or not to respond to queries from a particular client. This keyword only has meaning when it appears in a host declaration. By default, booting is allowed โ but if it is disabled for a particular client, then that client will not be able to get an address from the DHCP server.
๐ The duplicates keyword ๐
allow duplicates;
deny duplicates;
Host declarations can match client messages based on the DHCP Client Identifier option or based on the client's network hardware type and MAC address. If the MAC address is used, the host declaration will match any client with that MAC address โ even clients with different client identifiers. This doesn't normally happen, but it is possible when one computer has more than one operating system installed on it โ for example, Microsoft Windows and NetBSD or Linux.
The duplicates flag tells the DHCP server that if a request is received from a client that matches the MAC address of a host declaration, any other leases matching that MAC address should be discarded by the server, even if the UID is not the same. This is a violation of the DHCP protocol, but it can prevent clients whose client identifiers change regularly from holding many leases at the same time. By default, duplicates are allowed.
๐ธ The declines keyword ๐ธ
allow declines;
deny declines;
ignore declines;
The DHCPDECLINE message is used by DHCP clients to indicate that the lease the server has offered is not valid. When the server receives a DHCPDECLINE for a particular address, it normally abandons that address, assuming that some unauthorized system is using it. Unfortunately, a malicious or buggy client can, using DHCPDECLINE messages, completely exhaust the DHCP server's allocation pool. The server will eventually reclaim these leases, but not while the client is running through the pool. This may cause serious thrashing in the DNS, and it will also cause the DHCP server to forget old DHCP client address allocations.
The declines flag tells the DHCP server whether or not to honor DHCPDECLINE messages. If it is set to deny or ignore in a particular scope, the DHCP server will not respond to DHCPDECLINE messages.
The declines flag is only supported by DHCPv4 servers. Given the large IPv6 address space and the internal limits imposed by the server's address generation mechanism we don't think it is necessary for DHCPv6 servers at this time.
Currently, abandoned IPv6 addresses are reclaimed in one of two ways:
a)Client renews a specific address: If a client using a given DUID submits aDHCP REQUESTcontaining the last address abandoned by that DUID, the address will be reassigned to that client.b)Upon the second restart following an address abandonment. When an address is abandoned it is both recorded as such in the lease file and retained as abandoned in server memory until the server is restarted. Upon restart, the server will process the lease file and all addresses whose last known state is abandoned will be retained as such in memory but not rewritten to the lease file. This means that a subsequent restart of the server will not see the abandoned addresses in the lease file and therefore have no record of them as abandoned in memory and as such perceive them as free for assignment.
The total number addresses in a pool, available for a given DUID value, is internally limited by the server's address generation mechanism. If through mistaken configuration, multiple clients are using the same DUID they will competing for the same addresses causing the server to reach this internal limit rather quickly. The internal limit isolates this type of activity such that address range is not exhausted for other DUID values. The appearance of the following error log, can be an indication of this condition:
"Best match for DUID <XX> is an abandoned address, This may be a
result of multiple clients attempting to use this DUID"
where <XX> is an actual DUID value depicted as colon separated string of bytes in hexadecimal values.
๐ซถ The client-updates keyword ๐ซถ
allow client-updates;
deny client-updates;
The client-updates flag tells the DHCP server whether or not to honor the client's intention to do its own update of its A record. See the documentation under the heading THE DNS UPDATE SCHEME for details.
๐ The leasequery keyword ๐
allow leasequery;
deny leasequery;
The leasequery flag tells the DHCP server whether or not to answer DHCPLEASEQUERY packets. The answer to a DHCPLEASEQUERY packet includes information about a specific lease, such as when it was issued and when it will expire. By default, the server will not respond to these packets.
๐ ALLOW AND DENY WITHIN POOL DECLARATIONS ๐
The uses of the allow and deny keywords shown in the previous section work pretty much the same way whether the client is sending a DHCPDISCOVER or a DHCPREQUEST message โ an address will be allocated to the client (either the old address it's requesting, or a new address) and then that address will be tested to see if it's okay to let the client have it. If the client requested it, and it's not okay, the server will send a DHCPNAK message. Otherwise, the server will simply not respond to the client. If it is okay to give the address to the client, the server will send a DHCPACK message.
The primary motivation behind pool declarations is to have address allocation pools whose allocation policies are different. A client may be denied access to one pool, but allowed access to another pool on the same network segment. In order for this to work, access control has to be done during address allocation, not after address allocation is done.
When a DHCPREQUEST message is processed, address allocation simply consists of looking up the address the client is requesting and seeing if it's still available for the client. If it is, then the DHCP server checks both the address pool permit lists and the relevant in-scope allow and deny statements to see if it's okay to give the lease to the client. In the case of a DHCPDISCOVER message, the allocation process is done as described previously in the ADDRESS ALLOCATION section.
When declaring permit lists for address allocation pools, the following syntaxes are recognized following the allow or deny keywords:
known-clients;โ If specified, this statement either allows or prevents allocation from this pool to any client that has a host declaration (i.e., is known). A client is known if it has a host declaration in any scope, not just the current scope.unknown-clients;โ If specified, this statement either allows or prevents allocation from this pool to any client that has no host declaration (i.e., is not known).members of "class";โ If specified, this statement either allows or prevents allocation from this pool to any client that is a member of the named class.dynamic bootp clients;โ If specified, this statement either allows or prevents allocation from this pool to any bootp client.authenticated clients;โ If specified, this statement either allows or prevents allocation from this pool to any client that has been authenticated using the DHCP authentication protocol. This is not yet supported.unauthenticated clients;โ If specified, this statement either allows or prevents allocation from this pool to any client that has not been authenticated using the DHCP authentication protocol. This is not yet supported.all clients;โ If specified, this statement either allows or prevents allocation from this pool to all clients. This can be used when you want to write a pool declaration for some reason, but hold it in reserve, or when you want to renumber your network quickly, and thus want the server to force all clients that have been allocated addresses from this pool to obtain new addresses immediately when they next renew.after time;โ If specified, this statement either allows or prevents allocation from this pool after a given date. This can be used when you want to move clients from one pool to another. The server adjusts the regular lease time so that the latest expiry time is at the giventime+min-lease-time. A shortmin-lease-timeenforces a step change, whereas a longermin-lease-timeallows for a gradual change.timeis either second since epoch, or a UTC time string e.g.4 2007/08/24 09:14:32or a string with time zone offset in seconds e.g.4 2007/08/24 11:14:32 -7200
โญ REFERENCE: PARAMETERS โญ
๐งธ The abandon-lease-time statement ๐งธ
abandon-lease-time time;
Time should be the maximum amount of time (in seconds) that an abandoned IPv4 lease remains unavailable for assignment to a client. Abandoned leases will only be offered to clients if there are no free leases. If not defined, the default abandon lease time is 86400 seconds (24 hours). Note the abandoned lease time for a given lease is preserved across server restarts. The parameter may only be set at the global scope and is evaluated only once during server startup.
Values less than sixty seconds are not recommended as this is below the ping check threshold and can cause leases once abandoned but since returned to the free state to not be pinged before being offered. If the requested time is larger than 0x7FFFFFFF - 1 or the sum of the current time plus the abandoned time isgreater than 0x7FFFFFFF it is treated as infinite.
๐งธ The adaptive-lease-time-threshold statement ๐งธ
adaptive-lease-time-threshold percentage;
Okay so when the number of allocated leases inside a pool rises above the percentage in this statement, the DHCP server lowkey shortens the lease length for new clients in that pool to min-lease-time seconds. Clients renewing an already valid (long) lease still get at least the remaining time from the current lease. And because the leases expire faster, the server can either recover more quickly or avoid pool exhaustion entirely. Once the number of allocated leases drops below the threshold, the server reverts back to normal lease times. Valid percentages are between 1 and 99. Periodt ๐
โจ The always-broadcast statement โจ
always-broadcast flag;
The DHCP and BOOTP protocols both require DHCP and BOOTP clients to set the broadcast bit in the flags field of the BOOTP message header. Unfortunately, some DHCP and BOOTP clients just donโt do this ๐ญ, and therefore may not receive responses from the DHCP server. The DHCP server can be made to always broadcast its responses to clients by setting this flag to on for the relevant scope; relevant scopes would be inside a conditional statement, as a parameter for a class, or as a parameter for a host declaration. To avoid creating excess broadcast traffic on your network, we recommend that you restrict the use of this option to as few clients as possible. For example, the Microsoft DHCP client is known not to have this problem, as are the OpenTransport and ISC DHCP clients. Slay for them, honestly ๐ซถ
โจ The always-reply-rfc1048 statement โจ
always-reply-rfc1048 flag;
Some BOOTP clients expect RFC1048-style responses, but do not follow RFC1048 when sending their requests. You can tell that a client is having this problem if it is not getting the options you have configured for it, and if you see in the server log the message (non-rfc1048) printed with each BOOTREQUEST that is logged. Not me seeing that log line and immediately knowing whatโs up ๐
If you want to send rfc1048 options to such a client, you can set the always-reply-rfc1048 option in that clientโs host declaration, and the DHCP server will respond with an RFC-1048-style vendor options field. This flag can be set in any scope, and will affect all clients covered by that scope. Cute, covered, done โจ
โจ The authoritative statement โจ
authoritative;
not authoritative;
The DHCP server will normally assume that the configuration information about a given network segment is not known to be correct and is not authoritative. This is so that if a naive user installs a DHCP server not fully understanding how to configure it, it does not send spurious DHCPNAK messages to clients that have obtained addresses from a legitimate DHCP server on the network. Protecting the girlies from chaos, honestly ๐
Network administrators setting up authoritative DHCP servers for their networks should always write authoritative; at the top of their configuration file to indicate that the DHCP server should send DHCPNAK messages to misconfigured clients. If this is not done, clients will be unable to get a correct IP address after changing subnets until their old lease has expired, which could take quite a long time. Thatโs giving โwaiting for your fave to drop the albumโ energy and nobody wants that ๐ญ
Usually, writing authoritative; at the top level of the file should be sufficient. However, if a DHCP server is to be set up so that it is aware of some networks for which it is authoritative and some networks for which it is not, it may be more appropriate to declare authority on a per-network-segment basis.
Note that the most specific scope for which the concept of authority makes any sense is the physical network segment โ either a shared-network statement or a subnet statement that is not contained within a shared-network statement. It is not meaningful to specify that the server is authoritative for some subnets within a shared network, but not authoritative for others, nor is it meaningful to specify that the server is authoritative for some host declarations and not others. Like, pick a lane, bestie ๐
In order for DHCPINFORMs to be responded to by the server, they must match to subnets over which the server has authority; otherwise they will be ignored and logged. To minimize the impact on logging volume, only the first and every subsequent 100th occurrence of an ignored DHCPINFORM is logged. Logging said โIโm not doing this every single timeโ and honestly valid ๐
โจ The boot-unknown-clients statement โจ
boot-unknown-clients flag;
If the boot-unknown-clients statement is present and has a value of false or off, then clients for which there is no host declaration will not be allowed to obtain IP addresses. If this statement is not present or has a value of true or on, then clients without host declarations will be allowed to obtain IP addresses, as long as those addresses are not restricted by allow and deny statements within their pool declarations. No host declaration? No IP, depending on the flag. Itโs giving strict-door-policy but make it DHCP ๐ชโจ
โจ The check-secs-byte-order statement โจ
check-secs-byte-order flag;
When check-secs-byte-order is enabled, the server will check for DHCPv4 clients that do the byte ordering on the secs field incorrectly. This field should be in network byte order but some clients get it wrong. When this parameter is enabled the server will examine the secs field and if it looks wrong (high byte non zero and low byte zero) swap the bytes. The default is disabled. This parameter is only useful when doing load balancing within failover. (Formerly, this behavior had to be enabled during compilation configuration via --enable-secs-byteorder.) Byte-order chaos, but make it a flag ๐
โจ The db-time-format statement โจ
db-time-format [ default | local ] ;
The DHCP server software outputs several timestamps when writing leases to persistent storage. This configuration parameter selects one of two output formats. The default format prints the day, date, and time in UTC, while the local format prints the system seconds-since-epoch, and helpfully provides the day and time in the system timezone in a comment. The time formats are described in detail in the dhcpd.leases(5) manpage. Timestamp lore, but make it readable ๐ฐ๏ธ๐
โจ The ddns-hostname statement โจ
ddns-hostname name;
The name parameter should be the hostname that will be used in setting up the clientโs A and PTR records. If no ddns-hostname is specified in scope, then the server will derive the hostname automatically, using an algorithm that varies for each of the different update methods. Auto-generated hostname era, iykyk ๐ธ
โจ The ddns-domainname statement โจ
ddns-domainname name;
The name parameter should be the domain name that will be appended to the clientโs hostname to form a fully-qualified domain-name (FQDN). FQDN glow-up incoming โจ
โจ The ddns-dual-stack-mixed-mode statement โจ
ddns-dual-stack-mixed-mode flag;
The ddns-dual-stack-mixed-mode parameter controls whether or not the server applies Dual Stack Mixed Mode rules during DDNS conflict resolution. This parameter is off by default, has no effect unless update-conflict-detection is enabled, and may only be specified at the global scope. Global scope only, bestie โ no sneaking it into a tiny little scope ๐๐
โจ The ddns-guard-id-must-match statement โจ
ddns-guard-id-must-match flag;
The ddns-guard-id-must-match parameter controls whether or not the client id within a DHCID RR must match that of the DNS updateโs client to permit DNS entries associated with that DHCID RR to be overwritten. Proper conflict resolution requires ID matching and should only be disabled after careful consideration. When disabled, it allows any DNS updater to replace DNS entries that have an associated DHCID RR, regardless of client identity. This parameter is on by default, has no effect unless update-conflict-detection is enabled, and may only be specified at the global scope. Careful consideration, okay? This is not a casual toggle ๐ญ๐
โจ The dns-local-address4 and dns-local-address6 statements โจ
ddns-local-address4 address;
ddns-local-address6 address;
The address parameter should be the local IPv4 or IPv6 address the server should use as the from address when sending DDNS update requests. Local address, but make it the from address ๐
โจ The ddns-other-guard-is-dynamic statement โจ
ddns-other-guard-is-dynamic flag;
The ddns-other-guard-is-dynamic parameter controls whether or not a server running DSMM will consider the presence of the other update style DHCID RR as an indication that DNS entries may be overwritten. It should only be enabled after careful study as it allows DNS entries that would otherwise be protected as static, to be overwritten in certain cases. This parameter is off by default, has no effect unless ddns-dual-stack-mixed-mode is enabled, and may only be specified at the global scope. Again: careful study first, not just vibes ๐งโจ
โจ The ddns-rev-domainname statement โจ
ddns-rev-domainname name;
The name parameter should be the domain name that will be appended to the clientโs reversed IP address to produce a name for use in the clientโs PTR record. By default, this is in-addr.arpa., but the default can be overridden here.
The reversed IP address to which this domain name is appended is always the IP address of the client, in dotted quad notation, reversed โ for example, if the IP address assigned to the client is 10.17.92.74, then the reversed IP address is 74.92.17.10. So a client with that IP address would, by default, be given a PTR record of 10.17.92.74.in-addr.arpa. Reverse it, append it, slay it ๐
โจ The ddns-update-style parameter โจ
ddns-update-style style;
The style parameter must be one of standard, interim or none. The ddns-update-style statement is only meaningful in the outer scope โ it is evaluated once after reading the dhcpd.conf file, rather than each time a client is assigned an IP address, so there is no way to use different DNS update styles for different clients. The default is none. One style for the whole file, no per-client outfit changes ๐
โจ The ddns-updates statement โจ
ddns-updates flag;
The ddns-updates parameter controls whether or not the server will attempt to do a DNS update when a lease is confirmed. Set this to off if the server should not attempt to do updates within a certain scope. The ddns-updates parameter is on by default. To disable DNS updates in all scopes, it is preferable to use the ddns-update-style statement, setting the style to none. Yes, thereโs a whole-file way to turn it off โ use that instead of fighting every scope individually ๐ซถ
โจ The default-lease-time statement โจ
default-lease-time time;
Time should be the length in seconds that will be assigned to a lease if the client requesting the lease does not ask for a specific expiration time. This is used for both DHCPv4 and DHCPv6 leases (it is also known as the valid lifetime in DHCPv6). The default is 43200 seconds. Thatโs 12 hours of default-lease-time realness โฐโจ
โจ The delayed-ack and max-ack-delay statements โจ
delayed-ack count;
max-ack-delay microseconds;
Count should be an integer value from zero to 2^16-1 and defaults to 0, which basically means the feature is asleep ๐ค. Otherwise, 28 may be a sensible starting point for many configurations (SO_SNDBUF size / 576 bytes). The count is literally how many DHCPv4 replies max are gonna be queued pending transmission until after a database commit event. If that number gets hit, a database commit event goes down (commonly resulting in fsync() and, yeah, a performance penalty ๐ญ), and then the reply packets get transmitted in a batch afterwards. This keeps the RFC2131 direction that "stable storage" gets updated prior to replying to clients. And should the DHCPv4 sockets "go dry" (select() returns immediately with no read sockets), the commit is made and any queued packets are transmitted. No cap.
Similarly, microseconds says how many microseconds are permitted to pass inbetween queuing a packet pending an fsync and actually performing the fsync. Valid values range from 0 to 2^32-1, and it defaults to 250,000 (that's 1/4 of a second โฑ๏ธ).
The delayed-ack feature is compiled in by default, but you can disable it at compile time with ./configure --disable-delayed-ack. โ ๏ธ Please note the delayed-ack feature is not currently compatible with support for DHPCv4-over-DHCPv6, so when a 4to6 port ommand line argument enables this in the server, the delayed-ack value gets reset to 0. Like, fully reset. ๐
The dhcp-cache-threshold statement
dhcp-cache-threshold percentage;
The dhcp-cache-threshold statement takes one integer parameter with allowed values between 0 and 100. The default value is 25 (25% of the lease time). This parameter expresses the percentage of the total lease time, measured from the beginning, during which a client's attempt to renew its lease will result in getting the already assigned lease, rather than an extended lease. โจ This feature is supported for both IPv4 and IPv6 and down to the pool level, and for IPv6 all three pool types: NA, TA and PD.
Clients that attempt renewal frequently can cause the server to update and write the database frequently, resulting in a performance impact on the server. The dhcp-cache-threshold statement instructs the DHCP server to avoid updating leases too frequently, thus avoiding this behavior. Instead the server replies with the same lease (i.e. reuses it) with no modifications except for CLTT (Client Last Transmission Time) and, for IPv4:
- the lease time sent to the client is shortened by the age of the lease
while for IPv6:
- the preferred and valid lifetimes sent to the client are shortened by the age of the lease.
None of these changes require writing the lease to disk. slay ๐
When an existing lease is matched to a renewing client, it will be reused if all of the following conditions are true:
- The
dhcp-cache-thresholdis larger than zero - The current lease is active
- The percentage of the lease time that has elapsed is less than
dhcp-cache-threshold - The client information provided in the renewal does not alter any of the following:
- DNS information and DNS updates are enabled
- Billing class to which the lease is associated (IPv4 only)
- The host declaration associated with the lease (IPv4 only)
- The client id - this may happen if a client boots without a client id and then starts using one in subsequent requests. (IPv4 only)
While lease data is not written to disk when a lease is reused, the server will still execute any on-commit statements. ๐ซถ
Note that the lease can be reused if the options the client or relay agent sends are changed. These changes will not be recorded in the in-memory or on-disk databases until the client renews after the threshold time is reached. ikyk ๐
The do-forward-updates statement
do-forward-updates flag;
The do-forward-updates statement instructs the DHCP server as to whether it should attempt to update a DHCP client's A record when the client acquires or renews a lease. Heads up: this statement has no effect unless DNS updates are enabled. Forward updates are enabled by default. If this statement is used to disable forward updates, the DHCP server will never attempt to update the client's A record, and will only ever attempt to update the client's PTR record if the client supplies an FQDN that should be placed in the PTR record using the fqdn option. If forward updates are enabled, the DHCP server will still honor the setting of the client-updates flag. ๐ฆ
The dont-use-fsync statement
dont-use-fsync flag;
The dont-use-fsync statement instructs the DHCP server if it should call fsync() when writing leases to the lease file. By default โ and if the flag is set to false โ the server will call fsync(). Suppressing the call to fsync() may increase the performance of the server, but it also adds a risk that a lease will not be properly written to the disk after it has been issued to a client and before the server stops. That can lead to duplicate leases being issued to different clients. ๐
Using this option is not recommended. Like, genuinely. Don't. ๐
The dynamic-bootp-lease-cutoff statement
dynamic-bootp-lease-cutoff date;
The dynamic-bootp-lease-cutoff statement sets the ending time for all leases assigned dynamically to BOOTP clients. Here's the lore ๐ง: because BOOTP clients don't have any way of renewing leases, and don't know that their leases could expire, by default dhcpd assigns infinite leases to all BOOTP clients. But sometimes it makes sense to set a cutoff date for all BOOTP leases โ for example, the end of a school term, or the time at night when a facility is closed and all machines are required to be powered off. ๐
Date should be the date on which all assigned BOOTP leases will end. The date is specified in the form:
W YYYY/MM/DD HH:MM:SS
W is the day of the week expressed as a number from zero (Sunday) to six (Saturday). YYYY is the year, including the century. MM is the month expressed as a number from 1 to 12. DD is the day of the month, counting from 1. HH is the hour, from zero to 23. MM is the minute and SS is the second. โฐ And the time is always in Coordinated Universal Time (UTC), not local time โ don't come for me, that's just how it is.
The dynamic-bootp-lease-length statement
dynamic-bootp-lease-length length;
The dynamic-bootp-lease-length statement is used to set the length of leases dynamically assigned to BOOTP clients. At some sites, it may be possible to assume that a lease is no longer in use if its holder has not used BOOTP or DHCP to get its address within a certain time period. That period is specified in length as a number of seconds. If a client reboots using BOOTP during the timeout period, the lease duration is reset to length, so a BOOTP client that boots frequently enough will never lose its lease. ๐
Needless to say, this parameter should be adjusted with extreme caution. ๐จ
The echo-client-id statement
echo-client-id flag;
The echo-client-id statement is used to enable or disable RFC 6842 compliant behavior. If the echo-client-id statement is present and has a value of true or on, and a DHCP DISCOVER or REQUEST is received which contains the client identifier option (Option code 61), the server will copy the option into its response (DHCP ACK or NAK) per RFC 6842. In other words: if the client sends the option, it will receive it back. ๐ช By default, this flag is off and client identifiers will not be echoed back to the client.
The filename statement
filename "filename";
The filename statement can be used to specify the name of the initial boot file which is to be loaded by a client. The filename should be a filename recognizable to whatever file transfer protocol the client can be expected to use to load the file. ๐
The fixed-address declaration
fixed-address address [, address ... ];
The fixed-address declaration is used to assign one or more fixed IP addresses to a client. It should only appear in a host declaration. If more than one address is supplied, then when the client boots, it will be assigned the address that corresponds to the network on which it is booting. If none of the addresses in the fixed-address statement are valid for the network to which the client is connected, that client will not match the host declaration containing that fixed-address declaration. Each address in the fixed-address declaration should be either an IP address or a domain name that resolves to one or more IP addresses. ๐
The fixed-address6 declaration
fixed-address6 ip6-address ;
The fixed-address6 declaration is used to assign a fixed IPv6 addresses to a client. It should only appear in a host declaration.
The fixed-prefix6 declaration
fixed-prefix6 low-address / bits;
The fixed-prefix6 declaration is used to assign a fixed IPv6 prefix to a client. It should only appear in a host declaration, but multiple fixed-prefix6 statements may appear in a single host declaration.
The low-address specifies the start of the prefix and the bits specifies the size of the prefix in bits. ๐ข
If there are multiple prefixes for a given host entry, the server will choose one that matches the requested prefix size or, if none match, the first one.
If there are multiple host declarations, the server will try to choose a declaration where the fixed-address6 matches the client's subnet. If none match it will choose one that doesn't have a fixed-address6 statement.
Note Well: Unlike the fixed address, the fixed prefix does not need to match a subnet in order to be served. This allows you to provide a prefix to a client that is outside of the subnet on which the client makes the request to the the server. ๐คฏ
The get-lease-hostnames statement
get-lease-hostnames flag;
โจ The get-lease-hostnames statement โจ
get-lease-hostnames flag;
Okay so this one is basically the server doing a lil detective mission ๐ โ it tells dhcpd whether or not to look up the domain name that corresponds to the IP address of each address in the lease pool, and then use that address for the DHCP hostname option. If flag is true, then the lookup happens for all the addresses in the current scope. By default, or if flag is false, no lookups are done. Simple as that, bestie ๐
๐ The hardware statement ๐
hardware hardware-type hardware-address;
So for a BOOTP client to even be recognized, its network hardware address has to be declared using a hardware clause in the host statement โ no declaration, no recognition, that's the vibe check ๐
hardware-type must be the name of a physical hardware interface type. Currently, only the ethernet and token-ring types are recognized, although support for a fddi hardware type (and others) would also be desirable. (Yes, the manpage is out here saying "would also be desirable" like a hopeful little wishlist ๐ฅบ iconic honestly.)
The hardware-address should be a set of hexadecimal octets (numbers from 0 through ff) separated by colons. Also! The hardware statement may be used for DHCP clients too, not just BOOTP ones ๐ซถ
๐ฆ The host-identifier option statement ๐ฆ
host-identifier option option-name option-data;
or
host-identifier v6relopt number option-name option-data;
This bad boy identifies a DHCPv6 client in a host statement โจ option-name is any option, and option-data is the value for the option that the client will send. Lowkey important: the option-data must be a constant value โ no vibes-based dynamic stuff here ๐
In the v6relopts case, the additional number is the relay to examine for the specified option name and value. The values are the same as for the v6relay option: 0 is a no-op, 1 is the relay closest to the client, 2 the next one in, and so on. Values larger than the maximum number of relays (currently 32) indicate the relay closest to the server, independent of number. Slay, that's your addressing scheme mapped out ๐
๐ The ignore-client-uids statement ๐
ignore-client-uids flag;
If this statement is present and has a value of true or on, the UID for clients will not be recorded. If this statement is not present, or has a value of false or off, then client UIDs will be recorded. That's the whole thing, no notes ๐
๐ธ The infinite-is-reserved statement ๐ธ
infinite-is-reserved flag;
ISC DHCP now supports ยดreservedยด leases โ go check out the section on RESERVED LEASES below, it's giving lore ๐ If this flag is on, the server will automatically reserve leases allocated to clients which requested an infinite (0xffffffff) lease-time.
The default is off. Don't forget it, bestie ๐ซถ
โญ The lease-file-name statement โญ
lease-file-name name;
Where name is the name of the DHCP server's lease file. By default, this is /var/lib/dhcpd/dhcpd.leases. Lowkey crucial caveat: this statement must appear in the outer scope of the configuration file โ if it appears in some other scope, it will have no effect ๐ And the value must be the absolute path of the file to use, no funny business.
The order of precedence the server uses for the lease file name is:
lease-file-nameconfiguration file statement.-lfcommand line flag.PATH_DHCPD_DBenvironment variable.
๐ The dhcpv6-lease-file-name statement ๐
dhcpv6-lease-file-name name;
Where name is the name of the DHCP server's lease file when the server is running DHCPv6. By default, this is /var/lib/dhcpd/dhcpd6.leases. Same rules as its v4 sibling, bestie: this statement must appear in the outer scope of the configuration file โ anywhere else and it will have no effect โ and the value must be the absolute path of the file to use.
The order of precedence the server uses for the lease file name is:
dhcpv6-lease-file-nameconfiguration file statement.-lfcommand line flag.PATH_DHCPD6_DBenvironment variable.
๐ The lease-id-format parameter ๐
lease-id-format format;
The format parameter must be either octal or hex โ pick one, queen ๐ This parameter governs the format used to write certain values to lease files.
With the default format, octal, values are written as quoted strings in which non-printable characters are represented as octal escapes โ a backslash character followed by three octal digits. When the hex format is specified, values are written as an unquoted series of pairs of hexadecimal digits, separated by colons.
Currently, the values written out based on lease-id-format are the server-duid, the uid (DHCPv4 leases), and the IAID_DUID (DHCPv6 leases). And ngl the glow-up here is that the server automatically reads the values in either format, so no stress ๐ซถ
๐ง The limit-addrs-per-ia statement ๐ง
limit-addrs-per-ia number;
By default, the DHCPv6 server will limit clients to one IAADDR per IA option, meaning one address. If you wish to permit clients to hang onto multiple addresses at a time, configure a larger number here. Main character energy = multiple addresses ๐
Note that there is no present method to configure the server to forcibly configure the client with one IP address per each subnet on a shared network. This is left to future work. (Future work bestie, we'll get there ๐ญ)
๐ The local-port statement ๐
local-port port;
This statement causes the DHCP server to listen for DHCP requests on the UDP port specified in port, rather than on port 67. Custom port, custom vibe โจ
๐ฅ The local-address statement ๐ฅ
local-address address;
This statement causes the DHCP server to listen for DHCP requests sent to the specified address, rather than requests sent to all addresses.
Now here's the tea โ since serving directly attached DHCP clients implies that the server must respond to requests sent to the all-ones IP address, this option cannot be used if clients are on directly attached networks. It's only realistically useful for a server whose only clients are reached via unicasts, such as via DHCP relay agents.
Note: This statement is only effective if the server was compiled using theUSE_SOCKETS#definestatement, which is default on a small number of operating systems, and must be explicitly chosen at compile-time for all others. You can be sure if your server is compiled withUSE_SOCKETSif you see lines of this format at startup:
Listening on Socket/eth0
Note also that since this bind()s all DHCP sockets to the specified address, only one address may be supported in a daemon at a given time. One address only, no polyamory for sockets ๐
๐ธ The local-address6 and bind-local-address6 statements ๐ธ
local-address6 address;
bind-local-address6 flag;
The local-address6 statement causes the DHCP server to send IPv6 packets as originating from the specified IPv6 address, rather than leaving the kernel to fill in the source address field.
When bind-local-address6 is present and has a value of true or on, service sockets are bound to address too.
By default address is the undefined address and bind-local-address6 is disabled, and both may only be set at the global scope. Global scope only, bestie โ no nesting shenanigans ๐
๐ The log-facility statement ๐
log-facility facility;
This statement causes the DHCP server to do all of its logging on the specified log facility once the dhcpd.conf file has been read. By default the DHCP server logs to the daemon facility.
Possible log facilities include auth, authpriv, cron, daemon, ftp, kern, lpr, mail, mark, news, ntp, security, syslog, user, uucp, and local0 through local7. Not all of these facilities are available on all systems, and there may be other facilities available on other systems. (So many options, so little time ๐ญ)
In addition to setting this value, you may need to modify your syslog.conf file to configure logging of the DHCP server. For example, you might add a line like this:
local7.debug /var/log/dhcpd.log
The syntax of the syslog.conf file may be different on some operating systems โ consult the syslog.conf manual page to be sure. To get syslog to start logging to the new file, you must first create the file with correct ownership and permissions (usually, the same owner and permissions of your /var/log/messages or /usr/adm/messages file should be fine) and send a SIGHUP to syslogd. Some systems support log rollover using a shell script or program called newsyslog or logrotate, and you may be able to configure this as well so that your log file doesn't grow uncontrollably. ๐
Because the log-facility setting is controlled by the dhcpd.conf file, log messages printed while parsing the dhcpd.conf file or before parsing it are logged to the default log facility. To prevent this, see the README file included with this distribution, which describes BUG: where is that mentioned in README? how to change the default log facility. ๐ญ (Yes, that's literally in the manpage, we're keeping it, no cap.) When this parameter is used, the DHCP server prints its startup message a second time after parsing the configuration file, so that the log will be as complete as possible. Double the startup message, double the iconic โจ
๐ฆ The log-threshold-high and log-threshold-low statements ๐ฆ
log-threshold-high percentage;
log-threshold-low percentage;
The log-threshold-low and log-threshold-high statements are used to control when a message is output about pool usage. The value for both of them is the percentage of the pool in use.
If the high threshold is 0 or has not been specified, no messages will be produced. If a high threshold is given, a message is output once the pool usage passes that level. After that, no more messages will be output until the pool usage falls below the low threshold. If the low threshold is not given, it defaults to a value of zero.
Special case alert ๐จ when the low threshold is set to be higher than the high threshold, a message will be generated each time a lease is acknowledged when the pool usage is above the high threshold. Chaos mode, but make it intentional ๐
Note that threshold logging will be automatically disabled for shared subnets whose total number of addresses is larger than (2^64)-1. The server will emit a log statement at startup when threshold logging is disabled as shown below:
"Threshold logging disabled for shared subnet of ranges: <addresses>"
This is likely to have no practical runtime effect as CPUs are unlikely to support a server actually reaching such a large number of leases. (Like, girl, (2^64)-1? Your CPU said absolutely not ๐)
๐ The max-lease-time statement ๐
max-lease-time time;
Time should be the maximum length in seconds that will be assigned to a lease. If not defined, the default maximum lease time is 86400. The only exception to this is that Dynamic BOOTP lease lengths, which are not specified by the client, are not limited by this maximum. BOOTP said "rules don't apply to me" and honestly? Fair ๐ซถ
The min-lease-time statement
min-lease-time time;
Okay so time here is the minimum length in seconds that's gonna get assigned to a lease. The default? It's the minimum of 300 seconds or max-lease-time. That's it, that's the vibe ๐
The min-secs statement
min-secs seconds;
seconds should be the minimum number of seconds since a client began trying to acquire a new lease before the DHCP server will even respond to its request. The number of seconds is based on what the client reports, and the max value a client can report is 255 seconds. Generally, setting this to one means the DHCP server won't respond to the client's first request but will always respond to its second one. Iconic behavior honestly ๐
So this is how you set up a secondary DHCP server that never offers an address to a client until the primary server has been given a chance to do so. If the primary server is down, the client will bind to the secondary server โ but otherwise clients should always bind to the primary. โ ๏ธ Note that this does not, by itself, permit a primary server and a secondary server to share a pool of dynamically-allocatable addresses. Like, don't get it twisted bestie.
The next-server statement
next-server server-name;
The next-server statement specifies the host address of the server from which the initial boot file (the one in the filename statement) is to be loaded. server-name should be a numeric IP address or a domain name. If no next-server statement applies to a given client, the address 0.0.0.0 is used. ๐ฆ
The omapi-port statement
omapi-port port;
The omapi-port statement makes the DHCP server listen for OMAPI connections on the specified port. This statement is required to enable the OMAPI protocol, which is what you use to examine and modify the state of the DHCP server while it's running. Main character protocol, fr.
The one-lease-per-client statement
one-lease-per-client flag;
If this flag is enabled, whenever a client sends a DHCPREQUEST for a particular lease, the server will automatically free any other leases the client holds. This presumes that when the client sends a DHCPREQUEST, it has forgotten any lease not mentioned in the DHCPREQUEST โ i.e., the client has only a single network interface and it does not remember leases it's holding on networks to which it is not currently attached. ๐ญ
Neither of these assumptions are guaranteed or provable, so we urge caution in the use of this statement. Like, we're being so serious rn. Be careful.
The persist-eui-64-leases statement
persist-eui-64-leases flag;
When this flag is enabled, the server will write EUI-64 based leases to the leases file. Since such leases can only, ever be valid for a single DUID value, it can be argued that writing them to the leases file isn't essential โ and not doing so may have performance advantages. โจ See the use-eui-64 statement for more details on EUI-64 based address allocation. The flag is enabled by default and may only be set at the global scope. (And yes, the original page spells it "perfomance" โ we keep our typos canon around here ๐)
The pid-file-name statement
pid-file-name name;
name should be the name of the DHCP server's process ID file โ the file where the server's process ID is stored when the server starts. By default, this is /var/run/dhcpd.pid. Just like the lease-file-name statement, this one must appear in the outer scope of the configuration file. The order of precedence used by the server is:
pid-file-nameconfiguration file statement.-lfcommand line flag.PATH_DHCPD_PIDenvironment variable.
The dhcpv6-pid-file-name statement
dhcpv6-pid-file-name name;
name is the name of the pid file to use if and only if the server is running in DHCPv6 mode. By default, this is /var/lib/dhcpd/dhcpd6.pid. This statement, like pid-file-name, must appear in the outer scope of the configuration file. The order of precedence used by the server is:
dhcpv6-pid-file-nameconfiguration file statement.-lfcommand line flag.PATH_DHCPD6_PIDenvironment variable.
The ping-check statement
ping-check flag;
So when the DHCP server is considering dynamically allocating an IP address to a client, it first sends an ICMP Echo request (a ping ๐) to the address being assigned. It waits for a second, and if no ICMP Echo response has been heard, it assigns the address. If a response is heard, the lease is abandoned, and the server does not respond to the client. The lease will remain abandoned for a minimum of abandon-lease-time seconds.
If there are no free addresses but there are abandoned IP addresses, the DHCP server will attempt to reclaim an abandoned IP address regardless of the value of abandon-lease-time. slay, recycling โป๏ธ
Heads up: this ping check introduces a default one-second delay in responding toDHCPDISCOVERmessages, which can be a problem for some clients. The default delay of one second may be configured using theping-timeoutparameter. Theping-checkconfiguration parameter can be used to control checking โ if its value isfalse, no ping check is done. ๐
The ping-cltt-secs statement
ping-cltt-secs seconds;
The server will conduct a ping check if all the following conditions are true:
- Ping checking is enabled.
- The server is responding to a
DISCOVER. - The lease to be offered is neither static nor active (i.e. still a valid lease).
- And any of the following are true:
- This will be the first offer of this lease (CLTT is
0). - The lease is being offered to a client other than its previous owner.
- The lease is being offered to its previous owner and more than
ping-cltt-secshave elapsed since CLTT of the original lease. - The lease was abandoned and the server is attempting to reclaim it.
- This will be the first offer of this lease (CLTT is
The ping-cltt-secs statement lets you specify the amount of time that must elapse after CLTT before a ping check will be conducted. The default value is sixty seconds. โณ
The ping-timeout statement
ping-timeout seconds;
If the DHCP server determined it should send an ICMP echo request (a ping) because the ping-check statement is true, ping-timeout lets you configure how many seconds the DHCP server should wait for an ICMP Echo response to be heard. If no ICMP Echo response has been received before the timeout expires, it assigns the address. If a response is heard, the lease is abandoned, and the server does not respond to the client. If no value is set, ping-timeout defaults to 1 second. ๐ธ (See also ping-timeout-ms below.)
The ping-timeout-ms statement
ping-timeout-ms milliseconds;
Lets you specify the ping timeout in milliseconds rather than seconds. If this value is greater than zero, the server will use it in place of ping-timeout. The default value is zero. โจ Millisecond precision, we love to see it.
The preferred-lifetime statement
preferred-lifetime seconds;
IPv6 addresses have "valid" and "preferred" lifetimes. The valid lifetime determines at what point a lease might be said to have expired, and is no longer useable. A preferred lifetime is an advisory condition to help applications move off of the address and onto currently valid addresses (should there still be any open TCP sockets or similar). ๐ซถ
The preferred lifetime defaults to 5/8 the default lease time.
The prefix-length-mode statement
prefix-length-mode mode;
Okay so per RFC 3633, DHCPv6 clients may specify preferences when soliciting prefixes by including an IA_PD Prefix option within the IA_PD option. Among the preferences that may be conveyed is the "prefix-length". When non-zero it indicates a client's desired length for offered prefixes. The RFC states that servers "MAY choose to use the information...to select prefix(es)" but does not specify any particular rules for doing so. The prefix-length-mode statement can be used to set the prefix selection rules employed by the server, when clients send a non-zero prefix-length value. The mode parameter must be one of ignore, prefer, exact, minimum, or maximum, where:
ignoreโ The requested length is ignored. The server will offer the first available prefix.preferโ The server will offer the first available prefix with the same length as the requested length. If none are found then it will offer the first available prefix of any length. This is the default behavior.exactโ The server will offer the first available prefix with the same length as the requested length. If none are found, it will return a status indicating no prefixes available.minimumโ The server will offer the first available prefix with the same length as the requested length. If none are found, it will return the first available prefix whose length is greater than (e.g. longer than), the requested value. If none of those are found, it will return a status indicating no prefixes available. For example, if client requests a length of/60, and the server has available prefixes of lengths/56and/64, it will offer prefix of length/64. ๐maximumโ The server will offer the first available prefix with the same length as the requested length. If none are found, it will return the first available prefix whose length is less than (e.g. shorter than), the requested value. If none of those are found, it will return a status indicating no prefixes available. For example, if client requests a length of/60, and the server has available prefixes of lengths/56and/64, it will offer a prefix of length/56.
In general "first available" is determined by the order in which pools are defined in the server's configuration. For example, if a subnet is defined with three prefix pools A, B, and C:
okay bestie, picture this pool-ordering sitch:
subnet 3000::/64 {
# pool A
pool6 {
:
}
# pool B
pool6 {
:
}
# pool C
pool6 {
:
}
}
then the pools get checked in the order A, B, C. for the modes prefer, minimum, and maximum, this may mean checking the pools in that order, like, twice. a first pass is made looking for an available prefix of exactly the preferred length. if none are found, then a second pass is performed starting with pool A but with appropriately adjusted length criteria. โจ
๐ The release-on-roam statement
release-on-roam flag;
when this is enabled and the dhcpd server detects that a DHCPv6 client (IAID+DUID) has roamed to a new network, it will release the pre-existing leases on the old network and emit a log statement similiar to the following:
"Client: <id> roamed to new network, releasing lease: <address>"
the server will carry out all of the same steps that would normally occur when a client explicitly releases a lease. when release-on-roam is disabled (the default) the server makes such leases unavailable until they expire or the server is restarted. clients that need leases in multiple networks must supply a unique IAID in each IA. this parameter may only be specified at the global level. ๐ซถ
๐ The remote-port statement
remote-port port;
this statement causes the DHCP server to transmit DHCP responses to DHCP clients upon the UDP port specified in port, rather than on port 68. in the event that the UDP response is transmitted to a DHCP Relay, the server generally uses the local-port configuration value. should the DHCP Relay happen to be addressed as 127.0.0.1, however, the DHCP Server transmits its response to the remote-port configuration value. this is generally only useful for testing purposes, and this configuration value should generally not be used. ๐
๐ธ The server-identifier statement
server-identifier hostname;
the server-identifier statement can be used to define the value that is sent in the DHCP Server Identifier option for a given scope. the value specified must be an IP address for the DHCP server, and must be reachable by all clients served by a particular scope.
the use of the server-identifier statement is not recommended โ the only reason to use it is to force a value other than the default value to be sent on occasions where the default value would be incorrect. the default value is the first IP address associated with the physical network interface on which the request arrived.
the usual case where the server-identifier statement needs to be sent is when a physical interface has more than one IP address, and the one being sent by default isn't appropriate for some or all clients served by that interface. another common case is when an alias is defined for the purpose of having a consistent IP address for the DHCP server, and it is desired that the clients use this IP address when contacting the server. ๐ฆ
supplying a value for the dhcp-server-identifier option is equivalent to using the server-identifier statement.
๐ The server-id-check statement
server-id-check flag;
the server-id-check statement is used to control whether or not a server, participating in failover, verifies that the value of the dhcp-server-identifier option in received DHCP REQUEST messages match the server's id before processing the request. server id checking is disabled by default. setting this flag enables id checking and thereafter the server will only process requests that match. note the flag setting should be consistent between failover partners. ๐ญ
unless overridden by use of the server-identifier statement, the value the server uses as its id will be the first IP address associated with the physical network interface on which the request arrived.
in order to reduce runtime overhead the server only checks for a server id option in the global and subnet scopes. complicated configurations may result in different server ids for this check and when the server id for a reply packet is determined, which would prohibit the server from responding. ๐จ
the primary use for this option is when a client broadcasts a request but requires that the response come from a specific failover peer. an example of this would be when a client reboots while its lease is still active โ in this case both servers will normally respond. most of the time the client won't check the server id and can use either of the responses. however if the client does check the server id it may reject the response if it came from the wrong peer. if the timing is such that the "wrong" peer responds first most of the time the client may not get an address for some time.
care should be taken before enabling this option. fr fr.
๐ฅ The server-duid statement
server-duid LLT [ hardware-type timestamp hardware-address ] ;
server-duid EN enterprise-number enterprise-identifier ;
server-duid LL [ hardware-type hardware-address ] ;
the server-duid statement configures the server DUID. you may pick either LLT (link local address plus time), EN (enterprise), or LL (link local).
if you choose LLT or LL, you may specify the exact contents of the DUID. otherwise the server will generate a DUID of the specified type.
if you choose EN, you must include the enterprise number and the enterprise-identifier.
if there is a server-duid statement in the lease file it will take precedence over the server-duid statement from the config file and a dhcp6.server-id option in the config file will override both.
the default server-duid type is LLT. ๐
๐ง The server-name statement
server-name name ;
the server-name statement can be used to inform the client of the name of the server from which it is booting. name should be the name that will be provided to the client. ๐
๐ The dhcpv6-set-tee-times statement
dhcpv6-set-tee-times flag;
the dhcpv6-set-tee-times statement enables setting T1 and T2 to the values recommended in RFC 3315 (Section 22.4). when setting T1 and T2, the server will use dhcp-renewal-time and dhcp-rebinding-time, respectively. a value of zero tells the client it may choose its own value. โจ
when those options are not defined then values will be set to zero unless the global dhcpv6-set-tee-times is enabled. when this option is enabled the times are calculated as recommended by RFC 3315, Section 22.4:
T1 will be set to 0.5 times the shortest preferred lifetime
in the reply. If the "shortest" preferred lifetime is
0xFFFFFFFF, T1 will set to 0xFFFFFFFF.
T2 will be set to 0.8 times the shortest preferred lifetime
in the reply. If the "shortest" preferred lifetime is
0xFFFFFFFF, T2 will set to 0xFFFFFFFF.
keep in mind that given sufficiently small lease lifetimes, the above calculations will result in the two values being equal. for example, a 9 second lease lifetime would yield T1 = T2 = 4 seconds, which would cause clients to issue rebinds only. in such a case it would likely be better to explicitly define the values.
note that dhcpv6-set-tee-times is intended to be transitional and will likely be removed in a future release. once removed the behavior will be to use the configured values when present or calculate them per the RFC. if you want zeros, define them as zeros. ๐
๐ฆ The site-option-space statement
site-option-space name ;
the site-option-space statement can be used to determine from what option space site-local options will be taken. this can be used in much the same way as the vendor-option-space statement. site-local options in DHCP are those options whose numeric codes are greater than 224. these options are intended for site-specific uses, but are frequently used by vendors of embedded hardware that contains DHCP clients. because site-specific options are allocated on an ad hoc basis, it is quite possible that one vendor's DHCP client might use the same option code that another vendor's client uses, for different purposes. the site-option-space option can be used to assign a different set of site-specific options for each such vendor, using conditional evaluation (see dhcp-eval (5) for details). ๐ธ
๐ The stash-agent-options statement
stash-agent-options flag;
if the stash-agent-options parameter is true for a given client, the server will record the relay agent information options sent during the client's initial DHCPREQUEST message when the client was in the SELECTING state and behave as if those options are included in all subsequent DHCPREQUEST messages sent in the RENEWING state. this works around a problem with relay agent information options, which is that they usually not appear in DHCPREQUEST messages sent by the client in the RENEWING state, because such messages are unicast directly to the server and not sent through a relay agent. ๐ซถ
โญ The update-conflict-detection statement
update-conflict-detection flag;
if the update-conflict-detection parameter is true, the server will perform standard DHCID multiple-client, one-name conflict detection. if the parameter has been set false, the server will skip this check and instead simply tear down any previous bindings to install the new binding without question. the default is true and this parameter may only be specified at the global scope. ๐
๐งช The update-optimization statement
update-optimization flag;
okay so if the update-optimization parameter is false for a given client, the server will attempt a DNS update for that client each time the client renews its lease, rather than only attempting an update when it appears to be necessary. This will allow the DNS to heal from database inconsistencies more easily, but the cost is that the DHCP server must do many more DNS updates. We recommend leaving this option enabled, which is the default. If this parameter is not specified, or is true, the DHCP server will only update when the client information changes, the client gets a different lease, or the client's lease expires.
๐ The update-static-leases statement ๐
update-static-leases flag;
The update-static-leases flag, if enabled, causes the DHCP server to do DNS updates for clients even if those clients are being assigned their IP address using a fixed-address or fixed-address6 statement โ that is, the client is being given a static assignment. It is not recommended because the DHCP server has no way to tell that the update has been done, and therefore will not delete the record when it is not in use. Also, the server must attempt the update each time the client renews its lease, which could have a significant performance impact in environments that place heavy demands on the DHCP server. This feature is supported for both DHCPv4 and DHCPv6, and update modes standard or interim. It is disabled by default.
๐ง The use-eui-64 statement ๐ง
use-eui-64 flag;
(Support for this must be enabled at compile time, see EUI_64 in includes/site.h.)
The use-eui-64 flag, if enabled, instructs the server to construct an address using the client's EUI-64 DUID (Type 3, HW Type EUI-64), rather than creating an address using the dynamic algorithm. This means that a given DUID will always generate the same address for a given pool and further that the address is guaranteed to be unique to that DUID. The IPv6 address will be calculated from the EUI-64 link layer address, conforming to RFC 2373, unless there is a host declaration for the client-id.
The range6 statement for EUI-64 must define full /64 bit ranges. Invalid ranges will be flagged during configuration parsing as errors. See the following example:
subnet6 fc00:e4::/64 {
use-eui-64 true;
range6 fc00:e4::/64;
}
The statement may be specified down to the pool level, allowing a mixture of dynamic and EUI-64 based pools.
During lease file parsing, any leases which map to an EUI-64 pool, that have a non-EUI-64 DUID or for which the lease address is not the EUI-64 address for that DUID in that pool, will be discarded.
If a host declaration exists for the DUID, the server grants the address (fixed-prefix6, fixed-address6) according to the host declaration, regardless of the DUID type of the client (even for EUI-64 DUIDs).
If a client request's an EUI-64 lease for a given network, and the resultant address conflicts with a fixed address reservation, the server will send the client a "no addresses available" response.
Any client with a non-conforming DUID (not type 3 or not hw type EUI-64) that is not linked to a host declaration, which requests an address from an EUI-64 enabled pool will be ignored and the event will be logged.
Pools that are configured for EUI-64 will be skipped for dynamic allocation. If there are no pools in the shared network from which to allocate, the client will get back a no addresses available status.
On an EUI-64 enabled pool, any client with a DUID 3, HW Type EUI-64, requesting a solicit/renew and including IA_NA that do not match the EUI-64 policy, they will be treated as though they are "outside" the subnet for a given client message:
- Solicit โ Server will advertise with EUI-64 ia suboption, but with rapid commit off
- Request โ Server will send "an address not on link status", and no ia suboption
- Renew/Rebind โ Server will send the requested address ia suboption with lifetimes of 0, plus an EUI-64 ia
Whether or not EUI-64 based leases are written out to the lease database may be controlled by persist-eui-64-leases statement.
๐ The use-host-decl-names statement ๐
use-host-decl-names flag;
If the use-host-decl-names parameter is true in a given scope, then for every host declaration within that scope, the name provided for the host declaration will be supplied to the client as its hostname. So, for example,
group {
use-host-decl-names on;
host joe {
hardware ethernet 08:00:2b:4c:29:32;
fixed-address joe.example.com;
}
}
is equivalent to
host joe {
hardware ethernet 08:00:2b:4c:29:32;
fixed-address joe.example.com;
option host-name "joe";
}
Additionally, enabling use-host-decl-names instructs the server to use the host declaration name in the the forward DNS name, if no other values are available. This value selection process is discussed in more detail under DNS updates.
An option host-name statement within a host declaration will override the use of the name in the host declaration.
It should be noted here that most DHCP clients completely ignore the host-name option sent by the DHCP server, and there is no way to configure them not to do this. So you generally have a choice of either not having any hostname to client IP address mapping that the client will recognize, or doing DNS updates. It is beyond the scope of this document to describe how to make this determination.
๐ The use-lease-addr-for-default-route statement ๐
use-lease-addr-for-default-route flag;
If the use-lease-addr-for-default-route parameter is true in a given scope, then instead of sending the value specified in the routers option (or sending no value at all), the IP address of the lease being assigned is sent to the client. This supposedly causes Win95 machines to ARP for all IP addresses, which can be helpful if your router is configured for proxy ARP. The use of this feature is not recommended, because it won't work for many DHCP clients.
๐ฆ The vendor-option-space statement ๐ฆ
vendor-option-space string;
The vendor-option-space parameter determines from what option space vendor options are taken. The use of this configuration parameter is illustrated in the dhcp-options(5) manual page, in the VENDOR ENCAPSULATED OPTIONS section.
โจ SETTING PARAMETER VALUES USING EXPRESSIONS โจ
Sometimes it's helpful to be able to set the value of a DHCP server parameter based on some value that the client has sent. To do this, you can use expression evaluation. The dhcp-eval(5) manual page describes how to write expressions. To assign the result of an evaluation to an option, define the option as follows:
my-parameter = expression ;
For example:
ddns-hostname = binary-to-ascii (16, 8, "-",
substring (hardware, 1, 6));
๐ RESERVED LEASES ๐
It's often useful to allocate a single address to a single client, in approximate perpetuity. Host statements with fixed-address clauses exist to a certain extent to serve this purpose, but because host statements are intended to approximate "static configuration", they suffer from not being referenced in a littany of other Server Services, such as dynamic DNS, failover, "on events" and so forth.
If a standard dynamic lease, as from any range statement, is marked "reserved", then the server will only allocate this lease to the client it is identified by (be that by client identifier or hardware address).
In practice, this means that the lease follows the normal state engine, enters ACTIVE state when the client is bound to it, expires, or is released, and any events or services that would normally be supplied during these events are processed normally, as with any other dynamic lease. The only difference is that failover servers treat reserved leases as special when they enter the FREE or BACKUP states โ each server applies the lease into the state it may allocate from โ and the leases are not placed on the queue for allocation to other clients. Instead they may only be "found" by client identity. The result is that the lease is only offered to the returning client.
Care should probably be taken to ensure that the client only has one lease within a given subnet that it is identified by.
Leases may be set "reserved" either through OMAPI, or through the infinite-is-reserved configuration option (if this is applicable to your environment and mixture of clients).
It should also be noted that leases marked "reserved" are effectively treated the same as leases marked bootp.
๐ REFERENCE: OPTION STATEMENTS ๐
DHCP option statements are documented in the dhcp-options(5) manual page.
๐งฎ REFERENCE: EXPRESSIONS ๐งฎ
Expressions used in DHCP option statements and elsewhere are documented in the dhcp-eval(5) manual page.
๐ SEE ALSO ๐
dhcpd(8), dhcpd.leases(5), dhcp-options(5), dhcp-eval(5), RFC2132, RFC2131.
๐ AUTHOR ๐
dhcpd.conf(5) is maintained by ISC. Information about Internet Systems Consortium can be found at https://www.isc.org.
and that's a wrap on the iconic dhcpd.conf(5) page from ISC ๐ โ source/version and date are living their best life in the footer, and honestly? periodt โจ๐
๐ฆ where this page comes from
- fedora 43: dhcp-server 12:4.4.3-22.fc43 ยท ISC AND MPL-2.0
- fedora 44: dhcp-server 12:4.4.3-26.fc44 ยท ISC AND MPL-2.0
- Copyright (C) 2004-2022 Internet Systems Consortium, Inc. ("ISC")
- Copyright (c) 1996-2003 by Internet Software Consortium
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms