AllInfo
Main: Info Blog Temp Mail


unix 2013-01-11 21-56-12

create a bridge between host and guests (ok)

Please note that all these changes must be done on the host system.

1.

Install bridge-utils.
2.

Edit /etc/network/interfaces:
1.

Remove the 'auto' line and change the 'method' of your physical, wired network adapters from to 'manual':

#auto eth0
iface eth0 inet manual

2.

Add a stanza for the bridge:

auto br0
iface br0 inet dhcp
pre-up ip tuntap add dev tap0 mode tap user <username>
pre-up ip link set tap0 up
bridge_ports all tap0
bridge_stp off
bridge_maxwait 0
bridge_fd 0
post-down ip link set tap0 down
post-down ip tuntap del dev tap0 mode tap

Explanation: this stanza auto loads a bridge and configures it using DHCP. A tap device is created owned by <username> and is brought up; please note that <username> is the username on the host system. On the 'bridge_ports' line, 'all' adds all physical interfaces to the bridge; virtual interfaces have to be listed explicitly. The three other bridge directives will speed up the activating of the bridge. See bridge-utils-interfaces(5) - note that the man page warns against adding wireless adapters to the bridge (see also BridgeNetworkConnections).
3.

Launch QEMU:

$ qemu -hda imagefile.img -net nic -net tap,ifname=tap0,script=no,downscript=no

*

ifname=tap0 - the tap name here corresponds with the name in the bridge stanza above.
*

script=no,downscript=no disable the scripts /etc/qemu-ifup and /etc/qemu-ifdown as they are not needed.

The guest virtual network adapters will be configured by the /etc/network/interfaces file in the guest file system. DHCP will work so this is simplest way to go.
4.

To run additional guests, duplicate the lines in the bridge stanza for tap1, tap2 as needed and change the ifname argument in the command line. If you run more guests from the same image file, udev will rename the interface to avoid duplication (e.g. eth0 => eth1), so add extra interface stanzas in the guest interfaces file to configure these.

3.134.90.44 / 2024-04-28_12-58-00 UTC.