CentOS 7
 

OpenStack Ocata : Neutron ネットワークを構成する (VLAN)
2017/02/28
 
OpenStack Network Service(Neutron)による仮想ネットワークの構成です。
例として、VLAN タイプのネットワークを構成します。
事前に以下のように 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  |    eth1|      Open vSwitch     |eth2    |        Libvirt        |eth1
     |  Memcached  httpd     |   -----+  L2,L3,Metadata Agent +-----   |      Nova Compute     +-----
     |  Keystone   Glance    |        |                       |        |      Open vSwitch     |
     |  Nova API             |        |                       |        |        L2 Agent       |
     |  Neutron Server       |        |                       |        |                       |
     +-----------------------+        +-----------------------+        +-----------------------+

[1] Control ノードで以下のように設定変更します。
[root@dlp ~(keystone)]#
vi /etc/neutron/plugins/ml2/ml2_conf.ini
# 115行目:tenant_network_types に値を追記

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

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

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

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

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

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

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

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

+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | UP                                   |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| created_at              | 2017-03-04T11:23:06Z                 |
| description             |                                      |
| distributed             | False                                |
| external_gateway_info   | None                                 |
| flavor_id               | None                                 |
| ha                      | False                                |
| id                      | f62df3d6-a047-40e2-9241-0b0e25ef17a9 |
| name                    | router01                             |
| project_id              | c654e2e098b14356b97b6e613775cc54     |
| revision_number         | None                                 |
| routes                  |                                      |
| status                  | ACTIVE                               |
| updated_at              | 2017-03-04T11:23:06Z                 |
+-------------------------+--------------------------------------+
[5] 内部用のネットワークを作成し、仮想ルーターに関連付けます。
# 内部用ネットワーク作成

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

+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | UP                                   |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2017-03-04T11:23:20Z                 |
| description               |                                      |
| dns_domain                | None                                 |
| id                        | 01d68d9e-ff56-429c-828a-6c992ce0530e |
| ipv4_address_scope        | None                                 |
| ipv6_address_scope        | None                                 |
| is_default                | None                                 |
| mtu                       | 1500                                 |
| name                      | int_net                              |
| port_security_enabled     | True                                 |
| project_id                | c654e2e098b14356b97b6e613775cc54     |
| provider:network_type     | vlan                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | 1049                                 |
| qos_policy_id             | None                                 |
| revision_number           | 3                                    |
| router:external           | Internal                             |
| segments                  | None                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| updated_at                | 2017-03-04T11:23:20Z                 |
+---------------------------+--------------------------------------+

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

[root@dlp ~(keystone)]#
openstack subnet create subnet1 --network int_net \
--subnet-range 192.168.100.0/24 --gateway 192.168.100.1 \
--dns-nameserver 10.0.0.10

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| allocation_pools  | 192.168.100.2-192.168.100.254        |
| cidr              | 192.168.100.0/24                     |
| created_at        | 2017-03-04T11:24:25Z                 |
| description       |                                      |
| dns_nameservers   | 10.0.0.10                            |
| enable_dhcp       | True                                 |
| gateway_ip        | 192.168.100.1                        |
| host_routes       |                                      |
| id                | 5001e44a-7552-42cc-8521-fc916613a2b6 |
| ip_version        | 4                                    |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | subnet1                              |
| network_id        | 01d68d9e-ff56-429c-828a-6c992ce0530e |
| project_id        | c654e2e098b14356b97b6e613775cc54     |
| revision_number   | 2                                    |
| segment_id        | None                                 |
| service_types     |                                      |
| subnetpool_id     | None                                 |
| updated_at        | 2017-03-04T11:24:25Z                 |
+-------------------+--------------------------------------+

# 仮想ルーターに内部ネットワークを設定

[root@dlp ~(keystone)]#
openstack router add subnet router01 subnet1
[6] 外部接続用のネットワークを作成し、仮想ルーターに関連付けます。
# 外部用ネットワーク作成

[root@dlp ~(keystone)]#
openstack network create --external ext_net

+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | UP                                   |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2017-03-04T11:24:53Z                 |
| description               |                                      |
| dns_domain                | None                                 |
| id                        | 6c7c7ff9-702d-4379-9434-909b797ead58 |
| ipv4_address_scope        | None                                 |
| ipv6_address_scope        | None                                 |
| is_default                | False                                |
| mtu                       | 1500                                 |
| name                      | ext_net                              |
| port_security_enabled     | True                                 |
| project_id                | c654e2e098b14356b97b6e613775cc54     |
| provider:network_type     | vlan                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | 1022                                 |
| qos_policy_id             | None                                 |
| revision_number           | 4                                    |
| router:external           | External                             |
| segments                  | None                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| updated_at                | 2017-03-04T11:24:54Z                 |
+---------------------------+--------------------------------------+

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

[root@dlp ~(keystone)]#
openstack subnet create subnet2 \
--network ext_net --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

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| allocation_pools  | 10.0.0.200-10.0.0.254                |
| cidr              | 10.0.0.0/24                          |
| created_at        | 2017-03-04T11:26:01Z                 |
| description       |                                      |
| dns_nameservers   | 10.0.0.10                            |
| enable_dhcp       | True                                 |
| gateway_ip        | 10.0.0.1                             |
| host_routes       |                                      |
| id                | ca5afde6-96ea-4e14-8802-be9609f94e9f |
| ip_version        | 4                                    |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | subnet2                              |
| network_id        | 6c7c7ff9-702d-4379-9434-909b797ead58 |
| project_id        | c654e2e098b14356b97b6e613775cc54     |
| revision_number   | 2                                    |
| segment_id        | None                                 |
| service_types     |                                      |
| subnetpool_id     | None                                 |
| updated_at        | 2017-03-04T11:26:01Z                 |
+-------------------+--------------------------------------+

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

