1、配置yum源、掛載光盤、安裝dhcp包
[root@localhost ~]# vim /etc/yum.repos.d/base.repo
[base]
name=base
baseurl=file:///mnt
gpgcheck=0
enable=1
[root@localhost ~]# mount /dev/sr0 /mnt/
[root@localhost ~]# yum install dhcp -y
2、關閉防火牆、selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
3、配置dhcp主配置文件
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 172.16.1.0 netmask 255.255.255.0 { #網段
option routers 172.16.1.10; #router
option subnet-mask 255.255.255.0; #掩碼
option domain-name-servers 114.114.114.114; #DNS服務器
range dynamic-bootp 172.16.1.100 172.16.1.200; #下方地址的範圍
default-lease-time 60; #默認
max-lease-time 60;
}
重啓服務
[root@localhost ~]# systemctl restart dhcpd.service
將另一臺虛擬機與此臺虛擬機調節到一張網卡,另一臺虛擬機會獲取到172.16.1.100到200之間的地址、掩碼、網關、dns域名服務器等信息。