先在配置文件内禁用ipv6 dhcp服务:
/etc/config/dhcp
config dhcp 'lan'
option interface 'lan'
option start '150'
option limit '100'
option leasetime '12h'
option ra 'disabled'
option dhcpv6 'disabled'
config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'
option loglevel '4'
关闭odhcpd:
/etc/init.d/odhcpd stop
/etc/init.d/odhcpd disable
修改dnsmasq配置文件开启ra服务:
/etc/dnsmasq.conf
enable-ra
dhcp-range=::,constructor:br-lan,ra-only
#其它slaac ra-stateless等参考man文档
只想通过ipv4查询dns,下面patch让dnsmasq无状态分配ip时候不包含RDNSS,这样客户端只配置ipv4 dns而不配置ipv6 dns。
diff -urN dnsmasq-2.86/src/radv.c dnsmasq-2.86-bak/src/radv.c
--- dnsmasq-2.86/src/radv.c 2021-09-09 04:21:22.000000000 +0800
+++ dnsmasq-2.86-bak/src/radv.c 2022-01-23 11:57:01.818963642 +0800
@@ -507,7 +507,7 @@
}
}
- if (daemon->port == NAMESERVER_PORT && !done_dns && parm.link_pref_time != 0)
+ if ( 0 && daemon->port == NAMESERVER_PORT && !done_dns && parm.link_pref_time != 0)
{
/* default == us, as long as we are supplying DNS service. */
put_opt6_char(ICMP6_OPT_RDNSS);
odhcpd新版本参数dns_service也可实现此需求,不使用dhcpv6可尝试使用ra_dns参数关闭ra dns?
再次开启ipv6 dns服务,如果有配置dhcp6 dns服务器,dnsmasq会将其设置为RDNSS:
dhcp-option=option6:dns-server,[xxxx:xxxx:xxxx:xxxx::1]