我尝试在我的 Debian Stretch 机器(带 Pi Hole 的 RaspberryPi)上配置静态 IPv6,但我遇到了各种无法处理的问题。
我的 dhcpcd.conf 文件:
# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
#slaac private
# Example static IP configuration:
interface eth0
static ip_address=192.168.1.100/24
static ip6_address=2a01:aaaa:bbbb:cccc::100/64
static routers=192.168.1.1
static domain_name_servers=127.0.0.1 ::1
一些 IPv6 Sysctl 变量
net.ipv6.conf.eth0.accept_dad = 1
net.ipv6.conf.eth0.accept_ra = 0
net.ipv6.conf.eth0.accept_ra_defrtr = 1
net.ipv6.conf.eth0.accept_ra_mtu = 1
net.ipv6.conf.eth0.accept_ra_pinfo = 1
net.ipv6.conf.eth0.accept_ra_rtr_pref = 1
net.ipv6.conf.eth0.addr_gen_mode = 1
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.eth0.use_tempaddr = 2
最后是我的 resolv.conf (未安装 resolvconf)
# Generated by dhcpcd from eth0.dhcp, eth0.ra
# static resolv.conf file
search mydomain.home
nameserver 127.0.0.1
nameserver ::1
search home # search domain sent by ISP router
nameserver 127.0.0.1
nameserver ::1
nameserver 2a01:aaaa:bbbb:cccc:dddd:eeee:ffff:gggg # ISP router's IPv6
# /etc/resolv.conf.tail can replace this line
eth0 IPv6 地址:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
inet6 2a01:aaaa:bbbb:cccc:dddd:eeee:ffff:ccb0/64 scope global temporary dynamic
valid_lft 1763sec preferred_lft 563sec
inet6 2a01:aaaa:bbbb:cccc:dddd:eeee:ffff:f540/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 1763sec preferred_lft 563sec
inet6 2a01:aaaa:bbbb:cccc::100/64 scope global noprefixroute
valid_lft forever preferred_lft forever
inet6 fe80::aaaa:bbbb:cccc:f540/64 scope link
valid_lft forever preferred_lft forever
所以有一点我不明白:
- 我配置静态 IPv6 地址,阻止 autoconf,但我仍然获得 SLAAC IPv6 地址(使用 mngtmpaddr CONFFLAG)..为什么?
- 我阻止路由器广告(由我无法配置的 ISP 路由器发送),但 dhcpcd 仍在使用 RA 生成 resolv.conf(使用搜索域 home 和路由器 IPv6 作为 DNS)
- 看来 IPv6 默认路由是由 RA 学习的:对我来说似乎合法,但我不能 100% 确定这是否是正确的方法
非常感谢你的帮助