Configure DHCP server
I. Installation
Yum install dhcpd-y
Ii. Configuration
[Root @ server03/] # rpm-qc dhcp
The dhcp configuration file is displayed.
[Root @ server03/] # vim/etc/dhcp/dhcpd. conf
Change configuration file
Option domain-name "example.com"; # specifies the domain name, indicating the domain of the DHCP server;
Default-lease-time 600;
Max-lease-time 7200; # lease period, 600 7200 is the default time, if not written, the effect is the same
Log-facility local7; # log
Subnet 192.168.4.0 netmask 255.255.255.0 {# specify the network segment
Range 192.168.4.130 192.168.4.132; # address range
}
Save and exit
Restart the hdcp service and set another virtual machine as a bridge to restart the network. You can obtain the IP address 192.168.4.131 allocated by dhcp.
On the dhcp server,
Run tail-f/var/log/messages to view dynamic log files and dhcp request messages.
Open the configuration file:
[Root @ server03/] # vim/etc/dhcp/dhcpd. conf
Add
Option routers 192.168.4.254; # Gateway
Option domain-name-servers 192.168.4.103; # dns Server
Restart the dhcpd client and restart the network to obtain the address of the gateway and dns server.
[Root @ localhost Desktop] # vim/etc/resolv. conf
You can see:
# Generated by NetworkManager
Domain example.com
Search example.com
Nameserver 192.168.4.103
Address binding:
Open the configuration file:
[Root @ server03/] # vim/etc/dhcp/dhcpd. conf
Add:
Host fantasia {
Hardware ethernet 00: 0C: 29: 60: 31: B7
Fixed-address 192.168.4.133 # The address should be out of the address pool above to prevent conflict
}
Restart the DHCP Client and restart the network. Check the ip address. The ip address is changed to the binding address just set.
OK!