1.首先在centos上挂载centos镜像创建本地镜像源
步骤:
将iso镜像挂载到目录/mnt下;以下是在虚拟机上挂载iso镜像然后,将镜像mount到/mnt目录下
mount /dev/cdrom /mnt
然后
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
vi cdrom.repo
输入如下信息:
[CDROM]
name=isofile
baseurl=file:///mnt
enabled=1
gpgcheck=0
gpgkey=file:///mnt/RPM-GPG-KEY-redhat-release
2.安装dhcp
yum install dhcp
3.编辑dhcp配置文件
vi /etc/dhcp/dhcpd.conf
default-lease-time 2592000;
preferred-lifetime 604800;
option dhcp-renewal-time 3600;
option dhcp-rebinding-time 7200;
allow leasequery;
option dhcp6.info-refresh-time 21600;
dhcpv6-lease-file-name "/var/lib/dhcpd/dhcpd6.leases";
##设置一个与DHCP应答网关同网段地址池,不设置无法启动DHCP服务器
###注意以下网段为虚拟机应答网卡的IP地址所在网段
本次用于实验的虚拟机的网卡的IP信息如下:
subnet 123.168.3.0 netmask 255.255.255.0 {
}
subnet6 123::/64 {
}
##设置地址池,当然也可设置匹配条件用于过滤
subnet 192.168.4.0 netmask 255.255.255.0 {
pool{
allow members of "net004";
default-lease-time 600;
max-lease-time 7200;
range 192.168.4.2 192.168.4.254;
option routers 192.168.4.1;
option broadcast-address 192.168.4.255;
option subnet-mask 255.255.255.0;
option domain-name-servers 8.8.8.8;
}
}
subnet6 2018:4:10:ffff::/64 {
range6 2018:4:10:ffff::10 2018:4:10:ffff::1000;
}
4.启动DHCP服务
##启动DHCPv6 Server
dhcpd -6
##启动DHCPv4 Server
dhcpd -4
5.说明
没有尝试过dhcpv4和v6双栈的server,不保证双栈一定可行,但是单栈v4或者v6都是实验可行的。