Setting DHCP Server on FreeBSD

Home / Setting DHCP Server on FreeBSD

Setting DHCP Server on FreeBSD

December 9, 2015 | Uncategorized | No Comments

In open network such as internet cafe, campus, etc, DHCP protocol is widely used. DHCP providing client an IP address without them set IP manually. DHCP server also manage what IP should and should not be used by client in a network. This will ensure a dynamic environment in a network.

In this article we will discuss about install and configuring DHCP on FreeBSD machine. Technically I use:

  1. FreeBSD amd64 8.3
  2. ISC DHCP Server

How DHCP Works

When a client system first joins a network using DHCP, it broadcasts a request to the local network for configuration information. The DHCP server then answers this request with the parameters set in the DHCP server configuration file. The client system applies this assigned configuration to its network interface in order to communicate with the network.

DHCP servers generally assign IP addresses in one of two ways: statically or dynamically. The static method allocates an IP address to a client based on the client’s hardware MAC (Media Access Control) address. This IP address will not change. A dynamic IP address assignment is a leased address. The DHCP server assigns these addresses from a pool or range set by the administrator. Dynamic IP addresses are returned to the pool when a client disconnects from the network. If the same client rejoins the network, it may be assigned a different IP address if the previously assigned address is unavailable.

Preparation

A DNS server is not necessary to run DHCP server. However if you plan on running your own DNS server, you should install and configure it before proceeding to next stage.

Make sure you have acquired and become super user to do installation.

Installation

Installing ISC DHCP Server is as easy as other ports installation. The version we use will be ISC DHCP Server version 4.2. Now do command:

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

A menu of options might appear. In this article we will use default options, so leave those options at defaults.

Configuration

Fortunately, we can use a sample configuration provided by ISC DHCP server.

cd /usr/local/etc
cp dhcpd.conf.sample dhcpd.conf

ISC DHCP server use a plain text /usr/local/etc/dhcpd.conf as its main configuration file. Edit that file and adjust as we need.

In this article we will use a scenario like this:

  1. Using domain name ns1.celestial-being.net and ns2.celestial-being.net with IP address 192.168.1.11 (this existing domain name is not necessary)
  2. The available address will be 192.168.1.100 to 192.168.1.254.
  3. We disable dynamic DNS update.
  4. The router is at 192.168.1.1

Now alter the /usr/local/etc/dhcpd.conf and adjust it with your need. This one should fulfill our need:

option domain-name "celestial-being.net";
option domain-name-servers 192.168.1.11;

authoritative;

ddns-update-style none

subnet 192.168.1.0 netmask 255.255.255.0 {
   range 192.168.1.100 192.168.1.254
   option routers 192.168.1.1;
}

Make sure you terminating the line with “;” (semi-colon).

Another thing to note: there should be no other DHCP server on network. Most routers have a built-in DHCP server therefore if you want to use own DHCP server, disable the router DHCP’s before.

Whether we use ourself as a router or not, we can specify the router used by client.

At this point, we have configured a simple DHCP network.

,

About Author

about author

xathrya

A man who is obsessed to low level technology.

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial