Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure DHCP server in Centos8

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today Xiaobian to share with you how to configure DHCP server related knowledge points in Centos8, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for everyone to refer to, I hope you have some harvest after reading this article, let's learn about it together.

DHCP is usually used in large-scale local area network environments, mainly for centralized management and allocation of IP addresses, so that hosts in the network environment can dynamically obtain IP addresses, Gateway addresses, DNS server addresses and other information, and can improve the utilization rate of addresses.

system environment

Centos8

install DHCP

DHCP server address: 192.168.43.254/24, default gateway: 192.168.43.2/24,DHCP server will automatically assign IP address to other devices in the network 192.168.43.0/24.

Here is the DHCP server address information:

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens160

Install DHCP service below:

[root@localhost ~]# dnf -y install dhcp-server Configure DHCP service

The main configuration file for DHCP servers is/etc/dhcp/dhcpd.conf. By default, there are only comments in the file, suggesting that you can refer to the/usr/share/doc/dhcp-server/dhcpd.conf.example file to modify the configuration.

The configuration information is provided directly below. 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;max-lease-time 7200;ddns-update-style 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 Reserve IP addresses for a specific device for 10 minutes (600 seconds)

max-lease-time IP addresses are retained for up to 2 hours (7200 seconds).

The subnet section defines the DHCP configuration for the 192.168.43.0/24 network.

The range section defines assignable IP addresses in the range 192.168.43.101-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 configuration is complete, you can start dhcp service with 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.

Check to see if the service is running:

[root@localhost ~]# systemctl status dhcpd Configure Firewall

If the firewall is enabled, dhcp services need to be enabled in the firewall.

[root@localhost ~]# firewall-cmd --permanent --add-service=dhcpsuccess[root@localhost ~]# firewall-cmd --reloadsuccess Client Testing

Get the address on the client side:

On the client side, check whether it is 192.168.43.254. The DHCP server assigns the address:

[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, you need to know the network card address of the server that needs to reserve the ip address. Use ip link to view the mac address of the network card on the client side:

[root@localhost ~]# ip link

Next, on the dhcp server, edit the/etc/dhcp/dhcpd.conf configuration file and add the following content. The binding address is 192.168.43.150:

host server { hardware ethernet 00:0c:29:99:ee:d9; fixed-address 192.168.43.150;}

Restart dhcp service:

[root@localhost dhcp]# systemctl restart dhcpd

Next, restart the network service on the client side to see if the fixed address has been obtained.

You can see that we've got the address.

The above is "Centos8 how to configure DHCP server" all the content of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report