0%

Openstack学习 —— 创建网络及子网

搭建完测试环境后,拉起来个虚拟机看看,操作步骤

创建网络 - 创建虚拟机实例 - 创建路由器

本篇主要关注创建网络时主机上的行为

注:openstack CLI以及ovs命令行输出信息较多,仅提取关键信息

创建网络及子网

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ openstack network create net1
+---------------------------+-------------------------------------
| Field | Value
+---------------------------+-------------------------------------
| id | 2caecd1e-bda7-4a4e-baec-3d192f52aa3b
| provider:network_type | vxlan
| provider:segmentation_id | 15
+---------------------------+-------------------------------------
$ openstack subnet create --network net1 --subnet-range 200.0.0.0/24 sub1
+-------------------+-------------------------------------
| Field | Value
+-------------------+-------------------------------------
| allocation_pools | 200.0.0.2-200.0.0.254
| cidr | 200.0.0.0/24
| gateway_ip | 200.0.0.1
| id | 5875f007-7b0f-45af-b78f-82527e5d9a90
| network_id | 2caecd1e-bda7-4a4e-baec-3d192f52aa3b
+-------------------+-------------------------------------

发生了什么?

1. openstack

net1的id为2caecd1e-bda7-4a4e-baec-3d192f52aa3b

sub1的id为5875f007-7b0f-45af-b78f-82527e5d9a90

1
2
3
4
5
6
$ openstack port list
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------+--------+
| ID | Name | MAC Address | Fixed IP Addresses | Status |
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------+--------+
| 17a89323-fd0a-44cc-a525-fcf8d2efb836 | | fa:16:3e:f6:db:c9 | ip_address='200.0.0.2', subnet_id='5875f007-7b0f-45af-b78f-82527e5d9a90' | ACTIVE |
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------+--------+

sub1下创建了一个port

  • ID:17a89323-fd0a-44cc-a525-fcf8d2efb836
  • IP:200.0.0.2

2. ovs

1
2
3
4
5
6
7
8
9
$ ovs-vsctl show
...
Bridge br-int
...
Port "tap17a89323-fd"
tag: 1
Interface "tap17a89323-fd"
type: internal
...

ovs在br-int下创建了一个port tap17a89323-fd, tag为 1

3. Linux namespace

1
2
3
4
5
6
7
8
9
10
11
12
$ ip netns
qdhcp-2caecd1e-bda7-4a4e-baec-3d192f52aa3b (id: 0)
$ ip netns exec qdhcp-2caecd1e-bda7-4a4e-baec-3d192f52aa3b ifconfig
...
tap17a89323-fd: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450
inet 169.254.169.254 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::f816:3eff:fef6:dbc9 prefixlen 64 scopeid 0x20<link>
ether fa:16:3e:f6:db:c9 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5 bytes 446 (446.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

创建了一个qdhcp-2caecd1e-bda7-4a4e-baec-3d192f52aa3b的namespace

ovs的br-int上的 tap17a89323-fd的port被放在了这个namespace中。

留意一下接口的IP地址及MAC地址

综上

openstack上创建network并创建一个子网之后,体现为:

  1. 创建了一个dhcp的namespace
  2. ovs在br-int上创建了dhcp的port,并将其置于dhcp的namespace中

Create Network