Syed Jahanzaib Personal Blog to Share Knowledge !

October 7, 2010

howto install simple DHCP server in Ubuntu

Filed under: Linux Related — Syed Jahanzaib / Pinochio~:) @ 8:03 AM

This is a custom made configuration guide on howto install simple DHCP server in Ubuntu. I hope it will help you guys.

How to Install and Configure DHCP Server in Ubuntu Server

Install DHCP server in ubuntu

# apt-get install dhcp3-server

This will complete the installation.

Configuring DHCP server

If you have two network cards in your ubuntu server you need to select which interface you want to use for DHCP server listening.By default it listens to eth0.

You can change this by editing /etc/default/dhcp3-server file

# nano /etc/default/dhcp3-server

Find this line

INTERFACES=”eth0″

Replace with the following line

INTERFACES=”eth1″

Save and exit. (This is optional )

+++++++++++++++++++++++++++++++++++++++++++++++++++

Now to setup dhcp parameters, Edit /etc/dhcp3/dhcpd.conf file using the following command

# nano /etc/dhcp3/dhcpd.conf

Using address pool method:

You need to change the following sections in /etc/dhcp3/dhcpd.conf file

default-lease-time 900;

max-lease-time 7200;

option subnet-mask 255.255.255.0;

option broadcast-address 192.168.1.255;

option routers 192.168.1.254;

option domain-name-servers 192.168.1.1, 192.168.1.2;

option domain-name “yourdomainname.com”;

subnet 192.168.1.0 netmask 255.255.255.0 {

range 192.168.1.20 192.168.1.250;

}

Save and exit the file

Now you need to restart DHCP server using the following command

# service dhcp3-server restart

DHCP server Ready to serve, J Alhamdolillah

This will result in the DHCP server giving a client an IP address from the range 192.168.1.20-192.168.1.250 . It will lease an IP address for 600 seconds if the client doesn’t ask for a specific time frame. Otherwise the maximum (allowed) lease will be 7200 seconds. The server will also “advise” the client that it should use 255.255.255.0 as its subnet mask, 192.168.1.255 as its broadcast address, 192.168.1.254 as the router/gateway and 192.168.1.1 and 192.168.1.2 as its primary & secondary DNS servers.

+++++++++++++++++++++++++++++++++++++++++++++++++++

Using MAC address method:

This method is you can reserve some of the machines or all the machines with fixed ip address.
In the following example i am using fixed ip address for PC1,PC2,printer1 and printer2

default-lease-time 600;

max-lease-time 7200;

option subnet-mask 255.255.255.0;

option broadcast-address 192.168.1.255;

option routers 192.168.1.254;

option domain-name-servers 192.168.1.1, 192.168.1.2;

option domain-name “yourdomainname.com”;

subnet 192.168.1.0 netmask 255.255.255.0 {

range 192.168.1.10 192.168.1.200;

}

host PC1 {

hardware ethernet 00:1b:63:ef:db:54;

fixed-address 192.168.1.20;

}

host PC2 {

hardware ethernet 00:0a:95:b4:d4:b0;

fixed-address 192.168.1.21;

}

host printer1 {

hardware ethernet 00:16:cb:aa:2a:cd;

fixed-address 192.168.1.22;

}

host printer2 {

hardware ethernet 00:0a:95:f5:8f:b3;

fixed-address 192.168.1.23;

}

Now Again, you need to restart DHCP server using the following command

# service dhcp3-server restart

This time DHCP will give pc1 pc2 printer1 printer2 the same ip every time they request from dhcp server. Other pc’s or devices will get dynamic ip’s.

Regards,
SYED JAHANZAIB

Network Engineer
LG – New Allied Electronics Industries (Pvt) Ltd.
Web: http://www.nae.com.pk
Linkdein: http://pk.linkedin.com/pub/syed-jahanzaib/24/3b/407

اور آپ کا رب آپ کو نصیحت کر رہا ہے
فَاسْتَبِقُواْ الْخَيْرَاتِ
نیکیوں کی طرف د و ڑ و

From: speedzonenetwork@hotmail.com
To: aacable@hotmail.com
Subject: Support For Linux Server On Ubuntu
Date: Thu, 7 Oct 2010 03:10:16 -0400

Sir,

Please send me linux server tutorial on ubuntu.

Sincerely,

Fahad Khan

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

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

Blog at WordPress.com.

%d bloggers like this: