全新安装 Ubuntu 12.04 LTS,并安装 libvert/KVM。我有 2 台虚拟机,需要与主机位于同一 LAN 上。主机有两个物理接口 eth0 和 eth1。eth1 未使用。我希望 eth0 具有静态分配的 IP 并充当我的 VM 的桥梁。
在设置网桥之前,我的 /etc/network/interfaces 看起来像:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 10.0.5.5
netmask 255.255.255.0
gateway 10.0.5.254
dns-nameservers 10.0.5.1
在此配置下,一切都按预期工作。但是,当我应用以下标题配置时:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto br0
iface br0 inet static
address 10.0.5.5
netmask 255.255.255.0
gateway 10.0.5.254
dns-nameservers 10.0.5.1
bridge_ports eth0
bridge_stp off
bridge_maxwait 0
bridge_fd 0
在此配置下,我可以通过 IP 和名称 ping 内部主机。名称解析按预期工作。尝试 ping 外部主机时,系统会显示“无主机路由”。
这是应用桥接配置后的 ifconfig -a。
br0 Link encap:Ethernet HWaddr 00:25:90:da:29:8f
inet addr:10.0.5.5 Bcast:10.0.5.255 Mask:255.255.255.0
inet6 addr: fe80::225:90ff:feda:298f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11569 errors:0 dropped:0 overruns:0 frame:0
TX packets:586 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1433248 (1.4 MB) TX bytes:63079 (63.0 KB)
eth0 Link encap:Ethernet HWaddr 00:25:90:da:29:8f
inet addr:10.0.5.107 Bcast:10.0.5.255 Mask:255.255.255.0
inet6 addr: fe80::225:90ff:feda:298f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13632 errors:0 dropped:122 overruns:0 frame:0
TX packets:1240 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2008747 (2.0 MB) TX bytes:119540 (119.5 KB)
Interrupt:20 Memory:dfa00000-dfa20000
eth1 Link encap:Ethernet HWaddr 00:25:90:da:29:8e
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:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:16 Memory:df900000-df920000
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:745 errors:0 dropped:0 overruns:0 frame:0
TX packets:745 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:66095 (66.0 KB) TX bytes:66095 (66.0 KB)
virbr0 Link encap:Ethernet HWaddr c2:dd:f8:44:eb:2d
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)
最终,我希望 eth0 具有静态 10.0.5.5,并将我的两个 VM 放在此接口上,并静态分配 10.0.5.6-7。我的配置有什么问题?