0% found this document useful (0 votes)
14 views

dhcp-server

Uploaded by

Gurudas Swain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

dhcp-server

Uploaded by

Gurudas Swain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Installing DCHP is quite straight forward, simply run the command below.

# yum -y install dhcp

Important: Assuming there is more than one network interface attached to the system, but you want the DHCP server to only be
started on one of the interfaces, set the DHCP server to start only on that interface as follows.
Step 2: Configuring DHCP Server in CentOS
For starters, to setup a DHCP server, the first step is to create the dhcpd.conf configuration file, and the main DHCP configuration
file is normally /etc/dhcp/dhcpd.conf (which is empty by default), it keeps all network information sent to clients.
However, there is a sample configuration file /usr/share/doc/dhcp*/dhcpd.conf.sample, which is a good starting point for
configuring a DHCP server.

# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

Now, open the main configuration file and define your DHCP server options:

# vi /etc/dhcp/dhcpd.conf

Start by setting the following global parameters which will apply to all the subnetworks (do specify values that apply to your
scenario) at the top of the file:

option domain-name "example.com";


option domain-name-servers server.example.com, ;
default-lease-time 3600;
max-lease-time 7200;
authoritative;

5. Now, define a subnetwork; in this example, we will configure DHCP for 192.168.56.0/24 LAN network (remember to use
parameters that apply to your scenario):

subnet 192.168.56.0 netmask 255.255.255.0 {


option routers 192.168.56.1;
option subnet-mask 255.255.255.0;
option domain-search "example.com";
option domain-name-servers 192.168.56.1;
range 192.168.56.10 192.168.56.100;
range 192.168.56.120 192.168.56.200;
}

Step 3: Assign Static IP to DHCP Client


You can assign a static IP address to a specific client computer on the network, simply define the section below
in /etc/dhcp/dhcpd.conf file, where you must explicitly specify it’s MAC addresses and the fixed IP to be assigned:

host rhel-node {
hardware ethernet 00:f0:m4:6y:89:0g;
fixed-address 192.168.56.105;
}

Save the file and close it.


Note: You can find out or display the Linux MAC address using following command.

# ifconfig -a eth0 | grep HWaddr

6. Now start the DHCP service for the mean time and enable it to start automatically from the next system boot, using following
commands:

---------- On CentOS/RHEL 7 ----------


# systemctl start dhcpd
# systemctl enable dhcpd

7. Next, do not forget to permit DHCP service (DHCPD daemon listens on port 67/UDP) as below:

---------- On CentOS/RHEL 7 ----------


# firewall-cmd --add-service=dhcp --permanent
# firewall-cmd --reload
Step 4: Configuring DHCP Clients
8. Now, you can configure your clients on the network to automatically receive IP addresses from the DHCP server. Login to the
client machine and modify the Ethernet interface configuration file as follows (take not of the interface name/number):

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Add the options below:

DEVICE=eth0
BOOTPROTO=dhcp
TYPE=Ethernet
ONBOOT=yes

Save the file and exit.

You might also like