使用 KVM 设置桥接网络

使用 KVM 设置桥接网络

我正在尝试安装 KVM。我已经完成安装,现在正在执行指导使桥接网络正常工作。但是,我被困在需要修改文件的部分/etc/network/interfaces

(注意:我没有安装 X。)

我在Ubuntu Server 15.04上:

$ uname -a
Linux boson 3.19.0-21-generic #21-Ubuntu SMP Sun Jun 14 18:31:11 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

$ ifconfig
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:72 errors:0 dropped:0 overruns:0 frame:0
          TX packets:72 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:11098 (11.0 KB)  TX bytes:11098 (11.0 KB)

p17p1     Link encap:Ethernet  HWaddr bc:5f:f4:ea:0e:28
          inet addr:10.0.1.220  Bcast:10.0.1.255  Mask:255.255.255.0
          inet6 addr: fe80::be5f:f4ff:feea:e28/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:173566 errors:0 dropped:0 overruns:0 frame:0
          TX packets:219213 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:18152992 (18.1 MB)  TX bytes:208778324 (208.7 MB)
          Interrupt:16

virbr0    Link encap:Ethernet  HWaddr 52:54:00:82:25:dd
          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)

该文件当前如下所示:

$ 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 p17p1
iface p17p1 inet dhcp

#auto virbr0
#iface virbr0 inet dhcp
#        bridge_ports p17p1
#        bridge_stp off
#        bridge_fd 0
#        bridge_maxwait 0

如果我取消注释最后几行,并且systemctl restart networking网络连接p17p1丢失,ifconfig则显示p17p1virbr0都有相同的 IP 地址。

我应该使用静态设置吗?

答案1

您不需要使用静态设置。
另外,我看到您已经找到了这个答案

对于动态 IP 地址解决方案,您应该设置一个真正的网桥并使用它。您的接口文件应该变成:

# 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

auto br0
iface br0 inet dhcp
   bridge_ports p17p1
   bridge_fd 9
   bridge_hello 2
   bridge_maxage 12
   bridge_stp off

注意:我从Ubuntu 服务器指南

相关内容