Linux
橋接乙太網介面
我有一個有 4 個公共 IP 的伺服器。我有這個配置,我想橋接介面 eth0 以便將它與 KVM 一起使用:
所以,我有 3 個 IP(ABC144、ABC145、ABC146)和另一個要橋接的主 IP 介面(188.165.XY)
/etc/network/interfaces:
# 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
一切(eth0,eth0:0:eth0:1,eth0:2)都工作正常,除了網橋(br0)。但是,如果我這樣做:
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
如果您真的想將 eth0 與您的 kvm 客人橋接,您應該只通過您的網橋配置您的東西,例如:
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。