DHCP Install and Configure

DHCP

Dhcp

DHCP stands for Dynamic Host Configuration Protocol. It handles the automatic assignment of IP addresses and other configuration settings for devices on your network.

Detail configuration steps (Centos 6.8):

  1. Ensure internet connected for this first time.
  2. Ensure selinux is disabled
  3. Ensure good entries in iptables (FIREWALL) or simply disable firewall
#service iptables stop        => firewall is disabled for now.

#chkconfig iptables off       => iptables will be off on every startup
  1. Update yum repositories and packages by typing the below command
[root@localhost ~]# yum update
  1. Install dhcp server and client using the below command
[root@localhost ~]# yum install dhcp
  1. Assign a static ip (eg: “192.168.1.11”) in the same DHCP range for the listening interface ( eg : “eth0” ). Open /etc/sysconfig/network-scripts/ifcfg-eth0file and make the changes as per your requirement.
DEVICE="eth0"
HWADDR="00:0C:29:F1:01:4B"
NM_CONTROLLED="yes"
ONBOOT="yes"
BOOTPROTO="none"
IPADDR=192.168.1.11
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
  1. Now open /etc/sysconfig/dhcpdfile and add the preferred interface name to DHCPDARGS variable as below
# Command line options here
DHCPDARGS=eth0
  1. open /etc/dhcp/dhcpd.conffile and paste the below lines and save it.
#specify domain name
option domain-name "samajik.edu.np";

#specify DNS server ip and additional DNS server ip
option domain-name-servers 192.168.1.10, 208.67.222.222;

#specify default lease time
default-lease-time 600;

#specify Max lease time
max-lease-time 7200;

#specify log method
log-facility local7;

#Configuring subnet and iprange
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.50 192.168.1.254;
option broadcast-address 192.168.1.255;

#Default gateway ip
option routers 192.168.1.1;
}
#Fixed ip address based on MAC id
host Printer01 {
hardware ethernet 02:34:37:24:c0:a5;
fixed-address 192.168.1.55;
}
  1. Check configuration
#dhcpd –cf /etc/dhcp/dhcpd.conf

Above command shows error if configuration file contains any error with line number. If the file is of dhcpd service is just started.

  1. Start dhcpd service
#service dhcpd start          => simply starts dhcpd service

#chkconfig dhcpd on           => starts dhcpd service on every boot

dhcp server should now work

Now we can check dhcp working in live as:

Check log file continuously for latest updates:

By default dhcp server puts its log to messages file in /var/log/messages so,

#tail –f /var/log/messages

We can see updated entries as:

output

Thank you.

For more reading materials please click here

Advertisements
DHCP Install and Configure

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s