CentOS 7
Sponsored Link

OpenStack Train : Neutron ネットワークを構成する (FLAT)2019/10/25

 
OpenStack Network Service(Neutron)による仮想ネットワークの構成です。
例として、FLAT タイプのプロバイダーネットワークを構成します。
事前に以下のように Control ノードNetwork ノードCompute ノードの 各 Neutron サービスノードを構築済みであることが前提です。
また、当例では Network ノードと Compute ノードが二つのネットワークインターフェースを持っているものとします。
------------+---------------------------+---------------------------+------------
            |                           |                           |
        eth0|10.0.0.30              eth0|10.0.0.50              eth0|10.0.0.51
+-----------+-----------+   +-----------+-----------+   +-----------+-----------+
|    [ Control Node ]   |   |    [ Network Node ]   |   |    [ Compute Node ]   |
|                       |   |                       |   |                       |
|  MariaDB    RabbitMQ  |   |      Open vSwitch     |   |        Libvirt        |
|  Memcached  httpd     |   |        L2 Agent       |   |     Nova Compute      |
|  Keystone   Glance    |   |        L3 Agent       |   |      Open vSwitch     |
|  Nova API             |   |     Metadata Agent    |   |        L2 Agent       |
|  Neutron Server       |   |                       |   |                       |
|  Metadata Agent       |   |                       |   |                       |
+-----------------------+   +-----------+-----------+   +-----------+-----------+
                                    eth1|(UP with no IP)        eth1|(UP with no IP)

[1] Network ノード および Compute ノードの両方で以下のように設定します。
# ブリッジ追加

[root@network ~]#
ovs-vsctl add-br br-eth1

# 追加したブリッジのポートにeth1を追加

[root@network ~]#
ovs-vsctl add-port br-eth1 eth1

[root@network ~]#
vi /etc/neutron/plugins/ml2/ml2_conf.ini
# 最終行に追記

[ml2_type_flat]
flat_networks = physnet1
[root@network ~]#
vi /etc/neutron/plugins/ml2/openvswitch_agent.ini
# 最終行に追記

[ovs]
bridge_mappings = physnet1:br-eth1
[root@network ~]#
systemctl restart neutron-openvswitch-agent

[2] ネットワークを作成します。作業場所はどこでもよいですが、当例では Control ノード上で作業します。
[root@dlp ~(keystone)]#
projectID=$(openstack project list | grep service | awk '{print $2}')
# [sharednet1] という名称のネットワークを作成

[root@dlp ~(keystone)]#
openstack network create --project $projectID \
--share --provider-network-type flat --provider-physical-network physnet1 sharednet1

Created a new network:
+---------------------------+---------------------------------------------------------------------+
| Field                     | Value                                                               |
+---------------------------+---------------------------------------------------------------------+
| admin_state_up            | UP                                                                  |
| availability_zone_hints   |                                                                     |
| availability_zones        |                                                                     |
| created_at                | 2019-10-25T06:46:54Z                                                |
| description               |                                                                     |
| dns_domain                | None                                                                |
| id                        | 42b7b05f-a9c8-4231-aed7-aeeb73f13648                                |
| ipv4_address_scope        | None                                                                |
| ipv6_address_scope        | None                                                                |
| is_default                | False                                                               |
| is_vlan_transparent       | None                                                                |
| location                  | cloud='', project.domain_id=, project.domain_name=, project.id='2...|
| mtu                       | 1500                                                                |
| name                      | sharednet1                                                          |
| port_security_enabled     | True                                                                |
| project_id                | 2b9c4eda462e40a4a3d03b0a38f12bf1                                    |
| provider:network_type     | flat                                                                |
| provider:physical_network | physnet1                                                            |
| provider:segmentation_id  | None                                                                |
| qos_policy_id             | None                                                                |
| revision_number           | 1                                                                   |
| router:external           | Internal                                                            |
| segments                  | None                                                                |
| shared                    | True                                                                |
| status                    | ACTIVE                                                              |
| subnets                   |                                                                     |
| tags                      |                                                                     |
| updated_at                | 2019-10-25T06:46:54Z                                                |
+---------------------------+---------------------------------------------------------------------+

# [sharednet1] に [10.0.0.0/24] のサブネットを作成

[root@dlp ~(keystone)]#
openstack subnet create subnet1 --network sharednet1 \
--project $projectID --subnet-range 10.0.0.0/24 \
--allocation-pool start=10.0.0.200,end=10.0.0.254 \
--gateway 10.0.0.1 --dns-nameserver 10.0.0.10

