简体   繁体   English

如何将主机连接到她的虚拟网桥?

[英]How to connect the host to her virtual bridge?

A bridge brOnline is connected to eth0 which provides access to the LAN / Internet.网桥brOnline连接到eth0 ,提供对 LAN/Internet 的访问。 The setup is archived within modifying /etc/network/interfaces like below.设置存档在修改/etc/network/interfaces如下所示。

Why?为什么? The aim of this adventure is establish a virtual network between several virtual machines and the system hosting the virtual bridge an the virtual machines (host).这次冒险的目的是在几个虚拟机和托管虚拟网桥的系统和虚拟机(主机)之间建立一个虚拟网络。

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto MyBridge
iface MyBridge inet dhcp
    bridge_port eth0
    bridge_stp on
    bridge_fd 0.0

How can I connect to the bridge from my host?如何从我的主机连接到网桥?

One important thing: Adding eth0 to the bridge makes it somehow unavailable to the host!一件重要的事情:eth0添加到网桥会使主机以某种方式无法使用它!

So before adding the interface eth0 to the bridge, which magic was connected to eth0 which enabled my browser the access to the local network?那么在将接口eth0添加到桥接器之前,哪个魔法连接到eth0使我的浏览器能够访问本地网络? Can or how can I connect this magic to the bridge to have access to the LAN and can talk to the other clients connected to the bridge?我可以或如何将此魔法连接到网桥以访问 LAN 并可以与连接到网桥的其他客户端通话?

The attempts have been wrong.尝试是错误的。 For the host it is not necessary to connect over an tap-device to the bridge, it has the abilety to connect directly to the bridge.对于主机来说,不需要通过 Tap 设备连接到网桥,它可以直接连接到网桥。 In Other words if you set your default route to bridge connecting to the gateway, than you can connect to the LAN-Interface too.换句话说,如果您将默认路由设置为桥接连接到网关,那么您也可以连接到 LAN 接口。

# see actual settings
# The displayed via is the default gw which may be provided by your dhcp
ip route
default via 42.69.42.69 dev eth0
...

# delete the default route, otherwise error: "file exists" will show up
sudo ip route del default via 42.69.42.69 dev eth0

# Add your bridge as default route
sudo ip route add default via 42.69.42.69 dev brOnline

# check
ip route
default via 10.13.0.10 dev brOnline

ping/ssh to the outside are possible, also firefox is working with those settings. ping/ssh 到外部是可能的,firefox 也正在使用这些设置。

Hint:暗示:

  • Those changes are not permanent.这些变化不是永久性的。 To do so, you need to edit /etc/network/interfaces .为此,您需要编辑/etc/network/interfaces
  • I'm still not able to ping to the other VM's and vice versa, but this might be an other topic.我仍然无法 ping 到其他虚拟机,反之亦然,但这可能是另一个话题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM