(dhcp-server)= # DHCP Server VyOS uses Kea DHCP server for both IPv4 and IPv6 address assignment. ## IPv4 server The network topology is declared by shared-network-name and the subnet declarations. The DHCP service can serve multiple shared networks, with each shared network having 1 or more subnets. Each subnet must be present on an interface. A range can be declared inside a subnet to define a pool of dynamic addresses. Multiple ranges can be defined and can contain holes. Static mappings can be set to assign "static" addresses to clients based on their MAC address. ### Configuration ```{cfgcmd} set service dhcp-server hostfile-update Create DNS record per client lease, by adding clients to /etc/hosts file. Entry will have format: `_.` ``` #### Shared network options The following DHCP options apply to an entire shared network. All subnets inherit these values unless the same option is set locally. ```{cfgcmd} set service dhcp-server shared-network-name \ option bootfile-name \ Bootstrap file name (DHCP Option 67). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option bootfile-server \ Server from which the initial boot file is to be loaded (DHCP siaddr field). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option bootfile-size \ Bootstrap file size in 512-octet blocks (DHCP Option 13). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option captive-portal \ Captive portal API endpoint (DHCP Option 114). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option capwap-controller \ IP address of CAPWAP access controller (DHCP Option 138). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option client-prefix-length \ Specifies the client subnet mask as per RFC 950. If unset, the subnet declaration is used (DHCP Option 1). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option default-router \ IP address of default router (DHCP Option 3). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option domain-name \ The domain-name parameter should be the domain name that will be appended to the client's hostname to form a fully-qualified domain-name (FQDN) (DHCP Option 15). This is the configuration parameter for the entire shared network definition. All subnets will inherit this configuration item if not specified locally. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option domain-search \ The domain-name parameter should be the domain name used when completing DNS request where no full FQDN is passed. This option can be given multiple times if you need multiple search domains (DHCP Option 119). This is the configuration parameter for the entire shared network definition. All subnets will inherit this configuration item if not specified locally. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option interface-mtu \ Client interface MTU (DHCP Option 26). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option ip-forwarding Enable IP forwarding on the client (DHCP Option 19). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option ipv6-only-preferred \ Disable IPv4 on IPv6-only hosts for the specified number of seconds (RFC 8925, DHCP Option 108). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option name-server \ Inform client that the DNS server can be found at `
` (DHCP Option 6). This is the configuration parameter for the entire shared network definition. All subnets will inherit this configuration item if not specified locally. Multiple DNS servers can be defined. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option ntp-server \ IP address of NTP server (DHCP Option 42). This option can be specified multiple times. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option pop-server \ IP address of POP3 server (DHCP Option 70). This option can be specified multiple times. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option server-identifier \ Address for DHCP server identifier (DHCP Option 54). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option smtp-server \ IP address of SMTP server (DHCP Option 69). This option can be specified multiple times. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option static-route \ next-hop \ Classless static route destination subnet (DHCP Options 121 and 249). This option can be specified multiple times. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option tftp-server-name \ TFTP server name (DHCP Option 66). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option time-offset \ Client subnet offset in seconds from Coordinated Universal Time (UTC) (DHCP Option 2). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option time-server \ IP address of time server (DHCP Option 4). This option can be specified multiple times. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option time-zone \ Time zone to send to clients (DHCP Options 100 and 101, `pcode` and `tcode`, RFC 4833). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option vendor-option \ \ \ This configuration parameter lets you specify a vendor-option for the entire shared network definition. All subnets will inherit this configuration item if not specified locally (DHCP Option 43). An example for Ubiquiti is shown below: ``` **Example:** Pass address of Unifi controller at `172.16.100.1` to all clients of `NET1` ```none set service dhcp-server shared-network-name 'NET1' option vendor-option ubiquiti unifi-controller '172.16.100.1' ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option wins-server \ IP address for Windows Internet Name Service (WINS) server (DHCP Option 44). This option can be specified multiple times. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ option wpad-url \ Web Proxy Autodiscovery (WPAD) URL (DHCP Option 252). ``` ```{cfgcmd} set service dhcp-server listen-address \ This configuration parameter lets the DHCP server to listen for DHCP requests sent to the specified address, it is only realistically useful for a server whose only clients are reached via unicasts, such as via DHCP relay agents. ``` ```{cfgcmd} set service dhcp-server log-level \ Set the logging verbosity of the Kea DHCP server. The default level is `info`. ``` #### Individual Client Subnet ```{cfgcmd} set service dhcp-server shared-network-name \ authoritative This says that this device is the only DHCP server for this network. If other devices are trying to offer DHCP leases, this machine will send 'DHCPNAK' to any device trying to request an IP address that is not valid for this network. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ subnet \ subnet-id \ This configuration parameter is required and must be unique to each subnet. It is required to map subnets to lease file entries. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ subnet \ option default-router \ This is a configuration parameter for the ``, saying that as part of the response, tell the client that the default gateway can be reached at `
` (DHCP Option 3). ``` ```{cfgcmd} set service dhcp-server shared-network-name \ subnet \ option name-server \ This is a configuration parameter for the subnet, saying that as part of the response, tell the client that the DNS server can be found at `
` (DHCP Option 6). Multiple DNS servers can be defined. ``` ```{cfgcmd} set service dhcp-server shared-network-name \ subnet \ lease \ Assign the IP address to this machine for `