In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to configure DHCP server in Centos8". In daily operation, I believe many people have doubts about how to configure DHCP server in Centos8. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to configure DHCP server in Centos8". Next, please follow the editor to study!
DHCP (dynamic Host configuration Protocol) is used to automatically assign IP addresses to PC and other network devices so that they can communicate. It uses port 67 of the UDP protocol and port 68 of UDP for the client. The DHCP operation is divided into four phases: server discovery, IP lease quotation, IP lease request, and IP lease confirmation. These phases are usually abbreviated to DORA and are used to discover, provide, request, and confirm.
System environment
Centos8
Install DHCP
The address of the DHCP server is 192.168.43.254 IP 24, and the default gateway is 192.168.43.2 Universe 24. The DHCP server will automatically assign DHCP addresses to other devices in the network 192.168.43.0DHCP 24.
The following is the address information of the DHCP server:
[root@localhost ~] # cat / etc/sysconfig/network-scripts/ifcfg-ens160
Install the DHCP service below:
[root@localhost ~] # dnf-y install dhcp-server
Configure the DHCP service
The main configuration file for the DHCP server is / etc/dhcp/dhcpd.conf. By default, there are only comments in the file, so you can refer to the / usr/share/doc/dhcp-server/dhcpd.conf.example file to modify the configuration.
The following provides the configuration information directly. Paste the configuration information into the dhcpd.conf file and modify the address and other information:
[root@localhost ~] # cat / etc/dhcp/dhcpd.conf # DHCP Server Configuration file.# see / usr/share/doc/dhcp-server/dhcpd.conf.example# see dhcpd.conf (5) man page#default-lease-time 600 poster LleaseMustTime 7200witddupdatelystyle none;authoritative;subnet 192.168.43.0 netmask 255.255.255.0 {range 192.168.43.101 192.168.43.200; option routers 192.168.43.2 Option subnet-mask 255.255.255.0; option domain-name-servers 192.168.43.2;}
Default-lease-time reserves 10 minutes (600s) of IP addresses for specific devices
Max-lease-time retains up to 2 hours (7200 seconds) of IP addresses.
The subnet section defines the DHCP configuration for the 192.168.43.0 Compact 24 network.
The range section defines the IP addresses that can be assigned, ranging from 192.168.43.101 to 192.168.43.200.
The routers section defines the address of the default gateway.
The subnet-mask section defines the subnet mask that will be assigned to each host.
The domain-name-servers section defines the DNS server address that will be assigned to each host.
After the configuration is complete, you can start the dhcp service using the following command:
[root@localhost] # systemctl enable dhcpd & & systemctl start dhcpdCreated symlink / etc/systemd/system/multi-user.target.wants/dhcpd.service → / usr/lib/systemd/system/dhcpd.service.
Let's see if the service is running:
[root@localhost ~] # systemctl status dhcpd
Configure the firewall
If you turn on the firewall, you need to release the dhcp service in the firewall.
[root@localhost] # firewall-cmd-- permanent-- add-service=dhcpsuccess [root@localhost] # firewall-cmd-- reloadsuccess
Client test
The address was obtained at the client:
Check on the client to see if it is the address assigned by the 192.168.43.254 DHCP server:
[root@localhost ~] # nmcli connection show ens33 | grep-I 'dhcp4.option\ [4\]' DHCP4.OPTION [4]: dhcp_server_identifier = 192.168.43.254
You can see that the dhcp server identifier is 192.168.43.254.
Set reserved IP
First of all, you need to know the network card address of the server that retains the ip address, and use ip link on the client side to check the mac address of the network card:
[root@localhost ~] # ip link
On the dhcp server, edit the / etc/dhcp/dhcpd.conf configuration file and add the following. The binding address is 192.168.43.150:
Host server {hardware ethernet 00v0cVV 299Rd; fixed-address 192.168.43.150;}
Restart the dhcp service:
[root@localhost dhcp] # systemctl restart dhcpd
Next, on the client side, restart the network service to see if you have obtained a fixed address.
You can see that the address has been obtained.
At this point, the study on "how to configure the DHCP server with Centos8" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.