在一個子網上具有綁定介面的主機,為 VM 設置具有不同公共子網的網橋
注意: 我仍然無法讓這個配置工作,但我會盡快發布我的解決方案。
我正在設置一個執行多個 KVM 的 Ubuntu 主機伺服器(16.04)。主機伺服器有 4 個物理 NIC,它們成對綁定以訪問面向公眾的網路和專用網路。主機分配有一個主要的公共子網(只有一個可用的外部 IP)和一個主要的私有子網(有一個可用的內部 IP)。此外,我還為該主機上的虛擬機獲取了兩個額外的 8 個 IP 子網,一個是公共的,一個是私有的。例如,這是我的 IP 佈局:
對於主機:
- 公共主子網:200.0.0.72/29 - 可用公共 IP:200.0.0.75
- 專用主子網:10.0.0.128/26 - 可用專用 IP:10.0.0.138
用於 VMS
- 公共可移植子網:200.0.1.240/29,5 個可用公共 IP
- 私有攜帶式子網:10.0.1.216/29,5 個可用私有 IP
我在讓主機從我的虛擬機網橋介面中擁有一個單獨的子網時遇到了很多麻煩。當我指定了網橋時,似乎我無法讓主機正確聯網,並且當我沒有在綁定介面的主機區域中指定網路時,網橋只能工作。我的介面文件如下。你在這裡看到的是我“想要的”結果,實際上並沒有用。通過評論不同的部分並重新啟動網路,我已經能夠讓作品發揮作用。我還根據我的 ISP 的指令添加了路由命令(路由添加),但它們無法在橋接方面和 VM 方面提供幫助。
############################################ #For more information, see interfaces(5). ############################################ ##Loopback auto lo iface lo inet loopback ## Setup bond0 interface - INTERNAL CONNECTIONS auto bond0 iface bond0 inet static bond-lacp-rate 1 #pre-up /sbin/ethtool -s bond0 speed 100 duplex full autoneg off post-up ifenslave bond0 eth0 eth2 pre-down ifenslave -d bond0 eth0 eth2 address 10.0.0.138 netmask 255.255.255.192 gateway 10.0.0.129 bond-slaves none bond-mode 4 bond-lacp-rate fast bond-miimon 100 bond-downdelay 0 bond-updelay 0 bond-xmit_hash_policy 1 up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.0.0.129 auto eth0 iface eth0 inet manual bond-master bond0 #pre-up /sbin/ethtool -s eth0 speed 100 duplex full autoneg off auto eth2 iface eth2 inet manual bond-master bond0 #pre-up /sbin/ethtool -s eth2 speed 100 duplex full autoneg off auto br0 iface br0 inet static address 10.0.1.218 netmask 255.255.255.192 gateway 10.0.1.217 bridge_ports bond0 bridge_stp off bridge_fd 9 bridge_hello 2 bridge_maxage 12 ## Setup bond1 interface - EXTERNAL CONNECTIONS auto bond1 iface bond1 inet static bond-lacp-rate 1 post-up ifenslave bond1 eth1 eth3 pre-down ifenslave -d bond1 eth1 eth3 bond-slaves none bond-mode 4 bond-lacp-rate fast bond-miimon 100 bond-downdelay 0 bond-updelay 0 bond-xmit_hash_policy 1 address 200.0.0.75 netmask 255.255.255.248 gateway 200.0.0.73 up route add -net 0.0.0.0 netmask 0.0.0.0 gw 200.0.0.73 auto eth1 iface eth1 inet manual bond-master bond1 auto eth3 iface eth3 inet manual bond-master bond1 auto br1 iface br1 inet static address 200.0.1.242 netmask 255.255.255.248 gateway 200.0.1.241 #up iptables-restore < /etc/iptables.rules post-up echo 0 > /sys/devices/virtual/net/br1/bridge/multicast_snooping bridge_ports bond1 bridge_stp off bridge_fd 9 bridge_hello 2 bridge_maxage 12
如果我的主機上已經有一個子網(在綁定介面上),我在橋接介面上指定特定地址可能是錯誤的,但是我不確定如何為 VMS(在橋接上)指定一個單獨的子網而不做那。提前感謝您對我在這裡做錯的任何評論/建議。
#附加1:VLAN
下面是我的 ISP 給我的 VLAN 子網。“僅限未來伺服器的主 IP”是指給另一個客戶/主機的主 IP,我無法訪問。此外,還有兩個主要的私有 IP,一個可供我的主機作業系統訪問,另一個是用於控制台訪問的管理界面(通過它看起來像的 bios)。
有兩個 VLAN,一個是公用的,一個是專用的,每個都有編號,並有一個與之關聯的路由器。即 VLAN 號 1200 路由器 zzz02a.bbb03 用於公共網路,一個類似的專用網路。
公共主子網
200.0.0.72 Reserved Network 200.0.0.73 Reserved Gateway 200.0.0.74 Reserved Primary IP for future server only 200.0.0.75 In Use host.mydomain.com 200.0.0.76 Reserved Primary IP for future server only 200.0.0.77 Reserved Primary IP for future server only 200.0.0.78 Reserved Primary IP for future server only 200.0.0.79 Reserved Broadcast
公共攜帶式子網
200.0.1.240 Reserved Network 200.0.1.241 Reserved Gateway 200.0.1.242 Available vm1.mydomain.com 200.0.1.243 Available <<available for vm>> 200.0.1.244 Available <<available for vm>> 200.0.1.245 Available <<available for vm>> 200.0.1.246 Available <<available for vm>> 200.0.1.247 Reserved Broadcast
專用主子網
10.0.0.128 Reserved Network 10.0.0.129 Reserved Gateway 10.0.0.130 Reserved Primary IP for future server only 10.0.0.131 Reserved Primary IP for future server only 10.0.0.132 Reserved Primary IP for future server only 10.0.0.133 Reserved Primary IP for future server only 10.0.0.134 Reserved Primary IP for future server only 10.0.0.135 Reserved Primary IP for future server only 10.0.0.136 Reserved Primary IP for future server only 10.0.0.137 Reserved Primary IP for future server only 10.0.0.138 In Use host.mydomain.com 10.0.0.139 Reserved Primary IP for future server only 10.0.0.140 Reserved Primary IP for future server only 10.0.0.141 Reserved Primary IP for future server only 10.0.0.142 Reserved Primary IP for future server only 10.0.0.143 Reserved Primary IP for future server only 10.0.0.144 Reserved Primary IP for future server only 10.0.0.145 Reserved Primary IP for future server only 10.0.0.146 Reserved Primary IP for future server only 10.0.0.147 Reserved Primary IP for future server only 10.0.0.148 Reserved Primary IP for future server only 10.0.0.149 In Use host.mydomain.com 10.0.0.150 Reserved Primary IP for future server only 10.0.0.151 Reserved Primary IP for future server only 10.0.0.152 Reserved Primary IP for future server only
私有攜帶式子網
10.0.1.216 Reserved Network 10.0.1.217 Reserved Gateway 10.0.1.218 Available vm1.mydomain.com 10.0.1.219 Available <<available for vm>> 10.0.1.220 Available <<available for vm>> 10.0.1.221 Available <<available for vm>> 10.0.1.222 Available <<available for vm>> 10.0.1.223 Reserved Broadcast
我認為沒有vlan。如果您想將所有 4 個子網共享給您的虛擬機,您應該在網橋上分配它們。介面文件應該是:
############################################ #For more information, see interfaces(5). ############################################ ##Loopback auto lo iface lo inet loopback ## Setup bond0 interface - INTERNAL CONNECTIONS auto bond0 iface bond0 inet manual bond-slaves eth0 eth2 bond-mode 4 bond-lacp-rate fast bond-miimon 100 bond-downdelay 0 bond-updelay 0 bond-xmit_hash_policy 1 auto eth0 iface eth0 inet manual bond-master bond0 auto eth2 iface eth2 inet manual bond-master bond0 ## Setup VLAN ID 1201 on bond0 interface auto bond0.1201 iface bond0.1201 inet manual vlan_raw_device bond0 auto br0 iface br0 inet static address 10.0.0.138 netmask 255.255.255.192 bridge_ports bond0.1201 bridge_stp off up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.0.0.129 auto br0:1 iface br0:1 inet static address 10.0.1.218 netmask 255.255.255.192 ## Setup bond1 interface - EXTERNAL CONNECTIONS auto bond1 iface bond1 inet manual bond-slaves eth1 eth3 bond-mode 4 bond-lacp-rate fast bond-miimon 100 bond-downdelay 0 bond-updelay 0 bond-xmit_hash_policy 1 auto eth1 iface eth1 inet manual bond-master bond1 auto eth3 iface eth3 inet manual bond-master bond1 ## Setup VLAN ID 1200 on bond1 interface auto bond1.1200 iface bond1.1200 inet manual vlan_raw_device bond1 auto br1 iface br1 inet static address 200.0.0.75 netmask 255.255.255.248 gateway 200.0.0.73 post-up echo 0 > /sys/devices/virtual/net/br1/bridge/multicast_snooping bridge_ports bond1.1200 bridge_stp off auto br1:1 iface br1:1 inet static address 200.0.1.242 netmask 255.255.255.248