Created a new subnet:
+-------------------+-----------------------------------------------------------------------------+
| Field             | Value                                                                       |
+-------------------+-----------------------------------------------------------------------------+
| allocation_pools  | 10.0.0.200-10.0.0.254                                                       |
| cidr              | 10.0.0.0/24                                                                 |
| created_at        | 2019-10-25T06:47:31Z                                                        |
| description       |                                                                             |
| dns_nameservers   | 10.0.0.10                                                                   |
| enable_dhcp       | True                                                                        |
| gateway_ip        | 10.0.0.1                                                                    |
| host_routes       |                                                                             |
| id                | 2ec3f6fc-233a-4e5d-9628-a8764366ea57                                        |
| ip_version        | 4                                                                           |
| ipv6_address_mode | None                                                                        |
| ipv6_ra_mode      | None                                                                        |
| location          | cloud='', project.domain_id=, project.domain_name=, project.id='2b9c4eda4...|
| name              | subnet1                                                                     |
| network_id        | 42b7b05f-a9c8-4231-aed7-aeeb73f13648                                        |
| prefix_length     | None                                                                        |
| project_id        | 2b9c4eda462e40a4a3d03b0a38f12bf1                                            |
| revision_number   | 0                                                                           |
| segment_id        | None                                                                        |
| service_types     |                                                                             |
| subnetpool_id     | None                                                                        |
| tags              |                                                                             |
| updated_at        | 2019-10-25T06:47:31Z                                                        |
+-------------------+-----------------------------------------------------------------------------+

# 設定確認

[root@dlp ~(keystone)]#
openstack network list

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| 42b7b05f-a9c8-4231-aed7-aeeb73f13648 | sharednet1 | 2ec3f6fc-233a-4e5d-9628-a8764366ea57 |
+--------------------------------------+------------+--------------------------------------+
[3] 任意のユーザーでログインし、作成したネットワークをインスタンスに紐付けてインスタンスを作成・起動します。
# 利用可能な flavor 確認

[cent@dlp ~(keystone)]$
openstack flavor list

+----+----------+------+------+-----------+-------+-----------+
| ID | Name     |  RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+----------+------+------+-----------+-------+-----------+
| 0  | m1.small | 2048 |   10 |         0 |     1 | True      |
+----+----------+------+------+-----------+-------+-----------+

# 利用可能なイメージ確認

[cent@dlp ~(keystone)]$
openstack image list

+--------------------------------------+---------+--------+
| ID                                   | Name    | Status |
+--------------------------------------+---------+--------+
| c742c8ed-9d0f-4555-9844-7f063a0b585f | CentOS7 | active |
+--------------------------------------+---------+--------+

# 利用可能なネットワーク確認

[cent@dlp ~(keystone)]$
openstack network list

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| 42b7b05f-a9c8-4231-aed7-aeeb73f13648 | sharednet1 | 2ec3f6fc-233a-4e5d-9628-a8764366ea57 |
+--------------------------------------+------------+--------------------------------------+

# インスタンス用のセキュリティグループを作成

[cent@dlp ~(keystone)]$
openstack security group create secgroup01

+-----------------+-------------------------------------------------------------------------------+
| Field           | Value                                                                         |
+-----------------+-------------------------------------------------------------------------------+
| created_at      | 2019-10-25T06:50:07Z                                                          |
| description     | secgroup01                                                                    |
| id              | d4563618-ed32-44e2-8753-904b2c88994c                                          |
| location        | cloud='', project.domain_id=, project.domain_name='default', project.id='67...|
| name            | secgroup01                                                                    |
| project_id      | 67b2b71cee384d69939e6b3963e0b2db                                              |
| revision_number | 1                                                                             |
| rules           | created_at='2019-10-25T06:50:07Z', direction='egress', ethertype='IPv4', id...|
|                 | created_at='2019-10-25T06:50:07Z', direction='egress', ethertype='IPv6', id...|
| tags            | []                                                                            |
| updated_at      | 2019-10-25T06:50:07Z                                                          |
+-----------------+-------------------------------------------------------------------------------+

# インスタンス接続用の SSH キーペア作成

[cent@dlp ~(keystone)]$
ssh-keygen -q -N ""

Enter file in which to save the key (/home/cent/.ssh/id_rsa):
# 公開鍵登録

[cent@dlp ~(keystone)]$
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| fingerprint | 02:d5:c2:25:0e:06:34:a8:06:a2:2b:42:7e:eb:3d:d3 |
| name        | mykey                                           |
| user_id     | 14ad73cc98744e01a51886e13d541013                |
+-------------+-------------------------------------------------+

[cent@dlp ~(keystone)]$
netID=$(openstack network list | grep sharednet1 | awk '{ print $2 }')

[cent@dlp ~(keystone)]$
openstack server create --flavor m1.small --image CentOS7 --security-group secgroup01 --nic net-id=$netID --key-name mykey CentOS_7
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 1eea25f6-9744-4e5f-b918-2e705643abbf | CentOS_7 | ACTIVE | sharednet1=10.0.0.217 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
[4] 起動した仮想マシンインスタンスに SSH 接続できるように、先に作成したセキュリティグループにポート許可の設定を追加します。
# ICMP 許可

[cent@dlp ~(keystone)]$
openstack security group rule create --protocol icmp --ingress secgroup01

