Install DHCP on Ubuntu 22.04
From:     https://ubuntu.com/server/docs/network-dhcp


Intro Install DHCPd Configure DHCPd References



Dynamic Host Configuration Protocol (DHCP)

The Dynamic Host Configuration Protocol (DHCP) is a network service that enables host computers to be automatically assigned settings from a server as opposed to manually configuring each network host. Computers configured to be DHCP clients have no control over the settings they receive from the DHCP server, and the configuration is transparent to the computer’s user. The most common settings provided by a DHCP server to DHCP clients include: However, a DHCP server can also supply configuration properties such as: The advantage of using DHCP is that any changes to the network, such as a change in the DNS server address, only need to be changed at the DHCP server, and all network hosts will be reconfigured the next time their DHCP clients poll the DHCP server. As an added advantage, it is also easier to integrate new computers into the network, as there is no need to check for the availability of an IP address. Conflicts in IP address allocation are also reduced. A DHCP server can provide configuration settings using the following methods: The last two methods can be considered “automatic” because in each case the DHCP server assigns an address with no extra intervention needed. The only difference between them is in how long the IP address is leased; in other words, whether a client’s address varies over time. The DHCP server that Ubuntu makes available is dhcpd (dynamic host configuration protocol daemon), which is easy to install and configure and will be automatically started at system boot. Install dhcpd
At a terminal prompt, enter the following command to install dhcpd: apt install isc-dhcp-server Note: dhcpd’s messages are being sent to syslog. Look there for diagnostics messages. Configure dhcpd
You will probably need to change the default configuration by editing /etc/dhcp/dhcpd.conf to suit your needs and particular configuration. Most commonly, what you want to do is assign an IP address randomly. This can be done with settings as follows: # minimal sample /etc/dhcp/dhcpd.conf default-lease-time 600; max-lease-time 7200; subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.150 192.168.1.200; option routers 192.168.1.254; option domain-name-servers 192.168.1.1, 192.168.1.2; option domain-name "mydomain.example"; } This will result in the DHCP server giving clients an IP address from the range 192.168.1.150–192.168.1.200. It will lease an IP address for 600 seconds if the client doesn’t ask for a specific time frame. Otherwise the maximum (allowed) lease will be 7200 seconds. The server will also “advise” the client to use 192.168.1.254 as the default-gateway and 192.168.1.1 and 192.168.1.2 as its DNS servers. You also may need to edit /etc/default/isc-dhcp-server to specify the interfaces dhcpd should listen to. INTERFACESv4="eth4" After changing the config files you need to restart the dhcpd service: systemctl restart isc-dhcp-server.service References