Step 1. Set host name and set IP Address
Keeping it simple I just used dhcp.rhg.local here. It will be likely your system will run DHCP with other services so name accordingly. To check your current hostname use the cat command on /etc/hostname
cat /etc/hostname
Use the vi command to change /etc/hostname
vi /etc/hostname
After the change is made you need to restart the network service to see the name change
systemctl restart network
cat /etc/hostname
I set the ip address at installation time but if you did not and are still on DHCP use nmtui to change it. nmtui stands for Network Manager Text User Interface. It’s a nice easy way to update ip configurations from the command line
Remember to restart the network service after making a change
systemctl restart network
Step 2. Install DHCP Service
Here we are going to get the service installed with the yum command
yum install dhcp
After DHCP is installed, one of the next steps would be to configure it. If you did not know where the configuration files are located then you could query the RPM file it was installed from. In this example we are using RPM -qc where -qc stands for query config. This will return the files in the RPM marked as configuration. There is also rpm -qd to see documentation included with the RPM.
Step 3. Configure DHCP
So now that DHCP is installed we have to configure the range of addresses we want it to hand out. As shown in the previous step, the configuration file we want to edit is /etc/dhcp/dhcpd.conf
vi /etc/dhcp/dhcpd.conf
The above image shows an example of an ip range going form 192.168.1.50 thru 192.168.1.250. I have the same config below if you want to copy and paste and just change the parameters.
option domain-name "rhg.local";
option domain-name-servers 192.168.1.1;
default-lease-time 600;
max-lease-time 7200;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.1.50 192.168.1.250;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
}
Step 4. Start DHCP and configure to start at boot
Now we have DHCP configured but the service is not running. Along with starting the service we want DHCP to auto start on each boot. We will use the systemctl command to accomplish both of these. The D at the end on dhcpd is the daemon that runs the service so don’t forget the d at the end of dhcpd.
systemctl start dhcpd
systemctl enable dhcpd
Step 5. Open Firewall to DHCP requests
DHCP is running now but the firewall has to be opened to allow incoming DHCP requests. The Firewalld service is the default firewall for RHEL 7 so we will configure that to allow DHCP.
firewall-cmd --permanent --add-service=dhcp
firewall-cmd --reload
If you wanted the DHCP service to only be available to a certain network, you could do so with the below command. Please note that you would not want the firewall-cmd –permanent –add-service=dhcp command used with this because it is an allow all rule.
firewall-cmd --permanent –add-rich-rule=’rule family=”ipv4″ source address=”192.168.1.0/24″ service name=”dhcp” accept’
firewall-cmd --reload
Step 6. Verify its working
So now the test just to verify it works. I am using a Windows notebook right now so I disabled the adapter and checked it settings.
Post a Comment