CentOS 7
Sponsored Link

OpenStack Newton : Neutron ネットワーク構成 (VLAN)2016/10/23

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

                                        |
  +-------------+                  +----+----+
  | Name Server |                  | Gateway |
  +------+------+                  +----+----+
         |10.0.0.10                     |10.0.0.1
         |                              |
         +------------+-----------------+------------------------+
         |            |                 |                        |
         |            |                 |              10.0.0.200-10.0.0.254
     eth0|10.0.0.30   |        10.0.0.50| eth0          +--------+-------+
+--------+---------+  |     +-----------+----------+    | Virtual Router |
| [ Control Node ] |  |     |   [ Network Node ]   |    +--------+-------+
|     Keystone     |  |     |       DHCP Agent     |       192.168.100.1
|      Glance      |  | eth2|       L3 Agent       |eth1         |            192.168.100.0/24
|     Nova API     |  |     |       L2 Agent       |             |           +-----------------+
|  Neutron Server  |  |     |    Metadata Agent    |             |       +---| Virtual Machine |
+------------------+  |     +----------------------+             |       |   +-----------------+
                      |                                          |       |   +-----------------+
                      |     +----------------------+             +-------+---| Virtual Machine |
                      | eth0|   [ Compute Node ]   |eth1                 |   +-----------------+
                      +-----|     Nova Compute     |                     |   +-----------------+
                   10.0.0.51|       L2 Agent       |                     |---| Virtual Machine |
                            +----------------------+                     |   +-----------------+
                                                                         |   +-----------------+
                                                                         +---| Virtual Machine |
                                                                             +-----------------+
[1] Control ノードで以下のように設定変更します。
[root@dlp ~(keystone)]#
vi /etc/neutron/plugins/ml2/ml2_conf.ini
# 103行目:tenant_network_types に値を追記

[ml2]
type_drivers = flat,vlan,gre,vxlan
tenant_network_types =
vlan
# 195行目:追記

[ml2_type_vlan]
network_vlan_ranges = physnet1:1000:2999
[root@dlp ~(keystone)]#
systemctl restart neutron-server

[2] 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
# 103行目:tenant_network_types に値を追記

[ml2]
type_drivers = flat,vlan,gre,vxlan
tenant_network_types =
vlan
# 195行目:追記

[ml2_type_vlan]
network_vlan_ranges = physnet1:1000:2999
[root@network ~]#
vi /etc/neutron/plugins/ml2/openvswitch_agent.ini
# 181行目:追記

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

[3] Network ノードで外部接続用のブリッジの作成と定義をしておきます。
[root@network ~]#
ovs-vsctl add-br br-ext

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

[root@network ~]#
vi /etc/neutron/l3_agent.ini
# 98行目:追記

external_network_bridge =
br-ext
[root@network ~]#
systemctl restart neutron-l3-agent

[4] 仮想ルータを作成しておきます。作業場所はどこでもよいですが、ここでは Control ノード上で作業します。
# 仮想ルーター作成

[root@dlp ~(keystone)]#
neutron router-create router01

Created a new router:
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | True                                 |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| created_at              | 2016-10-25T08:00:46Z                 |
| description             |                                      |
| distributed             | False                                |
| external_gateway_info   |                                      |
| flavor_id               |                                      |
| ha                      | False                                |
| id                      | 0d8e7dfe-ee7a-4761-a7c3-dfbc5bd6d417 |
| name                    | router01                             |
| project_id              | 150e205a8791426e8028a94699fb8848     |
| revision_number         | 2                                    |
| routes                  |                                      |
| status                  | ACTIVE                               |
| tenant_id               | 150e205a8791426e8028a94699fb8848     |
| updated_at              | 2016-10-25T08:00:46Z                 |
+-------------------------+--------------------------------------+

[root@dlp ~(keystone)]#
Router_ID=`neutron router-list | grep router01 | awk '{ print $2 }'`

[5] 内部用のネットワークを作成し、仮想ルーターに関連付けます。
# 内部用ネットワーク作成

