16.04 - 插入以太网和 WiFi 时指标出现问题

16.04 - 插入以太网和 WiFi 时指标出现问题

将我们的许多笔记本电脑升级到 16.04 后,我们注意到网络发生了变化,并且与具有 0 指标的以太网相比,WiFi 适配器自动获得了更高的指标 600。

我们遇到的问题是,我们将以太网连接到没有互联网的封闭网络,将 WiFi 连接到具有互联网连接的网络,这必须解决许多位置问题,并且我们必须为以太网使用固定 IP。

我们得到的是,网络将始终尝试使用以太网来获取互联网连接,而不是 WiFi,即使拔掉以太网,它仍然会尝试通过以太网进行路由。

在 14.04 中这从来不是一个问题,目前我们必须关闭适配器才能使互联网正常工作。

以前有其他人见过这种情况吗?改变这种情况的最佳解决方案是什么?

可以更改指标,但如果笔记本电脑连接到不同的 WiFi 源,那么我们必须再次更改它?有没有更好的解决方案可以将网络改回 14.04 中的状态?

谢谢

  ping 8.8.8.8

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.0.205 icmp_seq=1 Destination Host Unreachable
From 192.168.0.205 icmp_seq=2 Destination Host Unreachable
From 192.168.0.205 icmp_seq=3 Destination Host Unreachable
From 192.168.0.205 icmp_seq=4 Destination Host Unreachable
From 192.168.0.205 icmp_seq=5 Destination Host Unreachable
From 192.168.0.205 icmp_seq=6 Destination Host Unreachable
From 192.168.0.205 icmp_seq=7 Destination Host Unreachable
From 192.168.0.205 icmp_seq=8 Destination Host Unreachable
^C
--- 8.8.8.8 ping statistics ---
8 packets transmitted, 0 received, +8 errors, 100% packet loss, time 7038ms
pipe 3


ifconfig

enp0s31f6 Link encap:Ethernet  HWaddr 98:e7:f4:f1:c3:9e  
          inet addr:192.168.0.205  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:16 Memory:e1200000-e1220000 

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:65536  Metric:1
          RX packets:718 errors:0 dropped:0 overruns:0 frame:0
          TX packets:718 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:62836 (62.8 KB)  TX bytes:62836 (62.8 KB)

wlp2s0    Link encap:Ethernet  HWaddr e4:a7:a0:a6:f7:34  
          inet addr:10.154.58.100  Bcast:10.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::50c5:514:7923:172c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:103 errors:0 dropped:0 overruns:0 frame:0
          TX packets:159 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:20862 (20.8 KB)  TX bytes:20668 (20.6 KB)



route -n 

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 enp0s31f6
0.0.0.0         10.128.128.128  0.0.0.0         UG    600    0        0 wlp2s0
10.0.0.0        0.0.0.0         255.0.0.0       U     600    0        0 wlp2s0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlp2s0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 enp0s31f





more /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto enp0s31f6
iface enp0s31f6 inet static
address 192.168.0.205
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8

答案1

解决方案是更改以太网连接的度量。将接口设置更改为类似

/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto enp0s31f6
iface enp0s31f6 inet static
address 192.168.0.205
netmask 255.255.255.0
dns-nameservers 8.8.8.8
up route add default gw 192.168.0.1 metric 1000
down route del default gw 192.168.0.1

这会将度量添加到 ,ethernet1000大于wifi。已wifi 连接,流量将被路由到wifi。如果wifi未连接,流量将被路由到eth。如果wifi已连接 并且eth也已连接,流量将被路由到 ,wifi因为度量是600wifi1000此外eth,如果eth断开连接,命令down route del default gw 192.168.0.1将删除到 的默认路由eth

相关内容