Home > Old Post dari Unilanet > Installing DHCP server on FreeBSD

Installing DHCP server on FreeBSD

I would like to automatically assign IP address to computers attached to my network rather than setting them manually everytime they are attached to my network. This time, I’m going to write how I install and configure the ISC DHCP on my FreeBSD Router.

What is DHCP

Dynamic Host Configuration Protocol (DHCP) is a protocol for automate the assignment of IP addresses in a network. Each computer connected to a network must have a unique IP, and without DHCP TCP/IP information must be assigned manually on each computer.

Installing ISC DHCP

The ISC DHCP server is a free implementation for the DHCP protocol. The software is available at DHCP Site

Before you install DHCP, you need to make sure the bpf device is compiled into your kernel. If you are using the default kernel (GENERIC) then it is built into your kernel by default.

To install ISC DHCP Server using ports on FreeBSD type (as root):

# cd /usr/ports/net/isc-dhcp3-server
# make install clean

Once you have finished installing, we can move on to configuring the server. A sample configuration file is located in /usr/local/etc/dhcpd.conf.sample and you can copy it or rename it to dhcpd.conf.


You can use your favorite text editor to edit the dhcpd configuration file. This is an example of my dhcpd.conf, you can read more about dhcpd.conf to read more options so you could set yours according to your need.

option domain-name "unila.ac.id";
# the domain-name option specifies the domain provided 
to clients as the default search domain.

option domain-name-servers dns.unila.ac.id, ns1.unila.ac.id;

# the domain-name-servers provide clients with the DNS server.
Replace this with your DNS server.

default-lease-time 86400;
max-lease-time 86400;

# The default lease expiry time in seconds
# This is the maximum length of time that the server will lease for.


# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.

ddns-update-style none;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

subnet netmask {
        option routers;

Now, I have some computers that I’d like to assign IP address manually. This is what I added to my configuration:

host pingpong {
        hardware ethernet 00:00:00:00:00:00; [1]
        fixed-address pingpong; [2]
        default-lease-time 604800;
        max-lease-time 604800;

# [1] You should change this to the hardware MAC address of the client
# [2] You should provide this with a valid hostname, and dhcp server 
will resolve the hostname before returning the lease to the client. 
I edited /etc/hosts and specify pingpong with 
my IP address.

Running dhcpd at startup

To configure FreeBSD to run dhcpd at start-up you need to edit /etc/rc.conf and add the following:


and since I only need dhcpd on my local area network, I also added the following to my rc.conf dhcpd_ifaces=”rl1”.

You can now start dhcpd by typing:

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

Client configuration

Now, it’s time for us to configure the client computers to use DHCP.

To configure Microsoft Windows 2000/XP operating system to automatically get ip address from the DHCP server:

  1. Right click on ‘My Network Places’ and select Properties
  2. Right click on ‘Local Area Connection’ and select Properties
  3. Select ‘Internet Protocol (TCP/IP)’ and click Properties
  4. Select ‘Obtain an IP address automatically” (and repeat for DNS) and click OK

To configure Mac OS X operating system to use DHCP:

  1. Click on the blue apple logo on the top left corner and go to System Preferences
  2. Choose Network
  3. Choose the network port you are using (Airport, Built-in Ethernet)
  4. Go to the TCP/IP tab
  5. Configure IPv4: Using DHCP

FreeBSD has a built-in dhcp client and to receive a dynamic IP address from my FreeBSD router this is what I type:

# dhclient rl0

Replace rl0 with your own interface (Type ifconfig -a) to see.

You can also configure your system to automatically use dhcp at startup by editing /etc/rc.conf. Add the following to your /etc/rc.conf:


  1. No comments yet.
  1. No trackbacks yet.

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: