Dynamic Host Configuration Protocol (DHCP)

network

The Dynamic Host Configuration Protocol (DHCP) is an Internet protocol for automating the configuration of computers that use TCP/IP. DHCP can be used to automatically assign IP addresses, to deliver TCP/IP stack configuration parameters such as the subnet mask and default router, and to provide other configuration information such as the addresses for printer, time and news servers.

For the DHCP client (dhclient), we have to edit the file /etc/dhclient.conf. The DHCP server my ISP is using wants to know my hostname, so we send this. In addition to our IP address we want to know the subnet mask, the broadcast address and the gateway.

send host-name "hostname";
request subnet-mask, broadcast-address, routers;

OpenBSD automatically runs dhclient if a network interface is configured to use DHCP. For example, to use DHCP on the interface xl0, edit /etc/hostname.xl0

dhcp

For the DHCP server (dhcpd), we have to edit the file /etc/dhcpd.conf. Assume dhcpd is located at a machine that is gateway for two LANs, the first being 192.168.0.0/24 and the second 10.0.0.0/24. There is a nameserver at 192.168.0.1 which serves the example.com domain.

option domain-name "example.com";
option domain-name-servers 192.168.0.1;

subnet 192.168.0.0 netmask 255.255.255.0 {
   option routers 192.168.0.1;
   range 192.168.0.10 192.168.0.99;
}

subnet 10.0.0.0 netmask 255.255.255.0 {
   option routers 10.0.0.1;
   range 10.0.0.128 10.0.0.254;
}

OpenBSD does not start dhcpd automatically, so we have to edit /etc/rc.conf.local

dhcpd_flags="-q"

Leave a Reply

Your email will not be published. Name and Email fields are required.