橋接乙太網路介面

橋接乙太網路介面

我有一個有 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。

相關內容