dnsmasq版本: dnsmasq 从2.6*版本开始支持DHCPv6功能
参考:https://blog.csdn.net/qq_35550345/article/details/86628962
dhcpv6原理:https://blog.csdn.net/qq_38265137/article/details/80466734
ifcfg配置参数介绍:https://blog.csdn.net/chinaltx/article/details/86497165
/etc/sysconfig/network
NETWORKING_IPV6=yes设置dnsmasq.conf read-ethers log-dhcp log-queries log-facility=/var/log/dnsmasq.log addn-hosts = /var/lib/cobbler/cobbler_hosts domain=local dhcp-lease-max=1800 server=/local/ resolv-file=/etc/dnsmasq.upstream interface=eth0 cache-size=1024 # This is one of the key options. dnsmasq tries to move out servername # and PXE filename from special fields into DHCP options. # Some old clients can't understand those DHCP options, so they # will not be able to boot via PXE without this option enabled. # For example gPXE will not work while iPXE works fine. dhcp-no-override # for many simultaneously DHCPDISCOVVER requests dnsmasq can offer # the same IP for two differnt MAC addresses. This option prevents it # by assigning IPs one by one instead of using hash algorithm. dhcp-sequential-ip #ipv4 dhcp-option=6,10.10.1.2 dhcp-range=internal,10.10.1.128,10.10.1.254,255.255.255.0,120m dhcp-option=net:internal,option:router,10.10.1.2 dhcp-boot=net:internal,pxelinux.0,boothost,10.10.1.2 #ipv6 dhcp-range=fd00::22, fd00::44, 64, 1h enable-ra #domain-needed #resolv-file=/etc/resolv.dnsmasq.conf
检查语法并启动dnsmasq:dnsmasq -test
杀掉测试进程后启动dnsmasq & dhcp租用信息:/var/lib/dnsmasq/dnsmasq.leases
客户端配置 网卡配置 客户机上的接口为eth0,网卡配置文件/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 ONBOOT=yes #禁止NetworkManager管理网卡 NM_CONTROLLED=no HWADDR= #USERCTL=no PEERDNS=yes BOOTPROTO=dhcp #只能小写 #BOOTPROTO=dhcp6 打开这个只会获取ipv6的地址 DHCPV6C=yes IPV6INIT=yes网络配置文件/etc/sysconfig/network NETWORKING_IPV6=yes IPV6_AUTOCONF=yes #yes表示自动获取地址
测试: dhclient -6 -v eth0
使用dnsmasq 有状态DHCPv6下发特定租约
上面的方式是dnsmasq按照特定算法给客户端分配ipv4和ipv6地址,如果想给每个客户端分配指定地址,需要增加以下配置。
dnsmasq服务器(dnsmasq.conf ) 配置和上面一样,添加以下语句 dhcp-host=id:00:03:01:00:08:00:27:5c:b9:f0, [fd00::22]修改配置需要重启dnsmasq服务
客户端根据官方描述,dhclient版本为4.1+支持ipv6。为了支持DUID-LL要在/etc/dhcp/dhclient.conf中写入:
ZQ send dhcp6.client-id = concat(00:03:00, hardware); /etc/sysconfig/network-scripts/ifcfg-eth0跟上面一样 配置/etc/sysconfig/network
NETWORKING_IPV6=yes IPV6_AUTOCONF=no客户端租约文件/var/lib/dhclient/dhclient6.leases
centos7使用NetworkManager启动dhclient (NM_CONTROLLED=yes )
相关文件在/var/lib/NetworkManager/
查看dhcliemt进程
ps aux | grep dhclient
/sbin/dhclient -d -q -6 -N -sf /usr/libexec/nm-dhcp-helper -pf /var/run/dhclient6-eth0.pid -lf /var/lib/NetworkManager/dhclient6-5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03-eth0.lease -cf /var/lib/NetworkManager/dhclient6-eth0.conf eth0
红色部分为租约信息和配置文件路径。