Setting up a DHCP server

Depending on the network infrastructure, you may need a DHCP server. This step shows how to install and configure a DHCP server.

Requirements:

Proceed as follows:

1. Enter the doas pkg install dhcpd command in the console to install the DHCP server.
2. Open the dhcpd.conf. file with doas ee /usr/local/etc/dhcpd.conf and edit the configuration according to your requirements..
Sample:
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.10 192.168.0.20;
default-lease-time 600;
max-lease-time 72400;
option subnet-mask 255.255.255.0;
}
3. Open the rc.conf file with doas ee /etc/rc.conf and add the following lines:
dhcpd_enable="YES"
dhcpd_flags="wlan0"
dhcpd_ifaces="wlan0"
4. Enter the doas service dhcpd start command to start the DHCP service. After a restart, the DHCP service is started automatically because of the corresponding entry in rc.conf.
5. The ee /var/db/dhcpd.leases command can be used to view current and expired leases.
The DHCP server is thus active and only listens to requests on the interface wlan0.
For more information, see: https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-dhcp.html or https://man.openbsd.org/dhcpd.8