Debian 9 Stretch
Sponsored Link

OpenStack Newton : Neutron ネットワーク構成(VXLAN)2017/07/03

 
OpenStack Network Service(Neutron)による仮想ネットワークの構成です。
例として、VXLAN タイプのネットワークを構成します。
事前に以下のように Control ノードNetwork ノードCompute ノードの 各 Neutron サービスノードを構築済みであることが前提です。
また、当例では Network ノードが二つのネットワークインターフェースを持っているものとします。
     ------------+--------------------------------+--------------------------------+------------
                 |                                |                                |
             eth0|10.0.0.30                   eth0|10.0.0.50                   eth0|10.0.0.51
     +-----------+-----------+        +-----------+-----------+        +-----------+-----------+
     |    [ Control Node ]   |        |    [ Network Node ]   |        |    [ Compute Node ]   |
     |                       |        |                       |        |                       |
     |  MariaDB    RabbitMQ  |        |                       |eth1    |        Libvirt        |
     |  Memcached  httpd     |        |  L2,L3,Metadata Agent +----    |      Nova Compute     |
     |  Keystone   Glance    |        |                       |        |        L2 Agent       |
     |  Nova API             |        |                       |        |                       |
     |  Neutron Server       |        |                       |        |                       |
     +-----------------------+        +-----------------------+        +-----------------------+

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

tenant_network_types =
vxlan
# 129行目:変更

flat_networks =
physnet1
# 171行目:追記

[ml2_type_vxlan]
vni_ranges = 1:1000
root@dlp ~(keystone)#
systemctl restart neutron-server

[2] Network ノードで以下のように設定変更します。
# ブリッジ追加

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

tenant_network_types =
vxlan
# 129行目:変更

flat_networks =
physnet1
# 171行目:追記

[ml2_type_vxlan]
vni_ranges = 1:1000
root@network:~#
vi /etc/neutron/plugins/ml2/openvswitch_agent.ini
# 99行目:コメント解除して変更

tunnel_types =
vxlan
# 180行目:コメント解除して変更

bridge_mappings =
physnet1:br-eth1
root@network:~#
for service in l3-agent dhcp-agent metadata-agent openvswitch-agent; do
systemctl restart neutron-$service
done

[3] Compute ノードで以下のように設定変更します。
root@node01:~#
vi /etc/neutron/plugins/ml2/ml2_conf.ini
# 94行目: tenant_network_types に値を追記

tenant_network_types =
vxlan
# 129行目:変更

flat_networks =
physnet1
# 171行目:追記

[ml2_type_vxlan]
vni_ranges = 1:1000
root@node01:~#
vi /etc/neutron/plugins/ml2/openvswitch_agent.ini
# 99行目:コメント解除して変更

tunnel_types =
vxlan
root@node01:~#
systemctl restart neutron-openvswitch-agent

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

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

Created a new router:
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | UP                                   |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| created_at              | 2017-07-06T07:29:08Z                 |
| description             |                                      |
| distributed             | False                                |
| external_gateway_info   | null                                 |
| flavor_id               | None                                 |
| ha                      | False                                |
| headers                 |                                      |
| id                      | 5e8f17a6-8808-4644-acd3-0cb6016bad51 |
| name                    | router01                             |
| project_id              | aa50ee91b9f748a38d9e1643006b6bd1     |
| project_id              | aa50ee91b9f748a38d9e1643006b6bd1     |
| revision_number         | 2                                    |
| routes                  |                                      |
| status                  | ACTIVE                               |
| updated_at              | 2017-07-06T07:29:08Z                 |
+-------------------------+--------------------------------------+
[5] 内部用のネットワークを作成し、仮想ルーターに関連付けます。
# 内部用ネットワーク作成

root@dlp ~(keystone)#
openstack network create int_net --provider-network-type vxlan

