在RHEL6.5上设置了两个网络,一个使用无线网卡连接上Wifi网络,另一个使用eth0网线,两个网络都正确分配了网络地址,可以正常连通。理想状况是,使用Wifi网络连接互连网,本地eth0网卡连接网线,连接本地路由,不上网。那么问题来了,现在电脑优先使用本地eth0网线,无法连接互联网,可以看到,ping 8.8.8.8没有走192.168.0.1连接互联网,转而走了192.168.26.2的本地eth0网络,症状如下:
[root@ipa ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.26.2 icmp_seq=1 Destination Net Unreachable
From 192.168.26.2 icmp_seq=2 Destination Net Unreachable
From 192.168.26.2 icmp_seq=3 Destination Net Unreachable
两个网络状态显示如下,
192.168.0.*
wlan0 网络是本地Wifi路由,连接了上互联网的路由器。
192.168.26.*
eth0 网络是本地eth0网线,连接了不上网的路由器,主要是访问本地网络。
[root@ipa ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:18:8B:AF:22:C2
inet addr:192.168.26.120 Bcast:192.168.26.255 Mask:255.255.255.0
inet6 addr: fe80::218:8bff:feaf:22c2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1074 errors:0 dropped:0 overruns:0 frame:0
TX packets:1338 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:101649 (99.2 KiB) TX bytes:222831 (217.6 KiB)
Interrupt:18
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:717 errors:0 dropped:0 overruns:0 frame:0
TX packets:717 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:58793 (57.4 KiB) TX bytes:58793 (57.4 KiB)
wlan0 Link encap:Ethernet HWaddr 00:18:F3:38:6E:79
inet addr:192.168.0.181 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::218:f3ff:fe38:6e79/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:904 errors:0 dropped:0 overruns:0 frame:0
TX packets:635 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:132360 (129.2 KiB) TX bytes:79696 (77.8 KiB)
[root@ipa ~]#
参考How can I give internet priority to wifi instead of ethernet?
设置Use this connection only for resources on its network,如下图所示,这样就设置了本地eth0网线只做本址资源路由,电脑在连接互联网就不走这个本地eth0网线路由了,转而从Wifi wlan0网络路由走,这样电脑就可以正常连接互联网了。
验证能够连接互联网,
[root@ipa ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=15.2 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=6.31 ms
^C
测试traceroute
指令。
[root@ipa ~]# traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
1 183.90.44.113 (183.90.44.113) 7.892 ms 12.932 ms an-ts-br05.starhub.net.sg (183.90.44.33) 12.929 ms
2 183.90.44.229 (183.90.44.229) 13.377 ms 18.804 ms 183.90.44.237 (183.90.44.237) 25.112 ms
3 203.117.36.57 (203.117.36.57) 15.705 ms 203.116.188.73 (203.116.188.73) 33.720 ms 203.117.36.53 (203.117.36.53) 39.933 ms
4 203.117.36.38 (203.117.36.38) 41.425 ms 203.117.36.42 (203.117.36.42) 43.251 ms 203.117.37.22 (203.117.37.22) 60.742 ms
5 72.14.196.189 (72.14.196.189) 75.949 ms 83.927 ms *
6 * 74.125.242.33 (74.125.242.33) 6.042 ms 108.170.240.161 (108.170.240.161) 10.754 ms
7 108.170.235.207 (108.170.235.207) 22.345 ms dns.google (8.8.8.8) 29.520 ms 72.14.234.177 (72.14.234.177) 41.606 ms
[root@ipa ~]#
Reference
How can I give internet priority to wifi instead of ethernet?