Dan*_*son 13 linux wireless-networking ethernet networkmanager fedora-17
一个类似的问题被问到 windows自动更喜欢以太网而不是 WLAN,但我在 linux 上并且正在使用 NetworkManager。
现在,如果以太网电缆已插入并且可用,同时 wifi 连接也可用 NetworkManager 选择 wifi 连接。如果可用,我如何告诉它始终选择有线连接?
我在 Fedora 17 上使用 NetworkManager-0.9.4.0-9.git20120521
注意:@Proxy user\xe2\x80\x99s 的答案作为我答案的基础。
\n您可以使用nmcli
(命令行界面NetworkManager
)来完成此操作,无需安装ifmetric
。
您需要做的就是将ipv4.route-metric
每个所需网络的选项设置为某个正整数(默认为-1
);数字越小,优先级越高。之后,您需要重新连接到所有已更改/所需的网络(简单up
就足够了,无需down
先打开它们)。
# List of connections\n# You need to get the connection name (first column)\nnmcli con\n\n# Set the `ipv4.route-metric` of each required network\n# Change the `$con_name_x` and integer as required\nnmcli con mod $con_name_1 ipv4.route-metric 20 # This connection is more prefered\nnmcli con mod $con_name_2 ipv4.route-metric 40 # This connection is less prefered\n\n# Disconnect and reconnect the networks to make the changes effective\nnmcli con down $con_name_1\nnmcli con down $con_name_2\nnmcli con up $con_name_1\nnmcli con up $con_name_2\n
Run Code Online (Sandbox Code Playgroud)\n您还可ipv6.route-metric
以为每个网络进行设置。
小智 7
只是一些事情:
您可以在您的环境中尝试这些命令,看看它们是否有效并带来预期的结果:
或者,您可以查看通过发出以下命令找到的 IP 路由:
sudo route -n
Run Code Online (Sandbox Code Playgroud)
通过查看输出,看看 wlan0 是否在所有路由上。
已经提出了其他几个问题,让 Linux 支持接口(默认情况下它是 eth0,但在您的情况下,出现问题)的唯一方法是操纵指标。
您可以使用ifmetric为接口配置指标,该指标操作您指定的接口上的指标。我还没有在 Fedora 本身上测试过这个,但我可以看到它在存储库中。所以,发出:
yum install ifmetric
Run Code Online (Sandbox Code Playgroud)
然后当它安装时,你会想要去:
/etc/network/interfaces
Run Code Online (Sandbox Code Playgroud)
使用 vi、nano、emacs 以及您使用的任何编辑器,然后在您要配置的任何界面下添加(在本例中为 eth0):
up ifmetric eth0 X
Run Code Online (Sandbox Code Playgroud)
X 与确定优先级的数字有关,默认情况下 0 是最高优先级,但为了避免访问静态/默认路由,请使用大于 2 的值。然后您需要向 wlan0 添加更高的数字。所以:
up ifmetric eth0 10
Run Code Online (Sandbox Code Playgroud)
在 wlan0 下:
up ifmetric wlan0 20
Run Code Online (Sandbox Code Playgroud)
您的文件应如下所示:
iface eth0 inet dhcp
up ifmetric eth0 10
iface wlan0 inet dhcp
up ifmetric wlan0 20
Run Code Online (Sandbox Code Playgroud)
如果有帮助,请告诉我们!
编辑:只是遇到几个链接:
编辑2:
网络管理器 GUI 中还有一个度量字段!
小智 4
networkmanager-connection-editor
NetworkManager 有一个名为或 的GUI 前端nm-connection-editor
,可以在其中为各个连接设置优先级。
0 - 最高优先级等等。
归档时间: |
|
查看次数: |
17233 次 |
最近记录: |