Setup DHCP Server On Ubuntu 14.04 LTS Server

by
Share this Article: Facebook0Google+0Twitter23LinkedIn0Reddit0StumbleUpon1

In our previous tutorial, we have explained how to setup DHCP server on CentOS 6.5. Today, we will do the same on Ubuntu 14.04 LTS server.

Installation

To install DHCP server on Ubuntu 14.04 LTS, enter the following command:

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

Configuration

DHCP server configuration is not that difficult. First, we have to assign on what interfaces should the DHCP server (dhcpd) serve DHCP requests. In my case, I have only one Interface on my system (eth0), so I assigned eth0.

To do that, edit file /etc/default/isc-dhcp-server,

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

Assign the network interface:

[...]
INTERFACES="eth0"

Save and close the file.

Now, edit dhcpd.conf file,

sudo nano /etc/dhcp/dhcpd.conf

Make the changes as shown below.

Set the domain name and domain-name servers:

[...]

# option definitions common to all supported networks...
 option domain-name "unixmen.local";
 option domain-name-servers server.unixmen.local;

[...]

If this DHCP server is the official DHCP server for the local network, you should uncomment the following line:

[...]
authoritative;
[...]

Define the sunbet, range of ip addresses, domain and domain name servers like below:

[...]
# A slightly different configuration for an internal subnet.
 subnet 192.168.1.0 netmask 255.255.255.0 {
 range 192.168.1.20 192.168.1.30;
 option domain-name-servers server.unixmen.local;
 option domain-name "unixmen.local";
 option routers 192.168.1.1;
 option broadcast-address 192.168.1.255;
 default-lease-time 600;
 max-lease-time 7200;
 }
[...]

If you want to assign a fixed IP address to your client, you should enter it’s MAC id and the IP address in the following directive. For example, I want to assign a fixed IP address 192.168.1.15 to my Ubuntu client, hence I modified the following directive as shown below.

[...]
host ubuntu-client {
 hardware ethernet 00:22:64:4f:e9:3a;
 fixed-address 192.168.1.15;
 }
[...]

After making all the changes you want, save and close the file. Be mindful that if you have another unused entries on the dhcpd.conf file, comment all of them. Otherwise, you’ll get issues while starting dhcp service.

Now, restart dhcp service and make it to start automatically on every reboot.

sudo service isc-dhcp-server restart

Likewise, you can start/stop dhcp service as shown below:

sudo service isc-dhcp-server start
sudo service isc-dhcp-server stop

Configure Clients

Now, go to the client configuration network settings and change the IP settings to Automatic (DHCP).

Here is my Lubuntu 14.04 settings:

Editing Wired connection 1_001

Restart the network or reboot the client system to get IP address automatically from the DHCP server.

Now, you should see the IP address has been automatically assigned to the clients from the DHCP server.

Run the following command from the client system Terminal:

sudo ifconfig

Sample output:

sk@sk: ~_002

As you see in the above picture, My ubuntu client system which has MAC id 00:22:64:4f:e9:3a gets a fixed IP address 192.168.1.15 from the DHCP server.

That’s it. DHCP server is up and ready.

Cheers!

For questions please refer to our Q/A forum at : http://ask.unixmen.com/


Share this Article: Facebook0Google+0Twitter23LinkedIn0Reddit0StumbleUpon1