Ubuntu 16.04
Sponsored Link

OpenStack Mitaka (三鷹) : Neutron ネットワーク構成(FLAT)
2016/05/28
 
OpenStack Network Service(Neutron)による仮想ネットワークの構成です。
例として、FLAT タイプのプロバイダーネットワークを構成します。
Control ノードNetwork ノードCompute ノードはそれぞれ事前に基本設定をしておいてください。
また、Network ノードと Compute ノードはネットワークインターフェースを二つ持っていることを前提とします。

                                        |
  +-------------+                  +----+----+
  | Name Server |                  | Gateway |
  +------+------+                  +----+----+
         |10.0.0.10                     |10.0.0.1
         |                              |
         +------------+-----------------+------------------+
         |            |                 |                  |     10.0.0.200-10.0.0.250
     eth0|10.0.0.30   |             eth0|10.0.0.50         |         +-----------------+
+--------+---------+  |     +-----------+----------+       |     +---| Virtual Machine |
| [ Control Node ] |  |     |   [ Network Node ]   |       |     |   +-----------------+
|     Keystone     |  |     |       DHCP Agent     |       |     |   +-----------------+
|      Glance      |  |     |       L3 Agent       |eth1   |     |---| Virtual Machine |
|     Nova API     |  |     |       L2 Agent       |       |     |   +-----------------+
|  Neutron Server  |  |     |    Metadata Agent    |       |     |   +-----------------+
+------------------+  |     +----------------------+       +-----+---| Virtual Machine |
                      |                                          |   +-----------------+
                      |     +----------------------+             |   +-----------------+
                      | eth0|   [ Compute Node ]   |             |---| Virtual Machine |
                      +-----|     Nova Compute     |eth1         |   +-----------------+
                   10.0.0.51|       L2 Agent       |             |   +-----------------+
                            +----------------------+             +---| Virtual Machine |
                                                                     +-----------------+

[1] Network ノード、および Compute ノードの両方で以下のように設定します。
root@network:~#
vi /etc/neutron/plugins/ml2/ml2_conf.ini
# 152行目:追記

[ml2_type_flat]
flat_networks = physnet1
root@network:~#
vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini
# 128行目:追記

[linux_bridge]
physical_interface_mappings = physnet1:eth1
# 171行目:コメント解除して変更

enable_vxlan =
false
root@network:~#
systemctl restart neutron-linuxbridge-agent

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

root@dlp ~(keystone)#
neutron net-create --tenant-id $tenantID sharednet1 \
--shared --provider:network_type flat --provider:physical_network physnet1

Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2016-05-29T16:01:56                  |
| description               |                                      |
| id                        | 8579942d-402f-403a-9713-be18b9bc546a |
| ipv4_address_scope        |                                      |
| ipv6_address_scope        |                                      |
| mtu                       | 1500                                 |
| name                      | sharednet1                           |
| port_security_enabled     | True                                 |
| provider:network_type     | flat                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  |                                      |
| router:external           | False                                |
| shared                    | True                                 |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| tenant_id                 | 004097e8a2da45e6a68f6474b5bd7207     |
| updated_at                | 2016-05-29T16:01:56                  |
+---------------------------+--------------------------------------+

# 作成した「sharednet1」に「10.0.0.0/24」のサブネットを作成

root@dlp ~(keystone)#
neutron subnet-create \
--tenant-id $tenantID --gateway 10.0.0.1 --dns-nameserver 10.0.0.1 \
--allocation-pool start=10.0.0.200,end=10.0.0.250 sharednet1 10.0.0.0/24

Created a new subnet:
+-------------------+----------------------------------------------+
| Field             | Value                                        |
+-------------------+----------------------------------------------+
| allocation_pools  | {"start": "10.0.0.200", "end": "10.0.0.250"} |
| cidr              | 10.0.0.0/24                                  |
| created_at        | 2016-05-29T16:02:12                          |
| description       |                                              |
| dns_nameservers   | 10.0.0.1                                     |
| enable_dhcp       | True                                         |
| gateway_ip        | 10.0.0.1                                     |
| host_routes       |                                              |
| id                | 24723118-8f1e-4530-aca7-b1dca4b6995d         |
| ip_version        | 4                                            |
| ipv6_address_mode |                                              |
| ipv6_ra_mode      |                                              |
| name              |                                              |
| network_id        | 8579942d-402f-403a-9713-be18b9bc546a         |
| subnetpool_id     |                                              |
| tenant_id         | 004097e8a2da45e6a68f6474b5bd7207             |
| updated_at        | 2016-05-29T16:02:12                          |
+-------------------+----------------------------------------------+

