我有一个有 4 个公共 IP 的服务器。我有这样的配置,我想桥接接口 eth0 以将其与 KVM 一起使用:
所以,我有 3 个 IP(ABC144、ABC145、ABC146)和另一个与我想要桥接的主 IP 的接口(188.165.XY)
/etc/网络/接口:
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 188.165.X.Y
netmask 255.255.255.0
network 188.165.255.0
broadcast 188.165.255.255
gateway 188.165.255.254
# KVM Bridge
auto br0
iface br0 inet static
address 188.165.X.Y
netmask 255.255.255.0
network 188.165.255.0
broadcast 188.165.255.255
gateway 188.165.255.254
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off
auto eth0:0
iface eth0:0 inet static
address A.B.C.145
netmask 255.255.255.255
auto eth0:1
iface eth0:1 inet static
address A.B.C.146
netmask 255.255.255.255
auto eth0:2
iface eth0:2 inet static
address A.B.C.147
netmask 255.255.255.255
除了桥接器 (br0) 之外,一切 (eth0、eth0:0: eth0:1、eth0:2) 都工作正常。但是,如果我这样做:
ifup br0
我失去了连接,必须在没有 br0 的情况下恢复配置。
我应该怎么办?
使用@Ulrich配置:
device eth0 entered promiscuous mode
e1000e 0000:00:19.0: irq 43 for MSI/MSI-X
e1000e 0000:00:19.0: irq 43 for MSI/MSI-X
ADDRCONF(NETDEV_UP): eth0: link is not ready
ADDRCONF(NETDEV_UP): br0: link is not ready
e1000e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: None
e1000e 0000:00:19.0: eth0: 10/100 speed: disabling TSO
ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
br0: port 1(eth0) entering forwarding state
br0: port 1(eth0) entering forwarding state
ADDRCONF(NETDEV_CHANGE): br0: link becomes ready
答案1
如果你真的想将 eth0 与你的 kvm guest 桥接起来,你应该只通过你的桥配置你的东西,例如:
auto eth0
iface eth0 inet manual
auto br0
iface br0 inet static
address 188.165.X.Y
netmask 255.255.255.0
network 188.165.255.0
broadcast 188.165.255.255
gateway 188.165.255.254
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off
如果您不想桥接而只想创建一个路由器(这取决于您的网络设置),则必须创建一个没有任何端口的桥接器/etc/network/interface
并创建适当的路由条目。 libvirt 可以创建正确的网桥,但该网桥必须有一个额外的 IP。