Configuring DHCP Server in Linux

Posted in Technical by admin on January 7th, 2008

Configuring DHCP Server in Linux

DHCP Introduction:

While you are using cable modem or DSL connection the IP is assigned to your PC dynamically by the service providers. If you are using router between home computer and Internet then your PC will get IP address from router at the boot time.
If you are looking to configure your Linux machine as DHCP Server then you can disable this feature from router.
Here is detail about configuring Linux machine as DHCP Server.

Download and Install DHCP Package:

Normally Linux packages are in RPM format and to download and install is not difficult.
To search for a DHCP package remember that dhcp file name always starts with name dhcp followed by its version number such as dhcp-4.01rc 14-1.i386.rpm.
While using Ubuntu package name may consist of version number also. In Ubuntu you can use dpkg –list | grep dhcp command to find out dhcp packages list and find dhcp package name.

Editing /etc/dhcpd.conf File:
When DHCP initialize, it reads file configuration from /etc/dhcpd.conf. DHCP RPM package is not installed by default but you have to manually install it. However you can find its sample copy at the following path
/usr/share/doc/dhcp-/dhcpd.conf.sample

It is necessary to copy this sample file dhcpd.conf into /etc directory and then edit this. Copy this file using this command
[root@linux-server tmp]# cp /usr/share/doc/dhcp-3.0p11/dhcpd.conf.sample/etc.dhcpd.conf

While in Ubuntu file configuration name is /etc/dhcp*/dhcpd.conf and you have to follow the same syntax which is used in Redhat/ Fedora.
Complete Information of dhcpd.conf is detailed here
Ddns-update-style interim
Ignore client-updates

Subnet 192.168.2.0 netmask 255.255.255.0 {

#Here is the range in from which DHCP server will assign Ip Addresses to clients
range 192.168.2.201 192.168.2.220;

# set number of seconds that a client PC will keep specific IP address

default-lease-time 86400;

max-lease-time 90000;

#Here is the information to set the default gateway used by PC clients

option router 192.168.1.1;

# Do not forward DHCP requests from this NIC Interface

option ip-forwarding off;

# Broadcast address and subnet mask which is used by DHCP clients

option broadcast-address 192.168.2.255;
option subnet-mask 255.255.255.0;

# Set DNS server used by DHCP clients

option domain-name-servers 192.168.2.100;

# Set NTP server used by DHCP client

option nntp-server 192.168.2.100;

# For WINS server for your Windows clients,
It needs to include this option in the dhcpd.conf file:

option netbios-name-servers 192.168.2.100;

# Assign IP addresses based on the clients and ethernet MAC address as follows (Host’s name is “linux-server”:

host Linux-server {
hardware ethernet 08:00:2b:4c:59:23;
fixed-address 192.168.2.222;
}
}
#
# List an unused interface here
#
subnet 192.168.2.0 netmask 255.255.255.0 {
}

Here you can find DHCP option page to find out more information after dhcp installation.

[root@bigboy tmp]# man dhcp-options

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

Leave a Comment