Networking / Beginners

Dynamic Host Configuration Protocol (DHCP)

In the simplest form, DHCP (as per RFC2131) introduces a method for network devices to obtain network configuration parameters from a centralized server. The obtained information can be the IP address, subnet mask, default router, DNS, or even information required for remote booting.

dhclient

FreeBSD comes with built-in DHCP client called dhclient(8). Once it is executed, it attaches to the specified network interface and goes to daemon mode (runs as a background process). Dhclient then takes care of discovering DHCP server on the specified interface, and receives network configuration information, and applies that to the interface. You can run dhclient manually, and bind it to a specific network interface:

# dhclient fxp0

You can also enable dhclient(8) on any interface to run on system start up, by adding a the following line to /etc/rc.conf:

ifconfig_fxp0="DHCP"

ISC DHCPD

FreeBSD does not come with a built-in DHCP server. However, the widely used ISC DHCP server (as well as client and relay) is available from the ports tree, under /usr/ports/net/isc-dhcp3-server.

ISC DHCPD (currently at version 3), is the de facto open source DHCP server solution that is available on many platforms, including FreeBSD.

Installing isc-dhcp3-server from port installs requires binaries, manual pages, and sample configuration file. A sample configuration file can be found at /usr/local/ etc/dhcpd.conf.sample. The dhcpd daemon looks for its configuration file at /usr/local/etc/dhcpd.conf. So, you can simply copy the sample file as the configuration file. Then make your own modifications, before starting the dhcpd daemon.

Enabling isc-dhcpd is possible by adding the following line to your /etc/rc.conf file:

dhcpd_enable="YES"

This will enable dhcpd to start automatically on system start up, by running the relevant rc script. You can also manually start DHCP server by running its rc script at:

# /usr/local/etc/rc.d/isc-dhcpd start

This will start the DHCP server that awaits on all active network interfaces for incoming DHCP discovery requests. If your server has multiple network interfaces, there are chances that you may not want dhcpd to be enabled on all interfaces (for example, your WAN uplink interface). This can be achieved by adding the following line to the /etc/rc.conf file:

dhcpd_ifaces="fxp0 bge0"

This will tell dhcpd to only listen for incoming requests on fxp0 and bge0 interface, and simply ignore all the other active interfaces.

[Contents] [Next]