[root@dlp ~(keystone)]#
openstack router set router01 --external-gateway ext_net

[7] 内部ネットワークを関連付けた仮想マシンインスタンスを作成して起動します。
[root@dlp ~(keystone)]#
Int_Net_ID=`openstack network list | grep int_net | awk '{ print $2 }'`

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

+--------------------------------------+---------+--------+
| ID                                   | Name    | Status |
+--------------------------------------+---------+--------+
| c13b45a8-5664-4169-93c7-625ae2e561e9 | 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)]#
openstack floating ip create ext_net

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2017-03-04T11:27:26Z                 |
| description         |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.208                           |
| floating_network_id | 6c7c7ff9-702d-4379-9434-909b797ead58 |
| id                  | f403f159-15dd-4c50-a3e4-9dec1f1aec15 |
| name                | None                                 |
| port_id             | None                                 |
| project_id          | c654e2e098b14356b97b6e613775cc54     |
| revision_number     | 1                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| updated_at          | 2017-03-04T11:27:26Z                 |
+---------------------+--------------------------------------+

[root@dlp ~(keystone)]#
openstack server add floating ip CentOS_7 10.0.0.208

# 設定確認

[root@dlp ~(keystone)]#
openstack floating ip show 10.0.0.208

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2017-03-04T11:27:26Z                 |
| description         |                                      |
| fixed_ip_address    | 192.168.100.8                        |
| floating_ip_address | 10.0.0.208                           |
| floating_network_id | 6c7c7ff9-702d-4379-9434-909b797ead58 |
| id                  | f403f159-15dd-4c50-a3e4-9dec1f1aec15 |
| name                | None                                 |
| port_id             | 35932c46-4cce-4b8e-bc5e-813b712a5ec3 |
| project_id          | c654e2e098b14356b97b6e613775cc54     |
| revision_number     | 2                                    |
| router_id           | f62df3d6-a047-40e2-9241-0b0e25ef17a9 |
| status              | ACTIVE                               |
| updated_at          | 2017-03-04T11:27:50Z                 |
+---------------------+--------------------------------------+

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

+-----------+----------+--------+------------------------------------+------------+
| ID        | Name     | Status | Networks                           | Image Name |
+-----------+----------+--------+------------------------------------+------------+
| 7587ad83- | CentOS_7 | ACTIVE | int_net=192.168.100.11, 10.0.0.208 | CentOS7    |
+-----------+----------+--------+------------------------------------+------------+
[9] 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。
# ICMP 許可

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

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2017-02-28T07:54:12Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | 180e4ec7-9221-42fb-bdba-382c5a06a8f4 |
| name              | None                                 |
| port_range_max    | None                                 |
| port_range_min    | None                                 |
| project_id        | c654e2e098b14356b97b6e613775cc54     |
| protocol          | icmp                                 |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 1                                    |
| security_group_id | 160e1d9e-72b9-4ed3-a434-276518f22a7b |
| updated_at        | 2017-02-28T07:54:12Z                 |
+-------------------+--------------------------------------+

# SSH 許可

[root@dlp ~(keystone)]#
openstack security group rule create --protocol tcp --dst-port 22:22 default

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2017-02-28T07:55:14Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | 93a858de-87b5-4544-8d23-ef4f24da5f3b |
| name              | None                                 |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| project_id        | c654e2e098b14356b97b6e613775cc54     |
| protocol          | tcp                                  |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 1                                    |
| security_group_id | 160e1d9e-72b9-4ed3-a434-276518f22a7b |
| updated_at        | 2017-02-28T07:55:14Z                 |
+-------------------+--------------------------------------+

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

+-------------------+-------------+-----------+------------+--------------------------------------+--------------+
| ID                | IP Protocol | IP Range  | Port Range | Remote Security Group                | Security Gro |
+-------------------+-------------+-----------+------------+--------------------------------------+--------------+
| 180e4ec7-9221-... | icmp        | 0.0.0.0/0 |            | None                                 | 160e1d9e-... |
| 29b38eb3-2004-... | None        | None      |            | 160e1d9e-72b9-4ed3-a434-276518f22a7b | 160e1d9e-... |
| 93a858de-87b5-... | tcp         | 0.0.0.0/0 | 22:22      | None                                 | 160e1d9e-... |
| 9f86c90e-6357-... | None        | None      |            | None                                 | 160e1d9e-... |
| a1feacc0-c8ea-... | None        | None      |            | None                                 | 160e1d9e-... |
| f46d96c3-235a-... | None        | None      |            | 160e1d9e-72b9-4ed3-a434-276518f22a7b | 160e1d9e-... |
+-------------------+-------------+-----------+------------+--------------------------------------+--------------+
[10] 仮想マシンインスタンスに割りあてられたフローティング IP 宛てに SSH 接続することで、インスタンスにログインできます。
[root@dlp ~(keystone)]#
openstack server list

+-----------+----------+--------+------------------------------------+------------+
| ID        | Name     | Status | Networks                           | Image Name |
+-----------+----------+--------+------------------------------------+------------+
| 7587ad83- | CentOS_7 | ACTIVE | int_net=192.168.100.11, 10.0.0.208 | CentOS7    |
+-----------+----------+--------+------------------------------------+------------+

[root@dlp ~(keystone)]#
ssh 10.0.0.208

The authenticity of host '10.0.0.208 (10.0.0.208)' can't be established.
ECDSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.208' (ECDSA) to the list of known hosts.
root@10.0.0.208's password:
Last login: Wed Mar  1 16:30:10 2017
[root@host-192-168-100-11 ~]#    
# ログインできた
 
Tweet