新手警告:我對虛擬化完全陌生,因此可能有一個非常簡單的解決方案...
我正在嘗試在 Ubuntu 14.04.1 LTS 上運行帶有 KVM 的虛擬機器作為主機。
為了方便使用,我使用 vmbuilder 建立虛擬機器。
我希望主機和訪客從現有的獨立 DHCP 伺服器取得各自的 IP 位址。
-> 我相信我需要一個網橋。
我已經成功地設定並運行了帶有 NAT 的虛擬機,但是轉向橋接網路卻讓我陷入了困境。我可以建立虛擬機器並啟動它,但我沒有看到 ARP 條目或來自來賓 MAC 位址的任何流量,因此我不知道它被分配了哪個 IP。
這給我留下了以下問題,非常感謝您的回答或提示:
- 我是否搞砸了網路配置中的某些內容?
- 如何確定我的訪客被分配了哪個 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 虛擬機器橋接
<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 網路的內容:)