我在 WiFi 网络上遇到了 Android 设备和 DNS 查找问题,因此我进行了一些挖掘并发现 android 正在 DNS1 插槽中分配看似随机的链路本地 ipv6 地址:
shell@htc_m8wl:/ $ getprop net.dns1
fe80::3246:9aff:fe00:3108
shell@htc_m8wl:/ $ getprop net.dns2
192.168.55.5
我认为这很奇怪,所以我决定从我的 dhcp 服务器执行 tcp 转储并得到以下结果:
# tcpdump -vv -n -i epair2b port bootps or port bootpc
18:18:13.285502 IP (tos 0x0, ttl 64, id 49166, offset 0, flags [none], proto UDP (17), length 342)
0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from 00:ee:bd:c1:7e:db, length 314, xid 0xdb33bc98, Flags [none] (0x0000)
Client-Ethernet-Address 00:ee:bd:c1:7e:db
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Request
Client-ID Option 61, length 7: ether 00:ee:bd:c1:7e:db
Requested-IP Option 50, length 4: 192.168.55.79
MSZ Option 57, length 2: 1500
Vendor-Class Option 60, length 12: "dhcpcd-5.5.6"
Hostname Option 12, length 24: "android-a440c6464dfcde43"
Parameter-Request Option 55, length 9:
Subnet-Mask, Static-Route, Default-Gateway, Domain-Name-Server
Domain-Name, BR, Lease-Time, RN
RB
18:18:13.285886 IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
192.168.55.5.67 > 192.168.55.79.68: [udp sum ok] BOOTP/DHCP, Reply, length 300, xid 0xdb33bc98, Flags [none] (0x0000)
Your-IP 192.168.55.79
Client-Ethernet-Address 00:ee:bd:c1:7e:db
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: ACK
Server-ID Option 54, length 4: 192.168.55.5
Lease-Time Option 51, length 4: 60000
Subnet-Mask Option 1, length 4: 255.255.255.0
Default-Gateway Option 3, length 4: 192.168.55.1
Domain-Name-Server Option 6, length 4: 192.168.55.5
Domain-Name Option 15, length 23: "local.my.domain"
如您所见,我根本没有向客户端宣传 ipv6 link-local,而 android 似乎是唯一受影响的设备。Linux 台式机、OSX 笔记本电脑、iPhone 似乎都运行良好。
通常情况下,我会假设当 ipv6 link-local 查找失败时,android 会转到 DNS2 记录,它会显示为我公布的 DNS 服务器。但是,情况似乎并非如此,因为连接到 WiFi 时,手机的所有 DNS 查询都会失败。
我想知道我是否需要在服务器配置中设置一个 DHCP 选项,以告诉 android 妥善处理这个问题而不是自我终止。经过多次谷歌搜索,我还是找不到遇到与我的网络相同问题的人,所以我假设此时是我的服务器配置出了问题。
# dhcpd.conf
option domain-name "local.my.domain";
option domain-name-servers 192.168.55.5;
include "/etc/namedb/dhcpupdate.key";
ddns-updates on;
ddns-update-style interim;
ignore client-updates;
update-static-leases on;
authoritative;
zone local.my.domain. {
primary 127.0.0.1;
key "dhcpupdate";
}
zone 55.168.192.in-addr.arpa. {
primary 192.168.55.5;
key "dhcpupdate";
}
subnet 192.168.55.0 netmask 255.255.255.0 {
range 192.168.55.100 192.168.55.240;
default-lease-time 60000;
max-lease-time 720000;
option routers 192.168.55.1;
ddns-domainname "local.my.domain.";
ddns-rev-domainname "55.168.192.in-addr.arpa.";
}
group {
option domain-name "local.my.domain";
ddns-domainname "local.my.domain.";
ddns-rev-domainname "55.168.192.in-addr.arpa.";
# Static hosts
host john-phone {
hardware ethernet 00:ee:bd:c1:7e:db;
fixed-address 192.168.55.79;
ddns-hostname "john-phone";
option host-name "john-phone";
}
}
我定义了更多静态主机,但它们实际上是相同的,唯一的区别是 IP 和以太网地址。
答案1
问题似乎是我的路由器使用 IPv6 自动配置选项广播了错误的 DNS 服务器。禁用路由器上的 IPv6 似乎已修复此问题,这很好,因为我的 ISP 尚不支持 IPv6。