CentOS 7
Sponsored Link

OpenStack Stein : Neutron ネットワークを構成する (FLAT)2019/05/16

 
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-05-16T05:08:14Z                                                    |
| description               |                                                                         |
| dns_domain                | None                                                                    |
| id                        | d1972b24-d8ca-4e18-8c91-5132908badcd                                    |
| ipv4_address_scope        | None                                                                    |
| ipv6_address_scope        | None                                                                    |
| is_default                | False                                                                   |
| is_vlan_transparent       | None                                                                    |
| location                  | Munch({'project': Munch({'domain_name': None, 'domain_id': None, '...}) |
| mtu                       | 1500                                                                    |
| name                      | sharednet1                                                              |
| port_security_enabled     | True                                                                    |
| project_id                | c5e87c9b460e4f16801b4102019c97e6                                        |
| 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-05-16T05:08:14Z                                                    |
+---------------------------+-------------------------------------------------------------------------+

# [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-05-16T05:09:03Z                                                           |
| description       |                                                                                |
| dns_nameservers   | 10.0.0.10                                                                      |
| enable_dhcp       | True                                                                           |
| gateway_ip        | 10.0.0.1                                                                       |
| host_routes       |                                                                                |
| id                | aa2459e8-11ce-4eee-a49a-cb904954f004                                           |
| ip_version        | 4                                                                              |
| ipv6_address_mode | None                                                                           |
| ipv6_ra_mode      | None                                                                           |
| location          | Munch({'project': Munch({'domain_name': None, 'domain_id': None, 'name': ...}) |
| name              | subnet1                                                                        |
| network_id        | d1972b24-d8ca-4e18-8c91-5132908badcd                                           |
| prefix_length     | None                                                                           |
| project_id        | c5e87c9b460e4f16801b4102019c97e6                                               |
| revision_number   | 0                                                                              |
| segment_id        | None                                                                           |
| service_types     |                                                                                |
| subnetpool_id     | None                                                                           |
| tags              |                                                                                |
| updated_at        | 2019-05-16T05:09:03Z                                                           |
+-------------------+--------------------------------------------------------------------------------+

# 設定確認

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

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| d1972b24-d8ca-4e18-8c91-5132908badcd | sharednet1 | aa2459e8-11ce-4eee-a49a-cb904954f004 |
+--------------------------------------+------------+--------------------------------------+
[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 |
+--------------------------------------+---------+--------+
| 0d0bf9ae-9d4c-445f-b2e0-5b322dffa988 | CentOS7 | active |
+--------------------------------------+---------+--------+

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

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

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| d1972b24-d8ca-4e18-8c91-5132908badcd | sharednet1 | aa2459e8-11ce-4eee-a49a-cb904954f004 |
+--------------------------------------+------------+--------------------------------------+

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

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

+-----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field           | Value                                                                                                                                                                                  |
+-----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at      | 2019-05-16T05:11:17Z                                                                                                                                                                   |
| description     | secgroup01                                                                                                                                                                             |
| id              | 448cbb81-75f8-452d-bc88-4e3c9ce8c7d9                                                                                                                                                   |
| location        | Munch({'project': Munch({'domain_name': 'default', 'domain_id': None, 'name': 'hiroshima', 'id': u'caab6ec580994e6481cd104b9d210f3f'}), 'cloud': '', 'region_name': '', 'zone': None}) |
| name            | secgroup01                                                                                                                                                                             |
| project_id      | caab6ec580994e6481cd104b9d210f3f                                                                                                                                                       |
| revision_number | 1                                                                                                                                                                                      |
| rules           | created_at='2019-05-16T05:11:17Z', direction='egress', ethertype='IPv6', id='b98ee0ef-4018-4416-868b-3827a05946ca', updated_at='2019-05-16T05:11:17Z'                                  |
|                 | created_at='2019-05-16T05:11:17Z', direction='egress', ethertype='IPv4', id='d6bbe952-a308-41e9-9b4d-f021e63c0e43', updated_at='2019-05-16T05:11:17Z'                                  |
| tags            | []                                                                                                                                                                                     |
| updated_at      | 2019-05-16T05:11:17Z                                                                                                                                                                   |
+-----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

# インスタンス接続用の 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 | d8:78:b4:66:2a:e3:25:9f:92:bc:36:59:84:0a:64:93 |
| name        | mykey                                           |
| user_id     | b5dd128c2fd744c892ad7d1fb39d21a0                |
+-------------+-------------------------------------------------+

[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   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| a19e0420-8cb7-47a1-bf07-1a0e0569212f | CentOS_7 | ACTIVE | sharednet1=10.0.0.219 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
[4] 起動した仮想マシンインスタンスに SSH 接続できるように、先に作成したセキュリティグループにポート許可の設定を追加します。
# ICMP 許可

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

+-------------------+--------------------------------------------------------------------------------+
| Field             | Value                                                                          |
+-------------------+--------------------------------------------------------------------------------+
| created_at        | 2019-05-16T05:20:20Z                                                           |
| description       |                                                                                |
| direction         | ingress                                                                        |
| ether_type        | IPv4                                                                           |
| id                | af4776ca-6f39-4d26-aed9-06b09d3c3d85                                           |
| location          | Munch({'project': Munch({'domain_name': 'default', 'domain_id': None, 'na...}) |
| name              | None                                                                           |
| port_range_max    | None                                                                           |
| port_range_min    | None                                                                           |
| project_id        | caab6ec580994e6481cd104b9d210f3f                                               |
| protocol          | icmp                                                                           |
| remote_group_id   | None                                                                           |
| remote_ip_prefix  | 0.0.0.0/0                                                                      |
| revision_number   | 0                                                                              |
| security_group_id | 448cbb81-75f8-452d-bc88-4e3c9ce8c7d9                                           |
| tags              | []                                                                             |
| updated_at        | 2019-05-16T05:20:20Z                                                           |
+-------------------+--------------------------------------------------------------------------------+

# SSH 許可

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

+-------------------+--------------------------------------------------------------------------------+
| Field             | Value                                                                          |
+-------------------+--------------------------------------------------------------------------------+
| created_at        | 2019-05-16T05:20:51Z                                                           |
| description       |                                                                                |
| direction         | ingress                                                                        |
| ether_type        | IPv4                                                                           |
| id                | 4c765423-dc8b-447a-b407-351e98e645f5                                           |
| location          | Munch({'project': Munch({'domain_name': 'default', 'domain_id': None, 'na...}) |
| name              | None                                                                           |
| port_range_max    | 22                                                                             |
| port_range_min    | 22                                                                             |
| project_id        | caab6ec580994e6481cd104b9d210f3f                                               |
| protocol          | tcp                                                                            |
| remote_group_id   | None                                                                           |
| remote_ip_prefix  | 0.0.0.0/0                                                                      |
| revision_number   | 0                                                                              |
| security_group_id | 448cbb81-75f8-452d-bc88-4e3c9ce8c7d9                                           |
| tags              | []                                                                             |
| updated_at        | 2019-05-16T05:20:51Z                                                           |
+-------------------+--------------------------------------------------------------------------------+

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

+--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+
| ID                                   | IP Protocol | IP Range  | Port Range | Remote Security Group                | Security Group                       |
+--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+
| 4c765423-dc8b-447a-b407-351e98e645f5 | tcp         | 0.0.0.0/0 | 22:22      | None                                 | 448cbb81-75f8-452d-bc88-4e3c9ce8c7d9 |
| 665074cc-31af-4195-9924-7b2082a4e8db | None        | None      |            | None                                 | f32328f7-b100-4f3a-a3aa-c10b98f24026 |
| 828a02bb-c1c9-4f4a-b8af-6bfb3f76a07f | None        | None      |            | None                                 | f32328f7-b100-4f3a-a3aa-c10b98f24026 |
| aa49bf4a-a63f-4008-9b8f-1f4a9c217ff1 | None        | None      |            | f32328f7-b100-4f3a-a3aa-c10b98f24026 | f32328f7-b100-4f3a-a3aa-c10b98f24026 |
| af4776ca-6f39-4d26-aed9-06b09d3c3d85 | icmp        | 0.0.0.0/0 |            | None                                 | 448cbb81-75f8-452d-bc88-4e3c9ce8c7d9 |
| b98ee0ef-4018-4416-868b-3827a05946ca | None        | None      |            | None                                 | 448cbb81-75f8-452d-bc88-4e3c9ce8c7d9 |
| d6bbe952-a308-41e9-9b4d-f021e63c0e43 | None        | None      |            | None                                 | 448cbb81-75f8-452d-bc88-4e3c9ce8c7d9 |
| ff674b2c-a4be-4f85-abd2-c05c23280ce5 | None        | None      |            | f32328f7-b100-4f3a-a3aa-c10b98f24026 | f32328f7-b100-4f3a-a3aa-c10b98f24026 |
+--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+
[5] インスタンスにログインします。
[cent@dlp ~(keystone)]$
ssh centos@10.0.0.219

The authenticity of host '10.0.0.219 (10.0.0.219)' can't be established.
ECDSA key fingerprint is SHA256:8JIQDmNwua3M1autPC3YjFOpTuP525whYxaWojC9fbw.
ECDSA key fingerprint is MD5:8e:78:d9:bf:0f:25:e4:14:b2:a2:0a:d7:58:cc:f4:66.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.219' (ECDSA) to the list of known hosts.
Last login: Wed May 15 00:33:45 2019
[centos@centos-7 ~]$    
# ログインできた
関連コンテンツ