Install Configure DHCP Server Ubuntu 12.10 / 12.04 / 11.10


Dynamic Host Configuration Protocol (DHCP) is a network protocol that enables a server to automatically assign an IP address to a computer from a defined range of numbers (i.e., a scope) configured for a given network.

DHCP assigns an IP address when a system is started, for example:

  • A user turns on a computer with a DHCP client.
  • The client computer sends a broadcast request (called a DISCOVER or DHCPDISCOVER), looking for a DHCP server to answer.
  • The router directs the DISCOVER packet to the correct DHCP server.
  • The server receives the DISCOVER packet. Based on availability and usage policies set on the server, the server determines an appropriate address (if any) to give to the client. The server then temporarily reserves that address for the client and sends back to the client an OFFER (or DHCPOFFER) packet, with that address information. The server also configures the client’s DNS servers, WINS servers, NTP servers, and sometimes other services as well.
  • The client sends a REQUEST (or DHCPREQUEST) packet, letting the server know that it intends to use the address.
  • The server sends an ACK (or DHCPACK) packet, confirming that the client has a been given a lease on the address for a server-specified period of time.

When a computer uses a static IP address, it means that the computer is manually configured to use a specific IP address. One problem with static assignment, which can result from user error or inattention to detail, occurs when two computers are configured with the same IP address. This creates a conflict that results in loss of service. Using DHCP to dynamically assign IP addresses minimizes these conflicts.

For a technical review of DHCP standards, see RFCs 2131 and 2132.

Note: At Indiana University, UITS prohibits individuals and departments from setting up local DHCP servers on the IU network. Almost all wireless access points, many wired Ethernet routers, and computers running Internet Connection Sharing have built-in DHCP servers. While this makes configuration of a small network easier, it can cause problems when the DHCP servers are used in larger networks. Client computers configured to use DHCP for IP assignment do not need statically assigned IP addresses. In addition, they generally do not need to have addresses configured for DNS servers or WINS servers, as these are also set by the DHCP server.

Earlier we have seen how to install DNS server on Ubuntu 10.10 and installing local DNS server on Ubuntu. In this tutorial we will see how to setup Local DHCP server on Ubuntu 12.10.

Note: that this method will also work on Ubuntu 12.04 and 11.10

Step By Step Guide to Install and Configure DHCP Server on Ubuntu 12.10

Step 1: Make sure that the latest version is installed:

sudo apt-get install -y isc-dhcp-server

Note: Don’t be alarmed if the startup fails; that’s because you haven’t configured it yet.

Step 2.1: Enable the DCHP server on your network interface (in my case eth0):

sudo vi /etc/default/isc-dhcp-server

Step 2.2: Set INTERFACES=”” to the name of the network interface that you want to enable the DHCP server on:

INTERFACES="eth0"

Step 3.1: Edit the DHCP server configuration:

sudo vi /etc/dhcp/dhcpd.conf

Step 3.2: The contents of my configuration file, for me the comments already in the file was what I needed to make the necessary changes:

#
# Sample configuration file for ISC dhcpd for Debian
#
# Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as
# configuration file instead of this file.
#
#
 
ddns-update-style none;
option domain-name "techienote.home";
option domain-name-servers server.techienote.home;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.101 192.168.1.250;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.1.255;
  option routers 192.168.1.1;
  option domain-name-servers 192.168.1.98;
}

This needs a little bit of explaining.

  • Adjust your settings according to your network requirements.
  • The option domain name is your dns zone name. For example mine is set to techienote.home.
  • Range should be the range of ip addresses that you want the server to give out to clients.
  • Step 4: Restart the DHCP server (it should now start without problems):

    sudo service isc-dhcp-server restart

    Your DHCP server should be running, however it is best to check. Open up a terminal and type:

    sudo netstat -uap

    which will show you the following information:

    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    udp        0      0 server.techienot:domain *:*                                 1002/named      
    udp        0      0 localhost:domain        *:*                                 1002/named      
    udp        0      0 *:bootps                *:*                                 1020/dhcpd      
    udp        0      0 *:48749                 *:*                                 547/avahi-daemon: r
    udp        0      0 *:29300                 *:*                                 1020/dhcpd      
    udp        0      0 *:mdns                  *:*                                 547/avahi-daemon: r

Leave a Reply

rss twitter facbook

Categories

Archives