两个局域网运行时如何正确配置DNS?

时间:2018-12-24 07:04:56

标签: android dns routes

设备无法ping通www.google.com,但可以ping 8.8.8.8。 我的操作系统是Android 6.0.1,内核是4.1.15

我已经尝试过resolv.conf和/ etc / hosts。但是这些方法似乎无法在Android上使用。

我不知道确切的问题是什么。

eth0      Link encap:Ethernet  HWaddr EE:DE:17:79:BB:42
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::ecde:17ff:fe79:bb42/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:600 TX bytes:1166

eth1      Link encap:Ethernet  HWaddr 00:0E:C6:81:79:01
          inet addr:192.168.120.57  Bcast:192.168.121.255  Mask:255.255.254.0
          inet6 addr: fe80::20e:c6ff:fe81:7901/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:41709 errors:0 dropped:0 overruns:0 frame:0
          TX packets:113 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2738793 TX bytes:8354

我关闭了netd服务,以便能够分别配置eth0和eth1。

这是我的IP规则

0:      from all lookup local
9998:   from all to 192.168.120.0/23 lookup 4
9999:   from all to 192.168.1.0/24 lookup 3
10000:  from all fwmark 0xc0000/0xd0000 lookup legacy_system
13000:  from all fwmark 0x10063/0x1ffff lookup local_network
15000:  from all fwmark 0x0/0x10000 lookup legacy_system
16000:  from all fwmark 0x0/0x10000 lookup legacy_network
17000:  from all fwmark 0x0/0x10000 lookup local_network
23000:  from all fwmark 0x0/0xffff uidrange 0-0 lookup main
32000:  from all unreachable

这是ping IP的结果,您可以看到响应很好。

root# ping 192.168.120.1
PING 192.168.120.1 (192.168.120.1) 56(84) bytes of data.
64 bytes from 192.168.120.1: icmp_seq=1 ttl=64 time=1.08 ms
64 bytes from 192.168.120.1: icmp_seq=2 ttl=64 time=0.986 ms
64 bytes from 192.168.120.1: icmp_seq=3 ttl=64 time=1.00 ms

root#ping 192.168.1.1

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=255 time=0.718 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=255 time=0.420 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=255 time=0.403 ms

但是ping google总是返回未知数。

ping: unknown host www.google.com

我希望我可以查验IP和URL。

顺便说一句,来自eth0 192.168.1.245的DNS和来自eth1的DNS是8.8.8.8

0 个答案:

没有答案