+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | UP                                   |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2017-07-06T07:29:27Z                 |
| description               |                                      |
| headers                   |                                      |
| id                        | d8259723-ca53-4f6e-8bd6-b7787775dfe8 |
| ipv4_address_scope        | None                                 |
| ipv6_address_scope        | None                                 |
| mtu                       | 1450                                 |
| name                      | int_net                              |
| port_security_enabled     | True                                 |
| project_id                | aa50ee91b9f748a38d9e1643006b6bd1     |
| project_id                | aa50ee91b9f748a38d9e1643006b6bd1     |
| provider:network_type     | vxlan                                |
| provider:physical_network | None                                 |
| provider:segmentation_id  | 39                                   |
| revision_number           | 3                                    |
| router:external           | Internal                             |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      | []                                   |
| updated_at                | 2017-07-06T07:29:27Z                 |
+---------------------------+--------------------------------------+

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

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-07-06T07:29:48Z                 |
| description       |                                      |
| dns_nameservers   | 10.0.0.10                            |
| enable_dhcp       | True                                 |
| gateway_ip        | 192.168.100.1                        |
| headers           |                                      |
| host_routes       |                                      |
| id                | f9cf78f4-3702-4894-9f3b-755b541fc162 |
| ip_version        | 4                                    |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | subnet1                              |
| network_id        | d8259723-ca53-4f6e-8bd6-b7787775dfe8 |
| project_id        | aa50ee91b9f748a38d9e1643006b6bd1     |
| project_id        | aa50ee91b9f748a38d9e1643006b6bd1     |
| revision_number   | 2                                    |
| service_types     | []                                   |
| subnetpool_id     | None                                 |
| updated_at        | 2017-07-06T07:29:48Z                 |
+-------------------+--------------------------------------+

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

root@dlp ~(keystone)#
openstack router add subnet router01 subnet1

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

root@dlp ~(keystone)#
openstack network create \
--provider-physical-network physnet1 \
--provider-network-type flat --external ext_net

+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | UP                                   |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2017-07-06T07:30:12Z                 |
| description               |                                      |
| headers                   |                                      |
| id                        | 3bbaadd7-6da0-494b-950d-489566b78713 |
| ipv4_address_scope        | None                                 |
| ipv6_address_scope        | None                                 |
| is_default                | False                                |
| mtu                       | 1500                                 |
| name                      | ext_net                              |
| port_security_enabled     | True                                 |
| project_id                | aa50ee91b9f748a38d9e1643006b6bd1     |
| project_id                | aa50ee91b9f748a38d9e1643006b6bd1     |
| provider:network_type     | flat                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | None                                 |
| revision_number           | 3                                    |
| router:external           | External                             |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      | []                                   |
| updated_at                | 2017-07-06T07:30:12Z                 |
+---------------------------+--------------------------------------+

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

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 --no-dhcp

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| allocation_pools  | 10.0.0.200-10.0.0.254                |
| cidr              | 10.0.0.0/24                          |
| created_at        | 2017-07-06T07:30:32Z                 |
| description       |                                      |
| dns_nameservers   | 10.0.0.10                            |
| enable_dhcp       | False                                |
| gateway_ip        | 10.0.0.1                             |
| headers           |                                      |
| host_routes       |                                      |
| id                | 688823d2-605c-4208-a42c-0622d182abf6 |
| ip_version        | 4                                    |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | subnet2                              |
| network_id        | 3bbaadd7-6da0-494b-950d-489566b78713 |
| project_id        | aa50ee91b9f748a38d9e1643006b6bd1     |
| project_id        | aa50ee91b9f748a38d9e1643006b6bd1     |
| revision_number   | 2                                    |
| service_types     | []                                   |
| subnetpool_id     | None                                 |
| updated_at        | 2017-07-06T07:30:32Z                 |
+-------------------+--------------------------------------+

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

