DHCP service construction under Centos 7
DHCP service construction under Centos 7
-
DHCP will not be introduced in detail. The function of DHCP can be configured with a router or switch (if supported), or it can be realized by building a server (Linux and windows). Now let’s talk about the configuration of DHCP service in CentOS 7 version. step
Several parameters that the DHCP service needs to provide
1), IP address and subnet mask;
2), the default gateway;
3), the lease time (if the time expires, the contract needs to be renewed, if the client does not renew the contract, the server will recycle the allocated IP address);
-
I will briefly talk about the three elements of service installation configuration startup mount and network card configuration
1. Mounting and network card configuration
1.1 mount
[root@localhost ~]# mkdir /media/cdrom
[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo 1
[root@localhost ~]# vi /etc/yum.repos.d/CentOS-Media.repo
[root@localhost ~]# mount /dev/cdrom /media/cdrom/
1.2 Network card configuration
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
ONBOOT=yes
IPADDR=192.168.10.10
NETMASK=255.255.255.0
GATEWAY=192.168.10.2
DNS1=192.168.10.10
restart network card
[root@localhost ~]# systemctl restart network
2. Install DHCP service
2.1 Install DHCP service
yum install -y dhcp
Copy the file to the DHCP master file
cp -p /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp:是否覆盖"/etc/dhcp/dhcpd.conf"? yes
3. Configure the DHCP master file
3.1 Configuring the DHCP master file
-
cd /etc/dhcp/dhcpd.conf
-
Enter the configuration file and use shift+: Then enter set nu to view the line number and find line 47
-
before fixing
-
after modification
45
46 # A slightly different configuration for an internal subnet.
47 subnet 192.168.10.0 netmask 255.255.255.0 {
48 range 192.168.10.1 192.168.10.30;
49 option domain-name-servers 192.168.10.10;
50 option domain-name "dhcp";
51 option routers 192.168.10.2;
52 option broadcast-address 10.5.5.31;
53 default-lease-time 600;
54 max-lease-time 7200;
55 }
4. Restart the DHCP service
4.1 Restart the DHCP service
[root@localhost ~]# systemctl restart dhcpd
5. Add a network adapter
5.1 Adding a network adapter
6. Result test
6.1 Result test
-
Use ip a to view the IP address of the network card
-
systemctl status dhcpd Check the status of the dhcp server.
If active is displayed, it means that the DHCP service is successfully enabled and the setup is complete.