CentOS 6
Sponsored Link

OpenStack Icehouse : ネットワーク構成#2
2014/06/25
 
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
# 36行目あたりに追記

[ml2_type_vlan]
network_vlan_ranges = physnet1:1000:2999
# 最終行に追記

[ovs]
tenant_network_type = vlan
bridge_mappings = physnet1:br-eth1
[root@dlp ~(keystone)]#
/etc/rc.d/init.d/neutron-server restart

Stopping neutron: [  OK  ]
Starting neutron: [  OK  ]
[2] Network ノード、および、Compute ノードの両方で以下のように設定変更します。
[root@network ~]#
ovs-vsctl add-br br-eth1
   
# ブリッジ追加

[root@network ~]#
ovs-vsctl add-port br-eth1 eth1
   
# 追加したブリッジのポートにeth1を追加

[root@network ~]#
vi /etc/neutron/plugins/ml2/ml2_conf.ini
# 36行目あたりに追記

[ml2_type_vlan]
network_vlan_ranges = physnet1:1000:2999
# 最終行に追記

[ovs]
tenant_network_type = vlan
bridge_mappings = physnet1:br-eth1
[root@network ~]#
/etc/rc.d/init.d/neutron-openvswitch-agent restart

Stopping neutron-openvswitch-agent:                        [  OK  ]
Starting neutron-openvswitch-agent:                        [  OK  ]
[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
# 47行目:追記

external_network_bridge =
br-ext
[root@network ~]#
/etc/rc.d/init.d/neutron-l3-agent restart

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

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

Created a new router:
+-----------------------+--------------------------------------+
| Field                 | Value                                |
+-----------------------+--------------------------------------+
| admin_state_up        | True                                 |
| external_gateway_info |                                      |
| id                    | 272a5007-2c61-4cd0-b69f-feae268a82ce |
| name                  | router01                             |
| status                | ACTIVE                               |
| tenant_id             | 6af6c82883db4dd399833237e64609bf     |
+-----------------------+--------------------------------------+

[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                        | 58daad73-ae23-4337-ad2b-fd4f1d9b46ea |
| name                      | int_net                              |
| provider:network_type     | vlan                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | 1000                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | 6af6c82883db4dd399833237e64609bf     |
+---------------------------+--------------------------------------+

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

[root@dlp ~(keystone)]#
neutron subnet-create \
--gateway 192.168.100.1 --dns-nameserver 10.0.0.10 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.10                                            |
| enable_dhcp      | True                                                 |
| gateway_ip       | 192.168.100.1                                        |
| host_routes      |                                                      |
| id               | a4f25d5b-4069-4f72-a8a7-b3d5dc5b6edd                 |
| ip_version       | 4                                                    |
| name             |                                                      |
| network_id       | 58daad73-ae23-4337-ad2b-fd4f1d9b46ea                 |
| tenant_id        | 6af6c82883db4dd399833237e64609bf                     |
+------------------+------------------------------------------------------+

[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 9f6da48a-6e63-4dd5-aa41-74a9a8b8dea6 to router 272a5007-2c61-4cd0-b69f-feae268a82ce.
[6] 外部接続用のネットワークを作成し、仮想ルーターに関連付けます。
# 外部用ネットワーク作成

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

Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| id                        | ac62454d-7be4-411d-946c-8ffcd59bfb39 |
| name                      | ext_net                              |
| provider:network_type     | vlan                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | 1001                                 |
| router:external           | True                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | 6af6c82883db4dd399833237e64609bf     |
+---------------------------+--------------------------------------+

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

[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.10 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.10                                    |
| enable_dhcp      | False                                        |
| gateway_ip       | 10.0.0.1                                     |
| host_routes      |                                              |
| id               | 12f71209-1730-41bb-84d1-7fbdd5069350         |
| ip_version       | 4                                            |
| name             |                                              |
| network_id       | ac62454d-7be4-411d-946c-8ffcd59bfb39         |
| tenant_id        | 6af6c82883db4dd399833237e64609bf             |
+------------------+----------------------------------------------+

[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 272a5007-2c61-4cd0-b69f-feae268a82ce
[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 |
+--------------------------------------+---------+--------+--------+
| bbbe2faf-f533-4f06-855c-ac33fb9e4209 | CentOS6 | ACTIVE |        |
+--------------------------------------+---------+--------+--------+

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

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

+-----------+-----------+--------+------------+-------------+-----------------------+
| ID        | Name      | Status | Task State | Power State | Networks              |
+-----------+-----------+--------+------------+-------------+-----------------------+
| 11be97d4- | CentOS_66 | ACTIVE | -          | Running     | int_net=192.168.100.2 |
+-----------+-----------+--------+------------+-------------+-----------------------+
[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 | ac62454d-7be4-411d-946c-8ffcd59bfb39 |
| id                  | d1ef564f-507b-4552-9a3c-19403d8498e1 |
| port_id             |                                      |
| router_id           |                                      |
| status              | DOWN                                 |
| tenant_id           | 6af6c82883db4dd399833237e64609bf     |
+---------------------+--------------------------------------+

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

[root@dlp ~(keystone)]#
Port_ID=`neutron port-list -- --device_id $Device_ID | grep 192.168.100.2 | 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 floatingip d1ef564f-507b-4552-9a3c-19403d8498e1
# 設定確認

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| fixed_ip_address    | 192.168.100.2                        |
| floating_ip_address | 10.0.0.201                           |
| floating_network_id | ac62454d-7be4-411d-946c-8ffcd59bfb39 |
| id                  | d1ef564f-507b-4552-9a3c-19403d8498e1 |
| port_id             | 8e9c0edf-fddf-4b50-b645-4a4325874285 |
| router_id           | 272a5007-2c61-4cd0-b69f-feae268a82ce |
| status              | ACTIVE                               |
| tenant_id           | 6af6c82883db4dd399833237e64609bf     |
+---------------------+--------------------------------------+
[9] 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。
# SSH 許可

[root@dlp ~(keystone)]#
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0

+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp         | 22        | 22      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+

# ICMP 許可

[root@dlp ~(keystone)]#
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0

+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
| icmp        | -1        | -1      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+

[root@dlp ~(keystone)]#
nova secgroup-list-rules default

+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp         | 22        | 22      | 0.0.0.0/0 |              |
| icmp        | -1        | -1      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+
[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.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:76:84:a6.
Are you sure you want to continue connecting (yes/no)?
yes

Warning: Permanently added '10.0.0.201' (RSA) to the list of known hosts.
root@192.168.100.3's password:
Last login: Thu Jun 26 01:50:50 2014
[root@host-10.0.0.201 ~]#    
# ログインできた
 
Tweet