[root@dlp ~(keystone)]#
neutron net-create int_net

Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2016-10-25T08:01:10Z                 |
| description               |                                      |
| id                        | cb956039-19e4-49d2-b2d3-6a1327c7b691 |
| ipv4_address_scope        |                                      |
| ipv6_address_scope        |                                      |
| mtu                       | 1500                                 |
| name                      | int_net                              |
| port_security_enabled     | True                                 |
| project_id                | 150e205a8791426e8028a94699fb8848     |
| provider:network_type     | vlan                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | 1066                                 |
| revision_number           | 3                                    |
| router:external           | False                                |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| tenant_id                 | 150e205a8791426e8028a94699fb8848     |
| updated_at                | 2016-10-25T08:01:11Z                 |
+---------------------------+--------------------------------------+

# 内部用ネットワークにサブネット作成

[root@dlp ~(keystone)]#
neutron subnet-create \
--gateway 192.168.100.1 --dns-nameserver 10.0.0.1 int_net 192.168.100.0/24

Created a new subnet:
+-------------------+------------------------------------------------------+
| Field             | Value                                                |
+-------------------+------------------------------------------------------+
| allocation_pools  | {"start": "192.168.100.2", "end": "192.168.100.254"} |
| cidr              | 192.168.100.0/24                                     |
| created_at        | 2016-10-25T08:02:16Z                                 |
| description       |                                                      |
| dns_nameservers   | 10.0.0.1                                             |
| enable_dhcp       | True                                                 |
| gateway_ip        | 192.168.100.1                                        |
| host_routes       |                                                      |
| id                | 303fbd3b-eb58-48e7-9508-f74a55e0f3be                 |
| ip_version        | 4                                                    |
| ipv6_address_mode |                                                      |
| ipv6_ra_mode      |                                                      |
| name              |                                                      |
| network_id        | cb956039-19e4-49d2-b2d3-6a1327c7b691                 |
| project_id        | 150e205a8791426e8028a94699fb8848                     |
| revision_number   | 2                                                    |
| service_types     |                                                      |
| subnetpool_id     |                                                      |
| tenant_id         | 150e205a8791426e8028a94699fb8848                     |
| updated_at        | 2016-10-25T08:02:17Z                                 |
+-------------------+------------------------------------------------------+

[root@dlp ~(keystone)]#
Int_Subnet_ID=`neutron net-list | grep int_net | awk '{ print $6 }'`
# 仮想ルーターに内部ネットワークを設定

[root@dlp ~(keystone)]#
neutron router-interface-add $Router_ID $Int_Subnet_ID

Added interface 77dc7a96-a742-403a-9549-70a6d5167561 to router 0d8e7dfe-ee7a-4761-a7c3-dfbc5bd6d417.
[6] 外部接続用のネットワークを作成し、仮想ルーターに関連付けます。
# 外部用ネットワーク作成

[root@dlp ~(keystone)]#
neutron net-create ext_net --router:external

Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2016-10-25T08:02:58Z                 |
| description               |                                      |
| id                        | 57841132-2c12-4a8b-b29f-2249eba54471 |
| ipv4_address_scope        |                                      |
| ipv6_address_scope        |                                      |
| is_default                | False                                |
| mtu                       | 1500                                 |
| name                      | ext_net                              |
| port_security_enabled     | True                                 |
| project_id                | 150e205a8791426e8028a94699fb8848     |
| provider:network_type     | vlan                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | 1012                                 |
| revision_number           | 3                                    |
| router:external           | True                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| tenant_id                 | 150e205a8791426e8028a94699fb8848     |
| updated_at                | 2016-10-25T08:02:58Z                 |
+---------------------------+--------------------------------------+

# 外部用ネットワークにサブネット作成

[root@dlp ~(keystone)]#
neutron subnet-create ext_net \
--allocation-pool start=10.0.0.200,end=10.0.0.254 \
--gateway 10.0.0.1 --dns-nameserver 10.0.0.1 10.0.0.0/24 --disable-dhcp

