Friday, April 20, 2018

Create and configure DHCP in Linux

DHCP works on D.O.R.A(Discover, Offer, Request, Acknowledge) process.

F.Q.D.N = Hostname + Domain Name

=> 67 port number for Server
    68 port number for Client

=> Set the hostname
  - # hostname <hostname> (But this is temporary)

=> Set Hostname permanent
  - # vim /etc/sysconfig/network
       Networking=Yes
       hostname <hostname>

=> By default the DHCP lease duration for wired Network is 6Days & for Wireless it is 7Hours.
=> To assign IP address 
  - # setup OR # netconfig
  - # service network restart  (to make the changes)
  - # ifconfig (to check the IP address)

=> Installation Packages.
  - dhcp*

=> Configuration File.
  - /etc/dhcpd.conf

=> Daemon/Service
  - dhcpd

=> Sample file of DHCP to copy it to the main configuration file.
  - /usr/share/doc-dhcp-<version>/dhcp.conf.sample

=> DHCP lease database file.
  - /var/lib/dhcpd/dhcpd.lease

Installation of DHCP Sever

# rpm -qa | grep dhcp (To check if it is already installed or not)
# yum install dhcp*
# cp /usr/share/doc-dhcp-<version>/dhcp.conf.sample /etc/dhcpd.conf
# gedit /etc/dhcpd.conf
Option routers 192.168.0.254   -/ Gateway
(Put # at NIS-Domain)
Domain name-server 192.168.0.254
range dynamic bootp 192.168.0.100 192.168.0.150
lease time 2
(save the file)
# service dhcpd restart
# service dhcpd status
# chkconfig dhcpd on
# chkconfig --list dhcpd
# netstat -ntpul | grep :67 (To show port status)

Now verify it from the client side.

No comments:

Post a Comment