# 設定確認

root@dlp ~(keystone)#
neutron net-list

+--------------------------------------+------------+--------------------------------------------------+
| id                                   | name       | subnets                                          |
+--------------------------------------+------------+--------------------------------------------------+
| 8579942d-402f-403a-9713-be18b9bc546a | sharednet1 | 24723118-8f1e-4530-aca7-b1dca4b6995d 10.0.0.0/24 |
+--------------------------------------+------------+--------------------------------------------------+
[3] 作成したネットワークをインスタンスに紐付けてインスタンスを作成・起動します。
root@dlp ~(keystone)#
netID=`neutron net-list | grep sharednet1 | awk '{print $2}'`

root@dlp ~(keystone)#
nova image-list

+--------------------------------------+------------+--------+--------+
| ID                                   | Name       | Status | Server |
+--------------------------------------+------------+--------+--------+
| d7e743c4-c1f5-458b-abc5-2d9176c07a93 | Ubuntu1604 | ACTIVE |        |
+--------------------------------------+------------+--------+--------+

root@dlp ~(keystone)#
nova boot --flavor 2 --image Ubuntu1604 --security-groups default --nic net-id=$netID Ubuntu_1604
root@dlp ~(keystone)#
nova list

+--------------------------------------+-------------+--------+------------+-------------+-----------------------+
| ID                                   | Name        | Status | Task State | Power State | Networks              |
+--------------------------------------+-------------+--------+------------+-------------+-----------------------+
| c600c707-59b2-4377-a2a0-830a13713b83 | Ubuntu_1604 | ACTIVE | -          | Running     | sharednet1=10.0.0.201 |
+--------------------------------------+-------------+--------+------------+-------------+-----------------------+
[4] 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。
# ICMP 許可

root@dlp ~(keystone)#
neutron security-group-rule-create --direction ingress --protocol icmp default

Created a new security_group_rule:
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| description       |                                      |
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| id                | 67699149-a85e-4334-91cc-48865147b7fd |
| port_range_max    |                                      |
| port_range_min    |                                      |
| protocol          | icmp                                 |
| remote_group_id   |                                      |
| remote_ip_prefix  |                                      |
| security_group_id | 04d72bc2-a73e-4803-b93a-0e22e69bae9f |
| tenant_id         | 61bb62a97e394b8db8f95aa05a678771     |
+-------------------+--------------------------------------+

# SSH 許可

root@dlp ~(keystone)#
neutron security-group-rule-create --direction ingress --protocol tcp --port_range_min 22 --port_range_max 22 default

Created a new security_group_rule:
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| description       |                                      |
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| id                | 492eb253-3314-420a-98ee-3d652aecbe86 |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| protocol          | tcp                                  |
| remote_group_id   |                                      |
| remote_ip_prefix  |                                      |
| security_group_id | 04d72bc2-a73e-4803-b93a-0e22e69bae9f |
| tenant_id         | 61bb62a97e394b8db8f95aa05a678771     |
+-------------------+--------------------------------------+

root@dlp ~(keystone)#
neutron security-group-rule-list

+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
| id                                   | security_group | direction | ethertype | port/protocol | remote          |
+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
| 492eb253-3314-420a-98ee-3d652aecbe86 | default        | ingress   | IPv4      | 22/tcp        | any             |
| 67699149-a85e-4334-91cc-48865147b7fd | default        | ingress   | IPv4      | icmp          | any             |
| 6976acfc-c439-44f1-b8a1-be9b917ebef2 | default        | ingress   | IPv4      | any           | default (group) |
| 710640ac-f8ac-4d29-b708-861476758f83 | default        | ingress   | IPv6      | any           | default (group) |
| 7ab15e66-e89b-4c72-b7b9-a7a216d14a81 | default        | egress    | IPv4      | any           | any             |
| 825efe36-22a0-4037-9cb9-3622b798fea0 | default        | egress    | IPv6      | any           | any             |
+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
[5] インスタンスにログインします。
root@dlp ~(keystone)#
ssh xerus@10.0.0.201

The authenticity of host '10.0.0.201 (10.0.0.201)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.201' (ECDSA) to the list of known hosts.
xerus@10.0.0.201's password:
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-22-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

0 packages can be updated.
0 updates are security updates.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

xerus@ubuntu:~$    
# ログインできた
関連コンテンツ
 
Tweet