Tuesday, 6 January 2015

DHCP Server configuration in RHEL 7.0


Dynamic Host Configuration Protocol (DHCP) As the name suggests, DHCP is used to control the network configuration of a host through a remote server. DHCP is an excellent alternative to the time-consuming manual configuration of network settings on a host or a network device.
It automatically assigns IP addresses and other network configuration information to systems on a network.

The following Diagram showing the DHCP Operation.



Let us check how to configure DHCP server in Redhat Enterprise Linux 7.0.
First we need to setup a static IP address for the DHCP Server. Use nmcli or edit the configuration file. click here to know how to configure ip address using nmcli.
 ip add
We need to install the DHCP Package using YUM or RPM. For more information on YUM configuration please chick here.
Run # yum install dhcp -y to install dhcp package .
yum dhcp installation
Let us check what all configuration files created after the dhcp package installation. run
# rpm -qlc dhcp command.
dhcp configuration files
Installing the dhcp package creates a file, /etc/dhcp/dhcpd.conf, which is merely an empty configuration file. This is configuration file for IPv4 DHCP .
dhcpd.conf
Looking into this file we could see that there is sample configuration file available for reference.
If do a cat on /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example you would get a better idea to configure DHCP server. there are lot of sample configurations available.
dhcp example conf file
The first step in configuring a DHCP server is to create the configuration file that stores the network information for the clients. Use this file to declare options for client systems.

Here is my DHCP server configuration. my IP address range is 192.168.1.101 to 192.168.1.111. and additionally we are give some options like netmask, router, domain, DNS etc.
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.101 192.168.1.111;
  option domain-name-servers 192.168.1.200;
  option domain-search "vinzlinux.com";
  option subnet-mask 255.255.255.0;
  option routers 192.168.1.100;
  default-lease-time 600;
  max-lease-time 7200;
}

dhcp config

Thats all about DHCP Configuration. There are many options available in DHCP configuration could you refer the man pages and example file for more information. lets restart the DHCP service and enable service.
# systemctl restart dhcpd
# systemctl status  dhcpd

# systemctl enable dhcpd

start dhcp

enable service
Now we need to work on client side. Check any ip address is configured in the client.  run #ip add show command.

There  no IP address is configured for eno16777736 interface now.
run #dhclient eno16777736 or take a reboot or restart NetworkManager this will get the ip address from the DHCP server.

dhclient
You could see the following entries in the /var/log/messages in the DHCP server.
/var/log/messages dhcp request
Fore IP lease information you could see in /var/lib/dhcpd/dhcpd.leases file in DHCP server.
You could see something similar to this.
dhcp leases

That's all about DHCP server configuration ..! Hope you found this article useful.

No comments:

Post a Comment