+-------------------+-----------------------------------------------------------------------------+
| Field             | Value                                                                       |
+-------------------+-----------------------------------------------------------------------------+
| created_at        | 2019-10-25T06:52:03Z                                                        |
| description       |                                                                             |
| direction         | ingress                                                                     |
| ether_type        | IPv4                                                                        |
| id                | c6b50434-bf8f-4270-841f-49994e38cfb6                                        |
| location          | cloud='', project.domain_id=, project.domain_name='default', project.id='...|
| name              | None                                                                        |
| port_range_max    | None                                                                        |
| port_range_min    | None                                                                        |
| project_id        | 67b2b71cee384d69939e6b3963e0b2db                                            |
| protocol          | icmp                                                                        |
| remote_group_id   | None                                                                        |
| remote_ip_prefix  | 0.0.0.0/0                                                                   |
| revision_number   | 0                                                                           |
| security_group_id | d4563618-ed32-44e2-8753-904b2c88994c                                        |
| tags              | []                                                                          |
| updated_at        | 2019-10-25T06:52:03Z                                                        |
+-------------------+-----------------------------------------------------------------------------+

# SSH 許可

[cent@dlp ~(keystone)]$
openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01

+-------------------+-----------------------------------------------------------------------------+
| Field             | Value                                                                       |
+-------------------+-----------------------------------------------------------------------------+
| created_at        | 2019-10-25T06:52:29Z                                                        |
| description       |                                                                             |
| direction         | ingress                                                                     |
| ether_type        | IPv4                                                                        |
| id                | b2bb1067-7cca-49fc-916a-4bd6372fb639                                        |
| location          | cloud='', project.domain_id=, project.domain_name='default', project.id='...|
| name              | None                                                                        |
| port_range_max    | 22                                                                          |
| port_range_min    | 22                                                                          |
| project_id        | 67b2b71cee384d69939e6b3963e0b2db                                            |
| protocol          | tcp                                                                         |
| remote_group_id   | None                                                                        |
| remote_ip_prefix  | 0.0.0.0/0                                                                   |
| revision_number   | 0                                                                           |
| security_group_id | d4563618-ed32-44e2-8753-904b2c88994c                                        |
| tags              | []                                                                          |
| updated_at        | 2019-10-25T06:52:29Z                                                        |
+-------------------+-----------------------------------------------------------------------------+

[cent@dlp ~(keystone)]$
openstack security group rule list

+--------------------------------------+-------------+-----------+-----------+------------+--------------------------------------+--------------------------------------+
| ID                                   | IP Protocol | Ethertype | IP Range  | Port Range | Remote Security Group                | Security Group                       |
+--------------------------------------+-------------+-----------+-----------+------------+--------------------------------------+--------------------------------------+
| 3fd92ecf-86dd-48a5-9d64-2a0c75744fc0 | None        | IPv4      | 0.0.0.0/0 |            | None                                 | d4563618-ed32-44e2-8753-904b2c88994c |
| 46c65b08-09a9-44e0-904d-934a91220ded | None        | IPv6      | ::/0      |            | e771f702-01e1-4263-95d0-e5818ea24c2c | e771f702-01e1-4263-95d0-e5818ea24c2c |
| 5a4b12f0-f1c2-43bb-b0bc-88a5e3fabafd | None        | IPv6      | ::/0      |            | None                                 | e771f702-01e1-4263-95d0-e5818ea24c2c |
| 76dac696-89a0-44e0-8144-d53c740b9746 | None        | IPv4      | 0.0.0.0/0 |            | None                                 | e771f702-01e1-4263-95d0-e5818ea24c2c |
| b2bb1067-7cca-49fc-916a-4bd6372fb639 | tcp         | IPv4      | 0.0.0.0/0 | 22:22      | None                                 | d4563618-ed32-44e2-8753-904b2c88994c |
| c6b50434-bf8f-4270-841f-49994e38cfb6 | icmp        | IPv4      | 0.0.0.0/0 |            | None                                 | d4563618-ed32-44e2-8753-904b2c88994c |
| ead55e6f-e2dd-4b21-862c-c2bcb6a724e9 | None        | IPv4      | 0.0.0.0/0 |            | e771f702-01e1-4263-95d0-e5818ea24c2c | e771f702-01e1-4263-95d0-e5818ea24c2c |
| f8282ac9-cd7f-4947-bd58-c2bb50d36b2e | None        | IPv6      | ::/0      |            | None                                 | d4563618-ed32-44e2-8753-904b2c88994c |
+--------------------------------------+-------------+-----------+-----------+------------+--------------------------------------+--------------------------------------+
[5] インスタンスにログインします。
[cent@dlp ~(keystone)]$
ssh centos@10.0.0.217

The authenticity of host '10.0.0.217 (10.0.0.217)' can't be established.
ECDSA key fingerprint is SHA256:8Mxh+vSFka75QgGaBO/RGWYnFNAOtdgw9q3OQv+QaJw.
ECDSA key fingerprint is MD5:7c:f3:35:bf:ab:01:d7:d0:98:a3:2b:2d:04:11:74:56.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.217' (ECDSA) to the list of known hosts.
[centos@centos-7 ~]$    
# ログインできた
関連コンテンツ