Saturday, November 22, 2008

How to Install DHCP Server in Ubuntu Linux

A Dynamic Host Configuration Protocol (DHCP) server dynamically assigns IP addresses and other network setting for a given network to other networked Computers that ask. This simplifies network administration.

Now we are going to install a dhcp server with following
For these examples we are using “eth0” and the following:
IP address range: 192.168.0.50 to 192.168.0.150
Subnet Mask: 255.255.255.0
DNS Servers: 202.188.0.133, 202.188.1.5 (If You dont have a DNS omit it)
Domains: tm.net.my (If You dont have a Domain omit this)
Gateway Address: 192.168.0.1

Install DHCP Server
$ sudo apt-get install dhcp3-server (or Install using Synaptic)

Now make a Backup copy of the following files
$ sudo cp /etc/default/dhcp3-server /etc/default/dhcp3-server_backup
$sudo cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf_backup

Now Edit the following file
sudo gedit /etc/default/dhcp3-server

Find this line
... INTERFACES=""

Replace with the following line
INTERFACES="eth0"

Save the edited file.

Now we can modify the configuration file
sudo gedit /etc/dhcp3/dhcpd.conf

Find this section
.......
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
.......
Make Changes as shown below ( comment the lines by adding # )

# option definitions common to all supported networks...
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
#default-lease-time 600;
#max-lease-time 7200;

Now Find this following section in conf file
...
# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name "internal.example.org";
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;
# default-lease-time 600;
# max-lease-time 7200;
#}
...
Make Changes as shown below
# A slightly different configuration for an internal subnet.
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.50 192.168.0.150;
option domain-name-servers 202.188.0.133, 202.188.1.5;
option domain-name "tm.net.my";
option routers 192.168.0.1;
option broadcast-address 192.168.0.255;
default-lease-time 600;
max-lease-time 7200;
}

Save the edited file


Restart the DHCP Server

sudo /etc/init.d/dhcp3-server restart



No comments: