DHCP, or Dynamic Host Configuration Protocol, allows an administrator to configure network settings for all clients on a central server.

The DHCP clients request an IP address and other network settings from the DHCP server on the network. The DHCP server in turn leases the client an IP address within a given range or leases the client an IP address based on the MAC address of the client’s network interface card (NIC). The information includes its IP address, along with the network’s name server, gateway, and proxy addresses, including the netmask.

Nothing has to be configured manually on the local system, except to specify the DHCP server it should get its network configuration from. If an IP address is assigned according to the MAC address of the client’s NIC, the same IP address can be leased to the client every time the client requests one. DHCP makes network administration easier and less prone to error.

Configure dhcp server

dhcp rpm is required to configure dhcp server. check it if not found then install

[root@manish~]# rpm -qa | grep dhcp

dhcp-3.0.5-7-el5

Now check dhcpd service in system service it should be on

[root@manish ~]# chkconfig –list | grep dhcp*

dhcpd       0:off   1:off   2:off   3:on   4:on   5:on   6:off

#setup

Select System service from list

[*]dhcpd

To assign IP to dhcp server

DHCP server have a static a ip address. First configure the ip address 192.168.0.254 with netmask of 255.255.255.0 on server.

Main configuration file of dhcp server is dhcpd.conf. This file located on /etc directory. If this file is not present there or you have corrupted this file, then copy new file first, if ask for overwrite press y

[root@manish ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf

cp: overwrite  ‘/etc/dhcpd.conf’ ? y

now open /etc/dhcpd.conf and modify it so that it looks like

# Sample configuration file for ISC dhcpd

# option definitions common to all supported networks…
#option domain-name “example.org”;
subnet 172.18.0.0  netmask 255.255.255.0 {
range 172.18.0.36 172.18.0.45;
# option routers 172.18.0.1;
# option domain-name-servers 192.200.1.14;
allow bootp;
allow booting;
default-lease-time 600;
max-lease-time 7200;
}
group My server group{
next-server 172.18.0.6;
filename “pxelinux.0”;
host manish {
fixed-address   172.18.0.15;

option routers 172.18.0.1;

option domain-name-servers 172.18.0.20;

hardware ethernet   D4:3D:7E:1A:6E:6B;
}
}

now create a blank file use to store the allocated ip address information

[root@manish~]# touch /var/lib/dhcpd/dhcpd.leases

Now restart dhcpd service and on it with chkconfig commands

[root@manish~]# service dhcpd restart

Linux Client configuration

Client configuration is very easy and straightforward. All you need to do is set ip address to dynamic in the properties of lan card. In linux

#setup select network configuration from menu list

Select lan card and enter on ok

Select USE DHCP and enter on ok

Now click on quit and quit to come back on root prompt

Now restart the network service to obtain ip from dhcp server

 

Posted in: Linux.
Last Modified: January 12, 2017

Leave a reply