Configuring DHCP on a FreeBSD DNS server

The dynamic host configuration protocol (DHCP) describes the means by which a system can connect to a network and obtain the necessary information for communication upon that network. The manual is available in the FreeBSD manual pages.

When the client is executed, it begins broadcasting requests for configuration information. By default, these requests are on UDP port 68. The server replies on UDP 67, giving the client an IP address and other relevant network information, such as netmask, router and DNS servers. This information comes in the form of a lease and is only valid for a certain amount of time. In this manner, stale IP addresses can be reclaimed.

It is important to know, that some internet service providers (ISPs) only allow traffic to customers, that use DHCP. Fullrate is an example of those. In such cases, the line will suddently appear dead even though, it has been configured with static network information.

Now, in our example, we want to configure the internet network interface on a FreeBSD 7.2 DNS server by using the DHCP client. What we need to take care of is the DNS configuration in resolv.conf and our hostname. The client will by default overwrite this. In stead of this, we want our local DNS to be prepended, the DNS servers of the ISP to be appended, our search domain to be superseded and our hostname to be superseded.

First, we make sure, that rc.conf is configured for DHCP. In our example, the interface is called bge0.

vi /etc/rc.conf
ifconfig_bge0="DHCP"

Then, we configure the client, where X and Y are other DNS servers of our own, that we want to use.

vi /etc/dhclient.conf

interface "bge0"
{
prepend domain-name-servers 127.0.0.1, X, Y;
supersede host-name "star.foobar.com";

supersede domain-name "foobar.com;
send dhcp-lease-time 9000;
}

Make sure, that these declarations end with a semicolon, and, that notation quotes are used where expected. Consult the manual. Forgetting this will result in silent unexpected behavior, such as overwriting our DNS configuration.

That’s it. We do a reboot test and confirm, that things look right.

ifconfig bge0
cat /etc/resolv.conf
hostname

Print

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>