最近折腾 Moto Edge 60 Pro (XT2507-5 ,国行) 时,发现连接任意 WiFi 系统都会强制追加 114 DNS (不管 DHCP 下发了一个还是两个 DNS ,亦或使用静态 IP 手填 DNS 都免不了),这直接破坏了我在 OpenWrt 上的 ADG 和 Mosdns 策略。
经过一番排查和实验,总结出这些应对方法。
iptables -t nat -A prerouting_lan_rule -m mac --mac-source <手机 MAC> -p udp -d 114.114.114.114 --dport 53 -j DNAT --to-destination 192.168.X.1
iptables -t nat -A prerouting_lan_rule -m mac --mac-source <手机 MAC> -p tcp -d 114.114.114.114 --dport 53 -j DNAT --to-destination 192.168.X.1
(最无感
(不喜欢 VPN 通道被占用
一开始以为是 overlay 配置,结果 cmd overlay 验证并不涉及 DNS 。 抓 dumpsys connectivity ,确认是 ClientModeImpl 里往 LinkProperties 里强加的。 最终在 /apex/com.android.wifi/javalib/service-wifi.jar 找到关键方法:addBackupDnsServerIfNeeded()。
(治标
iptables -I OUTPUT -d 114.114.114.114 -p udp --dport 53 -j REJECT
iptables -I OUTPUT -d 114.114.114.114 -p tcp --dport 53 -j REJECT
(治本
罪魁祸首↓
private void addBackupDnsServerIfNeeded() {
Iterator<InetAddress> it = this.mLinkProperties.getDnsServers().iterator();
int i = 0;
while (it.hasNext()) {
if (it.next() instanceof Inet4Address) {
i++;
}
}
if (i == 1) {
try {
this.mLinkProperties.addDnsServer(InetAddress.getByName("114.114.114.114"));
} catch (UnknownHostException unused) {
if (this.mVerboseLoggingEnabled) {
log("Adding 114 DNS Server Fails");
}
}
}
}
AOSP 已经有 Fallback 机制了,在无任何可用 DNS 时才会追加 8.8.8.8 。 小米、一加、Moto 搞这种骚操作,看似提升了小白的网络体验,实际上剥夺了用户选择权,都是傻*
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.