KVM 桥接网络问题

KVM 桥接网络问题

新手警告:我对虚拟化完全陌生,因此可能有一个非常简单的解决方案......

我正在尝试在 Ubuntu 14.04.1 LTS 上用 KVM 运行虚拟机作为主机。
为了方便使用,我使用 vmbuilder 构建虚拟机。
我希望主机和客户机从现有的独立 DHCP 服务器获取各自的 IP 地址。-
> 我相信我需要一个网桥来实现这一点。

我已经设法设置并运行了带有 NAT 的虚拟机,但转向桥接网络却让我陷入困境。我可以构建虚拟机并启动它,但我看不到 ARP 条目或来自客户 MAC 地址的任何流量,所以我不知道它被分配了哪个 IP。

这让我产生了以下问题,如果能得到答案或提示我将非常感激:

  1. 我是否弄坏了网络配置中的某些东西?
  2. 我如何知道我的客人被分配了哪个 IP 地址?

非常感谢!

如何构建虚拟机:

kidmose@radagast:~$ sudo vmbuilder kvm ubuntu -o \
--hostname vm-bridged \
--libvirt qemu:///system \
--addpkg openssh-server \
--destdir=./virtual-machines \
--flavour virtual \
--bridge br0 \
--suite precise

kidmose@radagast:~$ cat /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# # The primary network interface
# auto em1
# iface em1 inet dhcp

# Bridged network interface
auto br0
iface br0 inet dhcp
      bridge_ports em1
      bridge_stp off

kidmose@radagast:~$ brctl 显示

bridge name bridge id       STP enabled interfaces
br0     8000.c81f66cce0eb   no      em1
                            vnet0
virbr0      8000.000000000000   yes     

kidmose@radagast:~$ ifconfig

br0       Link encap:Ethernet  HWaddr c8:1f:66:cc:e0:eb  
          inet addr:10.20.12.216  Bcast:10.20.12.255  Mask:255.255.255.0
          inet6 addr: fe80::ca1f:66ff:fecc:e0eb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3239 errors:0 dropped:0 overruns:0 frame:0
          TX packets:430 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:493254 (493.2 KB)  TX bytes:54832 (54.8 KB)

em1       Link encap:Ethernet  HWaddr c8:1f:66:cc:e0:eb  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3269 errors:0 dropped:0 overruns:0 frame:0
          TX packets:449 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2648215 (2.6 MB)  TX bytes:58759 (58.7 KB)
          Interrupt:16 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

virbr0    Link encap:Ethernet  HWaddr 62:dc:74:f4:4d:69  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

vnet0     Link encap:Ethernet  HWaddr fe:54:00:ce:0a:3c  
          inet6 addr: fe80::fc54:ff:fece:a3c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:20 errors:0 dropped:0 overruns:0 frame:0
          TX packets:261 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:2143 (2.1 KB)  TX bytes:50735 (50.7 KB)

kidmose@radagast:~$ virsh dumpxml vm-bridged

<domain type='kvm'>
  <name>vm-bridged</name>
  <uuid>3d2fa61d-81ed-420b-afd3-00584b5ac116</uuid>
  <memory unit='KiB'>131072</memory>
  <currentMemory unit='KiB'>131072</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/home/kidmose/virtual-machines/tmpAQAZpr.qcow2'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:ce:0a:3c'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </memballoon>
  </devices>
</domain>

答案1

事实证明,不同的 MAC 是重要的细节:
vnet0 显然是主机上所需的 tap 接口。mac
地址virsh dumpxml vm-bridged是正确的。
http://www.redhat.com/archives/libvir-list/2012-June/msg01330.html

fe:54:00:ce:0a:3c一切都运行正常,但我正在寻找我应该寻找的IP 52:54:00:ce:0a:3c

我仍然有点困惑,因为没有出现任何内容,arp但这只是表明我需要阅读更多有关 Linux 网络的内容:)

相关内容