CentOS 7
Sponsored Link

OpenStack Liberty : Neutron ネットワーク構成(VLAN)2015/11/15

 
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
# 8行目あたり: tenant_network_types に値を追記

tenant_network_types =
vlan
# 73行目あたりに追記

[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
# 8行目あたり: tenant_network_types に値を追記

tenant_network_types =
vlan
# 73行目あたりに追記

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

[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
# 69行目:追記

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                                 |
| distributed           | False                                |
| external_gateway_info |                                      |
| ha                    | False                                |
| id                    | f762044c-6c9f-44be-812b-e5596c864313 |
| name                  | router01                             |
| routes                |                                      |
| status                | ACTIVE                               |
| tenant_id             | d625e02b3d394afbad250def2f88fefa     |
+-----------------------+--------------------------------------+

[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                                 |
| id                        | 3b53ceaf-d034-4dfa-854b-2eeef683149a |
| mtu                       | 0                                    |
| name                      | int_net                              |
| provider:network_type     | vlan                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | 1059                                 |
| router:external           | False                                |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | d625e02b3d394afbad250def2f88fefa     |
+---------------------------+--------------------------------------+

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

[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                                     |
| dns_nameservers   | 10.0.0.1                                             |
| enable_dhcp       | True                                                 |
| gateway_ip        | 192.168.100.1                                        |
| host_routes       |                                                      |
| id                | 9a9fad33-ed87-4aba-ab78-156fe329afe3                 |
| ip_version        | 4                                                    |
| ipv6_address_mode |                                                      |
| ipv6_ra_mode      |                                                      |
| name              |                                                      |
| network_id        | 3b53ceaf-d034-4dfa-854b-2eeef683149a                 |
| subnetpool_id     |                                                      |
| tenant_id         | d625e02b3d394afbad250def2f88fefa                     |
+-------------------+------------------------------------------------------+

[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 3ff8f163-7d8d-48cc-bbe6-e8686def5d69 to router f762044c-6c9f-44be-812b-e5596c864313.
[6] 外部接続用のネットワークを作成し、仮想ルーターに関連付けます。
# 外部用ネットワーク作成

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

Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| id                        | 22ec5795-1725-437a-b016-e799b05613c5 |
| mtu                       | 0                                    |
| name                      | ext_net                              |
| provider:network_type     | vlan                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | 1080                                 |
| router:external           | True                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | d625e02b3d394afbad250def2f88fefa     |
+---------------------------+--------------------------------------+

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

[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                                  |
| dns_nameservers   | 10.0.0.1                                     |
| enable_dhcp       | False                                        |
| gateway_ip        | 10.0.0.1                                     |
| host_routes       |                                              |
| id                | 90b8e531-de9a-4ebd-98e5-c622f94e0553         |
| ip_version        | 4                                            |
| ipv6_address_mode |                                              |
| ipv6_ra_mode      |                                              |
| name              |                                              |
| network_id        | 22ec5795-1725-437a-b016-e799b05613c5         |
| subnetpool_id     |                                              |
| tenant_id         | d625e02b3d394afbad250def2f88fefa             |
+-------------------+----------------------------------------------+

[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 f762044c-6c9f-44be-812b-e5596c864313
[7] 内部ネットワークを関連付けた仮想マシンインスタンスを作成して起動します。
[root@dlp ~(keystone)]#
Int_Net_ID=`neutron net-list | grep int_net | awk '{ print $2 }'`

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

+--------------------------------------+---------+--------+--------+
| ID                                   | Name    | Status | Server |
+--------------------------------------+---------+--------+--------+
| 34beed31-2971-43f0-9c5a-d39d3df1d501 | CentOS7 | ACTIVE |        |
+--------------------------------------+---------+--------+--------+

[root@dlp ~(keystone)]#
nova boot --flavor 2 --image CentOS7 --security_group default --nic net-id=$Int_Net_ID CentOS_7

[root@dlp ~(keystone)]#
nova list

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

Created a new floatingip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| fixed_ip_address    |                                      |
| floating_ip_address | 10.0.0.201                           |
| floating_network_id | 22ec5795-1725-437a-b016-e799b05613c5 |
| id                  | 6decb261-7087-4c05-980b-0337ce198416 |
| port_id             |                                      |
| router_id           |                                      |
| status              | DOWN                                 |
| tenant_id           | d625e02b3d394afbad250def2f88fefa     |
+---------------------+--------------------------------------+

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

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

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

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

Associated floating IP 6decb261-7087-4c05-980b-0337ce198416
# 設定確認

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| fixed_ip_address    | 192.168.100.3                        |
| floating_ip_address | 10.0.0.201                           |
| floating_network_id | 22ec5795-1725-437a-b016-e799b05613c5 |
| id                  | 6decb261-7087-4c05-980b-0337ce198416 |
| port_id             | 1db8cca9-1db8-44b8-8859-e1e91a6556dd |
| router_id           | f762044c-6c9f-44be-812b-e5596c864313 |
| status              | ACTIVE                               |
| tenant_id           | d625e02b3d394afbad250def2f88fefa     |
+---------------------+--------------------------------------+
[9] 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。
# ICMP 許可

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

Created a new security_group_rule:
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| id                | db4c60a3-cc3a-402d-94e0-e0484d8e68c9 |
| port_range_max    |                                      |
| port_range_min    |                                      |
| protocol          | icmp                                 |
| remote_group_id   |                                      |
| remote_ip_prefix  |                                      |
| security_group_id | 7a196ffd-a7d0-49ff-8771-cde18d299d72 |
| tenant_id         | d625e02b3d394afbad250def2f88fefa     |
+-------------------+--------------------------------------+

# 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                                |
+-------------------+--------------------------------------+
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| id                | f19c4f1f-7055-4a8e-8b6a-67282ea5819a |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| protocol          | tcp                                  |
| remote_group_id   |                                      |
| remote_ip_prefix  |                                      |
| security_group_id | 7a196ffd-a7d0-49ff-8771-cde18d299d72 |
| tenant_id         | d625e02b3d394afbad250def2f88fefa     |
+-------------------+--------------------------------------+

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

+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
| id                                   | security_group | direction | ethertype | protocol/port | remote          |
+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
| 08262f7f-584f-4f26-933b-ab7a4dc888a9 | default        | ingress   | IPv4      | any           | default (group) |
| aff0d3dc-ed67-4e8b-85c6-e2eb42311fe3 | default        | egress    | IPv4      | any           | any             |
| bcacccd1-5424-4407-8b9b-5002ef035be4 | default        | egress    | IPv6      | any           | any             |
| cbd0e7e6-a372-410e-9d33-0f6ae7c7a2e0 | default        | ingress   | IPv6      | any           | default (group) |
| db4c60a3-cc3a-402d-94e0-e0484d8e68c9 | default        | ingress   | IPv4      | icmp          | any             |
| f19c4f1f-7055-4a8e-8b6a-67282ea5819a | default        | ingress   | IPv4      | 22/tcp        | any             |
+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
[10] 仮想マシンインスタンスに割りあてたフローティングIPあてに SSH 接続することで、インスタンスにログインできます。
[root@dlp ~(keystone)]#
ssh 10.0.0.201

The authenticity of host '10.0.0.201 (10.0.0.201)' can't be established.
ECDSA key fingerprint is 03:3d:a6:2c:21:0d:03:cc:de:29:d1:c0:3b:4d:4c:e7.
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.
root@10.0.0.201's password:
Last login: Sat Nov 14 21:10:58 2015
[root@host-192-168-100-3 ~]#    
# ログインできた
関連コンテンツ