# 安装DHCP服务
【为其他服务器提供分配ip地址的功能,前提是其他服务器网卡必须设置成DHCP获取IP地址模式】
[root@pxe ~]# yum install dhcp.x86_64 -y
[root@pxe ~]# rpm -qc dhcp
/etc/dhcp/dhcpd.conf
[root@pxe -]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5)man page
# 生成配置文件
[root@pxe ~]# \cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@pxe ~]# vim /etc/dhcp/dhcpd.conf
1 # dhcpd.conf
2 #
3 # Sample configuration file for ISC dhcpd
4 #
5
6 # option definitions common to all supported networks...
7 option domain-name "timinhlee.org"; #公司域名
8 option domain-name-servers 114.114.114.114; # dhcp工作模式的网络主机获得的DNS的地址,也就是对外分发的dns地址
9
10 default-lease-time 600; # 默认租约期
11 max-lease-time 7200;
12
13 # Use this to enble / disable dynamic dns updates globally.
14 #ddns-update-style none;
15
16 # If this DHCP server is the official DHCP server for the local
17 # network, the authoritative directive should be uncommented.
18 #authoritative;
19
20 # Use this to send dhcp log messages to a different log file (you also
21 # have to hack syslog.conf to complete the redirection).
22 log-facility local7; #定义了local的日志格式
23
24 # No service will be given on this subnet, but declaring it helps the
25 # DHCP server to understand the network topology.
26
27 # subnet 10.152.187.0 netmask 255.255.255.0 {
28 # }
29
30 # This is a very basic subnet declaration.
31
32 subnet 网络位 netmask 255.255.255.0 {
33 range 地址池;
34 option routers 网关;
35 }
# 定位35行以后删除不要
[root@pxe ~]# systemctl enable --now dhcpd
### 创建一新台虚拟机,开机测试
检测成功!!!
[root@pxe html]# cat /var/lib/dhcpd/dhcpd.leases
# 查看测试主机的ip是否为dhcp分配