Debian 网桥配置 - /etc/network/interfaces

Debian 网桥配置 - /etc/network/interfaces

我正在运行 Lenny Xen dom0,它在路由 IP 设置中托管多个虚拟机。为了获得额外的私有子网,我使用以下命令在 dom0 中创建了网桥 xenbr0:

brctl addbr xenbr0
ifconfig xenbr0 10.0.0.1 netmask 255.255.255.0
ifconfig xenbr0 up

这按预期工作,并且 domU 接口在 VM 启动时由 Xen 添加到桥接器中。我唯一的问题是:我该如何在 /etc/network/interfaces 中指定此配置,以使其保持永久状态并且桥接器在重新启动后可用?我尝试了许多教程中提供的以下配置:

auto xenbr0
iface xenbr0 inet static
  address 10.0.0.1
  netmask 255.255.255.0
  network 10.0.0.0
  broadcast 10.0.0.255
  bridge_stp no

我收到 2 个不同的错误,具体取决于桥接器是否已存在。如果不存在:

root@dom0:~# brctl show
bridge name     bridge id               STP enabled     interfaces
root@dom0:~# /etc/init.d/networking restart
Reconfiguring network interfaces...if-up.d/mountnfs[eth0]: waiting for interface xenbr0 before doing NFS mounts (warning).
SIOCSIFADDR: No such device
xenbr0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
SIOCSIFBRDADDR: No such device
xenbr0: ERROR while getting interface flags: No such device
xenbr0: ERROR while getting interface flags: No such device
Failed to bring up xenbr0.
done.

如果存在:

root@dom0:~# brctl show
bridge name     bridge id               STP enabled     interfaces
xenbr0          8000.000000000000       no
root@dom0:~# /etc/init.d/networking restart
Reconfiguring network interfaces...if-up.d/mountnfs[eth0]: waiting for interface xenbr0 before doing NFS mounts (warning).
RTNETLINK answers: File exists
Failed to bring up xenbr0.
done.

有人能给我指出正确的方向吗?手动创建时,桥接器工作正常,我只需要正确的配置文件条目。我发现的大多数教程都在配置中向桥接器添加了一些设备,这可能是它不起作用的原因吗?我没有任何想在创建时添加到桥接器的接口,因为它们稍后会在 VM 启动时添加...

谢谢,马蒂亚斯

答案1

你似乎错过了最重要的一句话:

auto xenbr0
iface xenbr0 inet static
  bridge_ports eth0 eth4 eth7    # bridge traffic between these interfaces
  bridge_stp no
  address 10.0.0.1
  netmask 255.255.255.0
  network 10.0.0.0
  broadcast 10.0.0.255

man说:如果您需要更灵活地指定接口,您可以使用以下语法(在 Xen dom0 上最有用):

     bridge_ports regex (eth|vif).*

这意味着评估(如在 egrep(1) 中)“regex”后面的表达式。

答案2

启动后运行的脚本如何执行您想要的命令?

答案3

您可能需要删除该network-manager软件包。它通常会干扰手动界面设置。

相关内容