Ubuntu 10.04: Setup DHCP Server

Before diving into the server configuration, I would like to introduce DHCP server to those who are unaware of it and have reached this post without any research work.

Coming to the point, DHCP Server allots the IP addresses to computers. You need DHCP Server if you do not want to manually maintain IP Addresses or you have less IP Addresses than number of machines you have, as dynamic DHCP Server will recycle IP Addresses on machines.

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.

ankit-mathur-dhcp-server-setup-on-ubuntu-blog

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

  1. A user turns on a computer with a DHCP client.
  2. The client computer sends a broadcast request (called a DISCOVER or DHCPDISCOVER), looking for a DHCP server to answer.
  3. The router directs the DISCOVER packet to the correct DHCP server.
  4. 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.
  5. The client sends a REQUEST (or DHCPREQUEST) packet, letting the server know that it intends to use the address.
  6. 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.

Configuring a DHCP Server on Ubuntu 10.04 Machine

Before starting the configuration, make sure whether you are using a virtual machine or a dedicated system for the server.

If using a virtual system, you should go to it’s network settings and select Bridged adapter from there. For server, enable another adapter as NAT, not as bridged. If your client system also lives on virtual machine, then use bridged adapter for it too.

Now, configuring server:

  1. Open-up terminal on ubuntu-desktop and execute the below command:
    sudo gedit /etc/network/interfaces

  2. In this opened file write below code:
    auto eth0
    iface eth0 inet static

    address “Remove these quotes & mention IP of your router.”
    netmask 255.255.255.0

    auto eth1
    iface eth1 inet dhcp

  3. Now, restart your networking. Run below command:
    sudo /etc/init.d/networking restart
  4. Now install dhcp server on your machine.
    sudo apt-get install dhcp3-server

  5. Now, move to the newly created folder i.e. dhcp3 inside /etc and edit the dhcpd.conf file. Mention your desired range of IPs, lease time, domain name and all others.
  6. To start the server:
    service dhcp3-server restart

This finishes the server side configuration. Try this at your end and let know if any problem occurs.
Thanks 🙂

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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