1. 程式人生 > >Openstack 虛擬機通訊

Openstack 虛擬機通訊

mar tap instance 參考 總結 com doc open 3.2

1、虛擬機南北通訊:

技術分享圖片

環境:
External network:

Network 203.0.113.0/24
IP address allocation from 203.0.113.101 to 203.0.113.200
Project network router interface 203.0.113.101 TR

Project network

Network 192.168.1.0/24
Gateway 192.168.1.1 with MAC address TG
Compute node 1
Instance 1 192.168.1.11 with MAC address I1

Instance 1 resides on compute node 1 and uses a project network.

The instance sends a packet to a host on the external network.

過程:

涉及到計算節點的過程:
instance 通過qbr設備上的qvb-qbr-qvo 攜帶自己的mac地址以及目的地址和網關以及tag
通過qbr橋生的安全組
qbr橋將流量轉送到br-int上
br-int橋為project 網絡打上相應的tag
For VLAN project networks
br-init-->br-vlan
br-vlan 替換tag為真實的tag
br-vlan 把包轉發到網絡節點的br-vlan
涉及到網絡節點
剛剛從compute節點的br-vlan的包通過交換機傳送到網絡節點的br-vlan上

br-vlan把包轉發給br-int橋
br-int把真實的tag轉換為ovs自己認的tag。br-int上面有qroute的接口(qr)設備,包含interface的gw 和tag
通過qroute的namespace 中的iptables規則把qr做為source nat到 qg設備上,可以查看namespace裏面的ip信息
技術分享圖片
[root@cloud02 ~]#
查看Iptables規則
neutron-l3-agent-float-snat all -- anywhere anywhere
SNAT all -- anywhere anywhere to:10.10.255.226
SNAT all -- anywhere anywhere mark match ! 0x2/0xffff ctstate DNAT to:10.10.255.226
br-int 轉發到br-ex上,再從br-ex到外網的子接口。
此時Snat已經全部完成。

2、帶有FloatingIP的虛擬機南北流量

技術分享圖片
環境:
External network

Network 203.0.113.0/24
IP address allocation from 203.0.113.101 to 203.0.113.200
Project network router interface 203.0.113.101 TR
Project network
Network 192.168.1.0/24
Gateway 192.168.1.1 with MAC address TG
Compute node 1
Instance 1 192.168.1.11 with MAC address I1 and floating IP address 203.0.113.102 F1
Instance 1 resides on compute node 1 and uses a project network.
The instance receives a packet from a host on the external network.
過程
通過網絡節點:
通過外部接口轉發到br-ex上,br-ex轉發到br-int上
br-ex的qg設備轉到qrouter上面的qg設備
技術分享圖片
技術分享圖片
在qruoter的namesapce查看iptables nat規則
技術分享圖片
查看IP為“10.0.0.5” 的虛擬機
技術分享圖片
可以查看到router裏面的flouting-ip對應的dnat是和虛擬機的project ip是一一對應的。
通過route把包轉送到br-int。br-init 傳送到br-vlan ,並打上真實的tag.
從接口到達交換機。

經過計算節點
計算節點的br-vlan 收到包後,傳送給br-init,br-int 把tag轉換為ovs自己的內部tag.。然後經過qvb和qvo著一對peer 到達qbr橋,從而到達到達tap設備。如圖:
技術分享圖片

虛擬機之間在不同的網絡通訊:
技術分享圖片
環境:

Project network 1
Network: 192.168.1.0/24
Gateway: 192.168.1.1 with MAC address TG1

Project network 2
Network: 192.168.2.0/24
Gateway: 192.168.2.1 with MAC address TG2
Compute node 1
Instance 1: 192.168.1.11 with MAC address I1
Compute node 2
Instance 2: 192.168.2.11 with MAC address I2
Instance 1 resides on compute node 1 and uses project network 1.
Instance 2 resides on compute node 2 and uses project network 2.
Both project networks reside on the same router.
Instance 1 sends a packet to instance 2.

通過compute01的:

tap設備通過qvb和qvo把qbr橋和br-int橋連接起來,從而到達br-int上
br-int把包轉發給br-vlan上,br-vlan打上真實的tag,然後通過接口發給交換機。
通過network 節點的:
br-vlan接收到compute01上br-vlan發送的包,br-vlan 把包轉發給br-int。 br-int把tag替換為自己能識別的tag
br-int把包發給qrouter 的qbr-1 接口。並且攜帶自身的網關信息。
路由通過route功能把qbr-1的包發送給qbr-2.
qbr-2 通過轉發到達br-int上
br-init 把包轉發給br-vlan,br-vlan把tag替換為真實的tag
br-vlan 把包發給network-2 的網橋上,br-vlan 把包發給compute-2的節點上
通過compute02節點的
計算節點2 接收到網絡節點br-vlan的包。
br-vlan===> br-int
br-int ===>qbr===>tap

總結:
1、相同網絡不同節點上的虛擬機互相通訊不經過網絡節點
2、不通網絡相互通訊經過網絡節點
3、相同網絡部同計算節點的虛擬機 互相通訊 直接走br-int

參考連接:
https://docs.openstack.org/liberty/networking-guide/scenario-classic-ovs.html

Openstack 虛擬機通訊