用adb shell连接模拟器,
通过setprop net.dns1 ipaddress 设置dns
|generic_x86:/ $ setprop net.eth0.dns1 192.168.1.1
1:在命令提示符里输入>adb shell (进入模拟器的linux系统,前提是你的环境变量已经设置好了);
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE>adb shell
generic_x86:/ $ getprop |grep net
[gsm.network.type]: [LTE]
[init.svc.netd]: [running]
[init.svc.ranchu-net]: [stopped]
[net.bt.name]: [Android]
[net.eth0.dns1]: [10.0.2.3]
--------------------------------------------------------------------------
generic_x86:/ $ setprop net.dns1 192.168.1.1
setprop: failed to set property 'net.dns1' to '192.168.1.1'
修改dns失败?
怎么解决?
setprop: failed to set property 'net.eth0.dns1' to '192.168.1.1'
1|generic_x86:/ $ setprop net.eth0.dns1 192.168.1.1
修改dns失败?
怎么解决?