0

I have a server that's running Ubuntu 14.04, and I'm trying to run two virtual machines with bridged networking at the same time. The networking of the first VM works, but the second one has no networking.

The virtual machines are also Ubuntu 14.04.

What's the best way to get full (bridged) internet access for both VMs?

My best guess was to copy my br0 to br1, as seen below. But since it doesn't work, I'm guessing I need to do something else.

Here's my /etc/network/interfaces:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto em1
iface em1 inet dhcp

auto br0
iface br0 inet dhcp
   pre-up ip tuntap add dev tap0 mode tap user thor
   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

auto br1
iface br1 inet dhcp
   pre-up ip tuntap add dev tap1 mode tap user thor
   pre-up ip link set tap1 up
   bridge_ports all tap1
   bridge_stp off
   bridge_maxwait 0
   bridge_fd      0
   post-down ip link set tap1 down
   post-down ip tuntap del dev tap1 mode tap

And here's how I start the kvms.

(kvm1 - the one that has networking)

kvm -enable-kvm -nographic -net nic -net tap,ifname=tap0,script=no,downscript=no -hda disk.img.a.qcow2 -hdb my-seed.img -m 8192 -smp 16

(kvm2 - the vm without networking)

kvm -enable-kvm -nographic -net nic -net tap,ifname=tap1,script=no,downscript=no -hda disk.img.b.qcow2 -hdb my-seed.img -m 8192 -smp 16
1

Bridges are like virtual ethernet switches -- you plug many VMs into them, not just one. You should create a single bridge, and attach the NICs of both VMs to that one bridge. Then they'll be able to talk to each other.

  • Thanks for the answer @womble. I tried commenting out the br1 section from the /etc/network/interfaces and rebooting. Then after rebooting, since tap1 didn't seem to exist, I ran ip tuntap add dev tap1 mode tap user thor ip link set tap1 up I then ran the same kvm commands as above. kvm1 still works fine, kvm2 still doesn't have networking at all. Can you tell me what else I should try? Thanks! – user1175849 Nov 19 '15 at 4:24
0

Based on @Womble's suggestion, I seem to have gotten it to work. I'll post what I did here so hopefully it will help others.

I welcome suggestions for better solutions.

Here's my new /etc/network/interfaces:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto em1
iface em1 inet dhcp

auto br0
iface br0 inet dhcp
   pre-up ip tuntap add dev tap0 mode tap user myusername
   pre-up ip link set tap0 up

   pre-up ip tuntap add dev tap1 mode tap user myusername
   pre-up ip link set tap1 up

   bridge_ports all tap0 tap1
   bridge_stp off
   bridge_maxwait 0
   bridge_fd      0

   post-down ip link set tap1 down
   post-down ip tuntap del dev tap1 mode tap

   post-down ip link set tap0 down
   post-down ip tuntap del dev tap0 mode tap

(Replacing myusername, with the real user name I'm using).

Here's the command to start the first kvm:

kvm -enable-kvm -nographic -net nic -net tap,ifname=tap0,script=no,downscript=no -hda disk.a.qcow2 -hdb my-seed.img -m 8192 -smp 16

And here's the command to start the second kvm

kvm -enable-kvm -nographic -net nic,macaddr=0c:c4:7a:73:14:b2 -net tap,ifname=tap1,script=no,downscript=no -hda disk.img.b.qcow2 -hdb my-seed.img -m 8192 -smp 16

I had to explicitly set the mac address on the second kvm, otherwise it would have the same mac address as the first. Having the same MAC address leads to intermittent timeouts with networking, as you can imagine.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.