In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces how to install DHCP service on CentOS, RHEL and Fedora. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
DHCP (Dynamic Host Configuration Protocol) is a network protocol that enables the server to automatically assign IP addresses to client nodes in the network from a predefined IP pool and provide other relevant network configuration parameters.
This means that every time the client node starts (connects to the network), it gets a "dynamic" IP address as opposed to the "static" IP address that never changes. The IP address assigned by the DHCP server to the DHCP client is called a "lease", and the lease time varies depending on the connection time required by the client or the configuration of the DHCP.
In this guide, we will describe how to install and configure DHCP services in CentOS/RHEL and Fedora distributions.
Set up the test environment
We use the following test environment for this installation:
DHCP Server-CentOS 7
DHCP client-Fedora 25 and Ubuntu 16.04
How does DHCP work?
Before moving on to the next step, let's take a look at the workflow of DHCP:
When a client computer that is connected to the network (configured to use DHCP) starts, it sends an DHCPDISCOVER message to the DHCP server.
When the DHCP server receives an DHCPDISCOVER request message, it replies with an DHCPOFFER message.
After the client receives the DHCPOFFER message, it sends a DHCPREQUEST message to the server indicating that the client is ready to obtain the network configuration provided in the DHCPOFFER message.
*, the DHCP server receives the DHCPREQUEST message from the client and replies to the DHCPACK message, allowing the client to use the IP address assigned to it.
* step: install the DHCP service on CentOS
1. Installing the DHCP service is very simple, you only need to run the following command.
$yum-y install dhcp
Important: if there are multiple network cards in the system, but you want to enable DHCP services on only one of them, you can follow the steps below to enable DHCP services on that network card.
2. Open the file / etc/sysconfig/dhcpd, and add the name of the specified Nic to the DHCPDARGS list. If the Nic name is eth0, add:
DHCPDARGS=eth0
Save the file and exit.
Step 2: configure the DHCP service on CentOS
3. For beginners, the * * step to configure DHCP service is to create a dhcpd.conf configuration file. The main DHCP configuration file is usually / etc/dhcp/dhcpd.conf (the file is empty by default), which stores all the network information sent to the client.
However, there is a sample configuration file / usr/share/doc/dhcp*/dhcpd.conf.sample, which is a good start for configuring the DHCP service.
Two types of statements are defined in the DHCP configuration file:
Parameters-describes how to perform the task, whether or not to perform the task, or what network configuration options are sent to the DHCP client.
Declaration-specify the network topology, define the client, provide the client address, or apply a set of parameters to a set of declarations.
Therefore, first copy the sample configuration file as the master configuration file:
$cp/ usr/share/doc/dhcp-4.2.5/dhcpd.conf.example / etc/dhcp/dhcpd.conf
4. Then, open the main configuration file and define your DHCP service options:
$vi / etc/dhcp/dhcpd.conf
First, set the following global parameters that apply to all subnets at the beginning of the file (be sure to use the values in your actual scenario):
Option domain-name "tecmint.lan"; option domain-name-servers ns1.tecmint.lan, ns2.tecmint.lan; default-lease-time 3600; max-lease-time 7200; authoritative
5. Then, define a subnet; in this case, we will configure DHCP for the 192.168.56.0 ax 24 LAN (note that you use the values in your actual 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 "tecmint.lan"; 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 the DHCP client
You only need to define the following section in the / etc/dhcp/dhcpd.conf file, where you must explicitly specify its MAC address and the IP you intend to assign, and you can assign a static IP address to the client computers specified in the network:
Host ubuntu-node {hardware ethernet 00VOV F0 fixed-address 6yLV 89G; fixed-address 192.168.56.105;} host fedora-node {hardware ethernet 00V 4g fixed-address 8h 3a; fixed-address 192.168.56.110;}
Save the file and close it.
Note: you can find the MAC address of Linux using the following command.
$ifconfig-an eth0 | grep HWaddr
6. Now, use the following command to start the DHCP service and start it automatically the next time the system starts:
-On CentOS/RHEL 7-$systemctl start dhcpd $systemctl enable dhcpd-On CentOS/RHEL 6-$service dhcpd start $chkconfig dhcpd on
7. Also, don't forget to use the following command to allow the DHCP service to pass through the firewall (the DHCPD daemon listens on port 67 through UDP):
-On CentOS/RHEL 7-$firewall-cmd-- add-service=dhcp-- permanent $firewall-cmd-- reload-On CentOS/RHEL 6-$iptables-An INPUT-p tcp-m state-- state NEW-- dport 67-j ACCEPT $service iptables save
Step 4: configure the DHCP client
8. Now, you can configure clients in the network to automatically obtain IP addresses from the DHCP server. Log in to the client machine and modify the configuration file of the Ethernet interface as follows (note the name and number of the network card):
# vi / etc/sysconfig/network-scripts/ifcfg-eth0
Add the following options:
DEVICE=eth0 BOOTPROTO=dhcp TYPE=Ethernet ONBOOT=yes
Save the file and exit.
9. You can also set Method to Automatic (DHCP) through GUI in the desktop server according to the screenshot below (Ubuntu 16.04Desktop version).
Set up DHCP in the client network
10. Restart the network service according to the following command (you can also restart the system):
-On CentOS/RHEL 7-$systemctl restart network-On CentOS/RHEL 6-$service network restart
At this point, if all the settings are correct, your client should be able to automatically obtain the IP address from the DHCP server.
You can also read:
How to install and configure Multihomed ISC DHCP Services in Debian Linux
10 useful "IP" commands for configuring the network
So much for sharing about how to install DHCP services on CentOS, RHEL and Fedora. I hope the above can help you and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.