Created a new subnet:
+-------------------+----------------------------------------------+
| Field             | Value                                        |
+-------------------+----------------------------------------------+
| allocation_pools  | {"start": "10.0.0.200", "end": "10.0.0.254"} |
| cidr              | 10.0.0.0/24                                  |
| created_at        | 2016-10-25T08:04:04Z                         |
| description       |                                              |
| dns_nameservers   | 10.0.0.1                                     |
| enable_dhcp       | False                                        |
| gateway_ip        | 10.0.0.1                                     |
| host_routes       |                                              |
| id                | ea9dfc41-16e9-4f6b-8cd0-6024c3299488         |
| ip_version        | 4                                            |
| ipv6_address_mode |                                              |
| ipv6_ra_mode      |                                              |
| name              |                                              |
| network_id        | 57841132-2c12-4a8b-b29f-2249eba54471         |
| project_id        | 150e205a8791426e8028a94699fb8848             |
| revision_number   | 2                                            |
| service_types     |                                              |
| subnetpool_id     |                                              |
| tenant_id         | 150e205a8791426e8028a94699fb8848             |
| updated_at        | 2016-10-25T08:04:04Z                         |
+-------------------+----------------------------------------------+

[root@dlp ~(keystone)]#
Ext_Net_ID=`neutron net-list | grep ext_net | awk '{ print $2 }'`

# 仮想ルーターにゲートウェイを設定

[root@dlp ~(keystone)]#
neutron router-gateway-set $Router_ID $Ext_Net_ID

Set gateway for router 0d8e7dfe-ee7a-4761-a7c3-dfbc5bd6d417
[7] 内部ネットワークを関連付けた仮想マシンインスタンスを作成して起動します。
[root@dlp ~(keystone)]#
Int_Net_ID=`neutron net-list | grep int_net | awk '{ print $2 }'`

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

+--------------------------------------+---------+--------+
| ID                                   | Name    | Status |
+--------------------------------------+---------+--------+
| 0f695de0-2bf6-4a51-93ea-0c87ac6a3d07 | CentOS7 | active |
+--------------------------------------+---------+--------+

[root@dlp ~(keystone)]#
openstack server create --flavor m1.small --image CentOS7 --security-group default --nic net-id=$Int_Net_ID CentOS_7

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

+-----------+----------+--------+------------------------+------------+
| ID        | Name     | Status | Networks               | Image Name |
+-----------+----------+--------+------------------------+------------+
| e5a31503- | CentOS_7 | ACTIVE | int_net=192.168.100.11 | CentOS7    |
+-----------+----------+--------+------------------------+------------+
[8] 作成した仮想マシンインスタンスにフローティングIPを割り当てます。
[root@dlp ~(keystone)]#
neutron floatingip-create ext_net

Created a new floatingip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2016-10-25T08:07:21Z                 |
| description         |                                      |
| fixed_ip_address    |                                      |
| floating_ip_address | 10.0.0.200                           |
| floating_network_id | 57841132-2c12-4a8b-b29f-2249eba54471 |
| id                  | 79a5e6b0-5ffd-42d3-a13c-f27b35ca470c |
| port_id             |                                      |
| project_id          | 150e205a8791426e8028a94699fb8848     |
| revision_number     | 1                                    |
| router_id           |                                      |
| status              | DOWN                                 |
| tenant_id           | 150e205a8791426e8028a94699fb8848     |
| updated_at          | 2016-10-25T08:07:21Z                 |
+---------------------+--------------------------------------+

[root@dlp ~(keystone)]#
Device_ID=`openstack server list | grep CentOS_7 | awk '{ print $2 }'`

[root@dlp ~(keystone)]#
Port_ID=`neutron port-list -- --device_id $Device_ID | grep 192.168.100.11 | awk '{ print $2 }'`

[root@dlp ~(keystone)]#
Floating_ID=`neutron floatingip-list | grep 10.0.0.200 | awk '{ print $2 }'`

