昨天看到利用Router連接二個Geneve Network,但是router還可以連接不同類型的Network,今天就來看一下如何完成這件事吧。
今天建立的網路架構,和昨天基本上是一樣的,差別只在於其中一個Network是flat type,而不是二個netwrok都是geneve type。從下面的操作可以得知,昨天和今天的操作,唯一的差別,就只在於第二個Netwrok是選用flat Network,如果忘了flat Network的特性,可以再次複習Day-17: Flat Tenant Network。
openstack network create --provider-network-type geneve --provider-segment 100 n1
openstack subnet create --subnet-range 172.16.100.0/24 --network n1 n1subnet
openstack network create --provider-network-type flat --provider-physical-network flat0 n2
openstack subnet create --subnet-range 192.168.10.0/24 --network n2 n2subnet
openstack server group create --policy affinity odd_affinity
openstack server group create --policy anti-affinity odd_anti_affinity
IMAGE_ID=$(openstack image show cirros --format json | jq -r .id)
AFFINITY_ID=$(openstack server group show odd_affinity --format json | jq -r .id)
ANTI_AFFINITY_ID=$(openstack server group show odd_anti_affinity --format json | jq -r .id)
openstack server create --nic net-id=n1,v4-fixed-ip=172.16.100.10 --flavor m1.nano --image $IMAGE_ID --hint group=$AFFINITY_ID vm_1
openstack server create --nic net-id=n2,v4-fixed-ip=192.168.10.20 --flavor m1.nano --image $IMAGE_ID --hint group=$ANTI_AFFINITY_ID vm_2
openstack server list --long -c Name -c Status -c Host -c "Power State"
+------+--------+-------------+------------+
| Name | Status | Power State | Host |
+------+--------+-------------+------------+
| vm_2 | ACTIVE | Running | compute-02 |
| vm_1 | ACTIVE | Running | compute-01 |
+------+--------+-------------+------------+
openstack router create r
openstack router add subnet r n1subnet
openstack router add subnet r n2subnet
# Network
openstack network list --long -c ID -c "Network Type" | abbrev
+--------+--------------+
| ID | Network Type |
+--------+--------------+
| 76af9b | geneve |
| 72ac1d | flat |
+--------+--------------+
# Port
openstack port list --long -c ID -c "Fixed IP Addresses" -c "Device Owner" | abbrev
+--------+-------------------------------------------------+--------------------------+
| ID | Fixed IP Addresses | Device Owner |
+--------+-------------------------------------------------+--------------------------+
| 0bece6 | ip_address='172.16.100.10' , subnet_id='ec52a9' | compute:nova |
| 06ff4f | ip_address='172.16.100.2' , subnet_id='ec52a9' | network:distributed |
| 1c52f2 | ip_address='172.16.100.1' , subnet_id='ec52a9' | network:router_interface |
| d9d8c1 | ip_address='192.168.10.20' , subnet_id='6f6c62' | compute:nova |
| 57aec0 | ip_address='192.168.10.2' , subnet_id='6f6c62' | network:distributed |
| 70392b | ip_address='192.168.10.1' , subnet_id='6f6c62' | network:router_interface |
+--------+-------------------------------------------------+--------------------------+
OpenStack 建立的OVN元件長像如圖所示,一樣是把之前學過的做個統整,其中logical router 的資訊,可以參照 Day-14: OpenStack Router連接二個Network,而flat network對應的logical switch 的資訊,可以參照Day-17: Flat Tenant Network,就讓大家自己練習。
建立二個instances後,二個compute node上bridge的情況,可以參考Day-17: Flat Tenant Network的介紹,原理也是完全相同的。
因為今天的說明不會提及network-controller節點、eth0,所以我們把這些資訊從圖中省略。
大家思考一下,如果是geneve network,VM間是透過eth1經過geneve tunnel 做封包傳送;如果是flat network,VM間是透過eth2 直接傳送封包。這些內容之前都說明過了,忘了可以再往前複習一下。但是今天在二個不同的network上的VM要溝通,到底是透過eth1的geneve netwrok, 還是透過 eth2 直接通訊? 這是我們今天要搞清楚的內容。
今天的實驗是從 compute-01上屬於geneve network的vm_1,對compute-02上屬於falt network的vm_2,發起ping。我們來看一下,在二個compute node上的eth1與eth2抓封包的結果吧。
雖然 vm_1是連在geneve network上,但我們可以看到ICMP request是由 flat network 所使用的eth2 介面送出,且並不是採用geneve tunnel。
tcpdump -i eth2 icmp
05:48:29.346616 IP 172.16.100.10 > 192.168.10.20: ICMP echo request, id 7635, seq 1, length 64
在 eth1 的geneve tunnel上,只看到由compute-02上的vm_2送回來的ICMP reply。
tcpdump -vvneei eth1 'udp port 6081'
05:48:29.349789 52:54:00:0b:69:b3 > 52:54:00:ea:65:ed, ethertype IPv4 (0x0800), length 156: (tos 0x0, ttl 64, id 26018, offset 0, flags [DF], proto UDP (17), length 142)
192.168.33.30.29927 > 192.168.33.20.geneve: [bad udp cksum 0xc40e -> 0x5989!] Geneve, Flags [C], vni 0x1, proto TEB (0x6558), options [class Open Virtual Networking (OVN) (0x102) type 0x80(C) len 8 data 00030002]
fa:16:3e:03:34:34 > fa:16:3e:66:be:d8, ethertype IPv4 (0x0800), length 98: (tos 0x0, ttl 63, id 57570, offset 0, flags [none], proto ICMP (1), length 84)
192.168.10.20 > 172.16.100.10: ICMP echo reply, id 7635, seq 1, length 64
在vm_2所在的compute-02上,在flat network所用的eth2可以看到ICMP request.
tcpdump -i eth2 icmp
05:48:29.355366 IP 172.16.100.10 > 192.168.10.20: ICMP echo request, id 7635, seq 1, length 64
而vm_2要回傳給vm_1的ICMP reply,則是經由geneve tunnel 送回給在compute-01上的vm_1.
tcpdump -vvneei eth1 'udp port 6081'
05:48:29.358164 52:54:00:0b:69:b3 > 52:54:00:ea:65:ed, ethertype IPv4 (0x0800), length 156: (tos 0x0, ttl 64, id 26018, offset 0, flags [DF], proto UDP (17), length 142)
192.168.33.30.29927 > 192.168.33.20.geneve: [bad udp cksum 0xc40e -> 0x5989!] Geneve, Flags [C], vni 0x1, proto TEB (0x6558), options [class Open Virtual Networking (OVN) (0x102) type 0x80(C) len 8 data 00030002]
fa:16:3e:03:34:34 > fa:16:3e:66:be:d8, ethertype IPv4 (0x0800), length 98: (tos 0x0, ttl 63, id 57570, offset 0, flags [none], proto ICMP (1), length 84)
192.168.10.20 > 172.16.100.10: ICMP echo reply, id 7635, seq 1, length 64
總結來說,在 geneve network上的vm_1,透過 flat network送封包給在另一個節點上的vm_2;vm_2收到後,再用geneve tunnel 回傳response 給在另一個節點上的vm_1。回到一開始的問題,在二個不同的network上的VM要溝通,到底是透過eth1的geneve netwrok, 還是透過 eth2 直接通訊呢? 答案是二個都會用到。