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.
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 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.
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:
- Open-up terminal on ubuntu-desktop and execute the below command:
sudo gedit /etc/network/interfaces
- In this opened file write below code:
iface eth0 inet static
address “Remove these quotes & mention IP of your router.”
iface eth1 inet dhcp
- Now, restart your networking. Run below command:
sudo /etc/init.d/networking restart
- Now install dhcp server on your machine.
sudo apt-get install dhcp3-server
- 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.
- 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.