root@dlp ~(keystone)#
neutron router-gateway-set \
$(openstack router list | grep router01 | awk '{ print $2 }') \
$(openstack network list | grep ext_net | awk '{ print $2 }')
[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 |
+--------------------------------------+---------+--------+
| a44f263f-be6c-4b7a-b23e-228f8cf396ca | Debian9 | active |
+--------------------------------------+---------+--------+

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

root@dlp ~(keystone)#
openstack server list

+--------------------------------------+----------+--------+-----------------------+------------+
| ID                                   | Name     | Status | Networks              | Image Name |
+--------------------------------------+----------+--------+-----------------------+------------+
| bab79aeb-5e1f-4331-83f0-ff6cc662b13d | Debian_9 | ACTIVE | int_net=192.168.100.3 | Debian9    |
+--------------------------------------+----------+--------+-----------------------+------------+
[8] 作成した仮想マシンインスタンスにフローティングIPを割り当てます。
root@dlp ~(keystone)#
openstack floating ip create ext_net

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2017-07-06T07:34:24Z                 |
| description         |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.204                           |
| floating_network_id | 3bbaadd7-6da0-494b-950d-489566b78713 |
| headers             |                                      |
| id                  | a8e89629-6f9c-4258-9a43-55cb3153b48b |
| port_id             | None                                 |
| project_id          | aa50ee91b9f748a38d9e1643006b6bd1     |
| project_id          | aa50ee91b9f748a38d9e1643006b6bd1     |
| revision_number     | 1                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| updated_at          | 2017-07-06T07:34:24Z                 |
+---------------------+--------------------------------------+

root@dlp ~(keystone)#
openstack server add floating ip Debian_9 10.0.0.204

# 設定確認

root@dlp ~(keystone)#
openstack floating ip show 10.0.0.204

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2017-07-06T07:34:24Z                 |
| description         |                                      |
| fixed_ip_address    | 192.168.100.3                        |
| floating_ip_address | 10.0.0.204                           |
| floating_network_id | 3bbaadd7-6da0-494b-950d-489566b78713 |
| id                  | a8e89629-6f9c-4258-9a43-55cb3153b48b |
| port_id             | 223c25e0-d149-40d9-bcd4-255158cbfb4e |
| project_id          | aa50ee91b9f748a38d9e1643006b6bd1     |
| project_id          | aa50ee91b9f748a38d9e1643006b6bd1     |
| revision_number     | 2                                    |
| router_id           | 5e8f17a6-8808-4644-acd3-0cb6016bad51 |
| status              | ACTIVE                               |
| updated_at          | 2017-07-06T07:34:44Z                 |
+---------------------+--------------------------------------+
[9] 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。
# ICMP 許可

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

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2017-07-06T07:35:12Z                 |
| description       |                                      |
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| headers           |                                      |
| id                | 8fcf2c23-361d-467d-9293-4519276900df |
| port_range_max    | None                                 |
| port_range_min    | None                                 |
| project_id        | aa50ee91b9f748a38d9e1643006b6bd1     |
| project_id        | aa50ee91b9f748a38d9e1643006b6bd1     |
| protocol          | icmp                                 |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 1                                    |
| security_group_id | c2471cef-b570-46ac-8a5d-088547c4b8c5 |
| updated_at        | 2017-07-06T07:35:12Z                 |
+-------------------+--------------------------------------+

# SSH 許可

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

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2017-07-06T07:35:26Z                 |
| description       |                                      |
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| headers           |                                      |
| id                | 1ff0166a-6c14-4580-b638-bf23bb45815c |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| project_id        | aa50ee91b9f748a38d9e1643006b6bd1     |
| project_id        | aa50ee91b9f748a38d9e1643006b6bd1     |
| protocol          | tcp                                  |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 1                                    |
| security_group_id | c2471cef-b570-46ac-8a5d-088547c4b8c5 |
| updated_at        | 2017-07-06T07:35:26Z                 |
+-------------------+--------------------------------------+

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

+-----------+-------------+-----------+------------+--------------------------+---------------------+
| ID        | IP Protocol | IP Range  | Port Range | Remote Security Group    | Security Group      |
+-----------+-------------+-----------+------------+--------------------------+---------------------+
| 1ff0166a- | tcp         | 0.0.0.0/0 | 22:22      | None                     | c2471cef-b570-46ac- |
| 5414cf34- | None        | None      |            | c2471cef-b570-46ac-8a5d- | c2471cef-b570-46ac- |
| 7161b00c- | None        | None      |            | None                     | c2471cef-b570-46ac- |
| 8fcf2c23- | icmp        | 0.0.0.0/0 |            | None                     | c2471cef-b570-46ac- |
| 99774862- | None        | None      |            | c2471cef-b570-46ac-8a5d- | c2471cef-b570-46ac- |
| ef685e2b- | None        | None      |            | None                     | c2471cef-b570-46ac- |
+-----------+-------------+-----------+------------+--------------------------+---------------------+
[10] 仮想マシンインスタンスに割りあてたフローティングIPあてに SSH 接続することで、インスタンスにログインできます。
root@dlp ~(keystone)#
ssh debian@10.0.0.204

The authenticity of host '10.0.0.204 (10.0.0.204)' can't be established.
ECDSA key fingerprint is SHA256:8BCoEq/qE1pI3cVawS3cZdAk8xCctjljkrAVwPZAMRU.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.204' (ECDSA) to the list of known hosts.
debian@10.0.0.204's password:
Linux debian.srv.world 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64

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

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
debian@debian:~$    
# ログインできた
関連コンテンツ