[root@dlp ~(keystone)]#
neutron floatingip-associate $Floating_ID $Port_ID

Associated floating IP 79a5e6b0-5ffd-42d3-a13c-f27b35ca470c
# 設定確認

[root@dlp ~(keystone)]#
neutron floatingip-show $Floating_ID

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2016-10-25T08:07:21Z                 |
| description         |                                      |
| fixed_ip_address    | 192.168.100.11                       |
| floating_ip_address | 10.0.0.200                           |
| floating_network_id | 57841132-2c12-4a8b-b29f-2249eba54471 |
| id                  | 79a5e6b0-5ffd-42d3-a13c-f27b35ca470c |
| port_id             | e2897c95-f3c0-402b-9a2c-1f53d2cfadd0 |
| project_id          | 150e205a8791426e8028a94699fb8848     |
| revision_number     | 2                                    |
| router_id           | 0d8e7dfe-ee7a-4761-a7c3-dfbc5bd6d417 |
| status              | ACTIVE                               |
| tenant_id           | 150e205a8791426e8028a94699fb8848     |
| updated_at          | 2016-10-25T08:09:29Z                 |
+---------------------+--------------------------------------+
[9] 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。
# ICMP 許可

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

Created a new security_group_rule:
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2016-10-25T05:43:31Z                 |
| description       |                                      |
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| id                | bcb97399-f401-4c20-b7db-c3c25fc816b4 |
| port_range_max    |                                      |
| port_range_min    |                                      |
| project_id        | 150e205a8791426e8028a94699fb8848     |
| protocol          | icmp                                 |
| remote_group_id   |                                      |
| remote_ip_prefix  |                                      |
| revision_number   | 1                                    |
| security_group_id | 572bb509-9c34-44cf-ab38-408e5b9cddb8 |
| tenant_id         | 150e205a8791426e8028a94699fb8848     |
| updated_at        | 2016-10-25T05:43:31Z                 |
+-------------------+--------------------------------------+

# 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                                |
+-------------------+--------------------------------------+
| created_at        | 2016-10-25T05:43:48Z                 |
| description       |                                      |
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| id                | 5aae60db-71e2-4b7e-9eda-bd556dbed8aa |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| project_id        | 150e205a8791426e8028a94699fb8848     |
| protocol          | tcp                                  |
| remote_group_id   |                                      |
| remote_ip_prefix  |                                      |
| revision_number   | 1                                    |
| security_group_id | 572bb509-9c34-44cf-ab38-408e5b9cddb8 |
| tenant_id         | 150e205a8791426e8028a94699fb8848     |
| updated_at        | 2016-10-25T05:43:48Z                 |
+-------------------+--------------------------------------+

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

+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
| id                                   | security_group | direction | ethertype | port/protocol | remote          |
+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
| 1867284b-45e6-4c64-95f7-408c7c00a82f | default        | egress    | IPv4      | any           | any             |
| 5aae60db-71e2-4b7e-9eda-bd556dbed8aa | default        | ingress   | IPv4      | 22/tcp        | any             |
| b44e29e3-a37b-41fa-9169-1bc102e3891d | default        | egress    | IPv6      | any           | any             |
| bcb97399-f401-4c20-b7db-c3c25fc816b4 | default        | ingress   | IPv4      | icmp          | any             |
| d534b39e-34ab-4f34-ae30-7205a7c6c511 | default        | ingress   | IPv4      | any           | default (group) |
| d672c429-55a1-4e7a-9ae8-99ee0cab0df8 | default        | ingress   | IPv6      | any           | default (group) |
+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
[10] 仮想マシンインスタンスに割りあてたフローティングIPあてに SSH 接続することで、インスタンスにログインできます。
[root@dlp ~(keystone)]#
ssh 10.0.0.200

root@10.0.0.201's password:
Last login: Fri Apr 29 02:31:00 2016
[root@host-192-168-100-11 ~]#    
# ログインできた
関連コンテンツ