Posted by: jasonk2600 | January 13, 2010

FreeBSD DHCP Server

Synopsis

This post will describe the steps necessary to configure the ISC DHCP Server under FreeBSD for a simple local area network (LAN).

Installation

Install the ISC DHCP Server v3.1 from the FreeBSD ports collection.  NOTE: The default port configuration options are acceptable.

# cd /usr/ports/net/isc-dhcp31-server
# make config
# make install clean
# rehash

 

Configuration

Create the /usr/local/etc/dhcpd.conf configuration file for the ISC DHCP Server and set the following global settings for the server. NOTE: The following will configure the ISC DHCP Server to be the main authoritative DHCP server for the LAN. Use your local domain name and DNS server addresses.

option domain-name "yourdomain.com";
option domain-name-server ns1.yourdomain.com, n2.yourdomain.com;

default-lease-time 600;
max-lease-time 7200;

authoritative;

ddns-update-style none;

log-facility local7;

 

Next, configure network settings and IP addresses range from your local network for the DHCP server to serve. These settings are appended to the end of the /usr/local/etc/dhcpd.conf configuration file.

subnet 10.0.1.0 netmask 255.255.255.0 {
  # Assign addresses from 10.0.1.100 to 10.0.1.200.
  range 10.0.1.100 10.0.1.200;
  # Parent domain name for all hosts on LAN.
  option domain-name "LAN.yourdomain.com";
  # DNS server for hosts on LAN.
  option domain-name-servers ns1.LAN.yourdomain.com;
  # Default route for hosts on LAN.
  option routers 10.0.1.1;
  default-lease-time 600;
  max-lease-time 7200;
}

 

In addition to defining the network settings and IP addresses for hosts on the local network, you can also specify a static IP address to be assigned to a specific host by following the example below. These settings are appended to the end of the /usr/local/etc/dhcpd.conf configuration file.

host ns1 {
  # MAC address of the host to receive this static IP address.
  hardware ethernet 80:00:07:26:c0:a5;
  # Static IP address to assign to this host.
  fixed-address 10.0.1.2;
  option domain-name "LAN.yourdomain.com";
  option domain-name-servers ns1.LAN.yourdomain.com;
  option routers 10.0.1.1;
  default-lease-time 600;
  max-lease-time 7200;
}

 

Enable the ISC DHCP Server to automatically start and system boot and start it for the first time.

# echo 'dhcpd_enable="YES"' >> /etc/rc.conf
# /usr/local/etc/rc.d/isc-dhcpd start

 

Testing

To text the newly configured DHCP server, configure a client system on the local network to automatically obtain an IP address.  The client should automatically obtain an IP address from the IP address range you specified above along with the other network settings specified.  If the client fails to obtain an IP address, check /var/log/messages for any error messages and ensure that the ISC DHCP Server is the only DHCP server running on the local network.

References

 

  [EoF]
Advertisements

Responses

  1. Excellent – This is wonderful. You’ve done a great job. When you’re standing on the beginning side of doing something like this, it can seem rather daunting and overwhelming but once you’ve done it, looking back, you wonder what you were worried about. You’ve made a seemingly difficult task really easy to complete.

    One constructive criticism though.
    You’ve got a typo in the global configuration section.

    option domain-name-server

    should be:

    option domain-name-servers

    The DHCP daemon kicks up a stink if you use domain-name-server .


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: