网络管理器中断手动路由

Rei*_*ien 10 network-manager networking routing 13.10

我有 Ubuntu 13.10,Saucy Salamander x64 在 VirtualBox 中作为来宾运行(Windows 7 作为主机)。

我写这个/etc/network/interfaces是因为我需要添加大量永久的、手动的静态路由:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet dhcp
    up ip -force -b /etc/network/eth1-routes
Run Code Online (Sandbox Code Playgroud)

eth1-routes 包含几行表格:

route add 10.0.0.0/8 via 172.x.x.x dev eth1
Run Code Online (Sandbox Code Playgroud)

172.x.x.xVBox NAT 给我的网关在哪里。

通过运行netstat -nr,似乎我的所有手动路由都已成功添加,包括通过172.x.x.x.

但是,网络管理员说这两个设备都“不受管理”。如果我设置了/etc/NetworkManager/NetworkManager.conf managed=true,网络管理器会再次工作,但我的路由丢失了。所以我目前的妥协是设置managed=false并注释掉eth0的行/etc/network/interfaces

有没有办法管理设备并仍然执行上述手动路由?

小智 5

网络管理器管理自己的静态路由 - 打开网络管理器并选择“有线连接 1”。选择编辑。选择 IPv4 选项卡。此页面底部是“路线”按钮。那就是你添加它们的地方。完成后,NM 在其 /etc/NetworkManager/system-connections/ 目录中写入一个具有 root 权限的文件,称为“有线连接 1”

示例如下

ls -l /etc/NetworkManager/system-connections/
total 4.0K
-rw------- 1 root root 216 Aug 26 10:38 Wired connection 1

sudo cat /etc/NetworkManager/system-connections/Wired\ connection\ 1

[802-3-ethernet]
mac-address=A:Real:Mac:Add:re:ss

[connection]
id=Wired connection 1
uuid=df4491fc-0981-4071-82ae-04c7b2d6d9fc
type=802-3-ethernet

[ipv6]
method=auto

[ipv4]
method=auto
route1=10.2.2.0/24,10.1.1.68,1
Run Code Online (Sandbox Code Playgroud)

其中 10.2.2.0 是目标网络,10.1.1.68 是网关。


cha*_*aos 4

网络管理器无法识别您在 中写入的语句/etc/network/interfaces

因此,您可以将脚本添加eth1-routes为 中网络管理器的调度程序脚本/etc/network/if-up.d/。每次接口上线时都会运行它。eth1也许您必须在脚本中编写一个“if 子句”,以便仅在出现时添加路由。像这样:

if [ "$IFACE" == "eth1" ]; then
  route add ...
  route add ...
fi
Run Code Online (Sandbox Code Playgroud)