Ubuntu 16.04
Sponsored Link

OpenStack Pike : Neutron ネットワーク構成(VXLAN)2017/09/13

 
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  |   |        L2 Agent       |   |        Libvirt        |
     |  Memcached  httpd     |   |        L3 Agent       |   |     Nova Compute      |
     |  Keystone   Glance    |   |     Metadata Agent    |   |        L2 Agent       |
     |  Nova API             |   |                       |   |                       |
     |  Neutron Server       |   |                       |   |                       |
     |  Metadata Agent       |   |                       |   |                       |
     +-----------------------+   +-----------+-----------+   +-----------------------+
                                             |eth1

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

tenant_network_types =
vxlan
# 166行目:追記

[ml2_type_flat]
flat_networks = physnet1
# 220行目:追記

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

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

tenant_network_types =
vxlan
# 166行目:追記

[ml2_type_flat]
flat_networks = physnet1
# 220行目:追記

[ml2_type_vxlan]
vni_ranges = 1:1000
root@network:~#
vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini
# 114行目:追記

[agent]
prevent_arp_spoofing = True
# 145行目:追記

[linux_bridge]
physical_interface_mappings = physnet1:eth1
# 168行目:追記

[vxlan]
enable_vxlan = True
l2_population = True
root@network:~#
vi /etc/neutron/dhcp_agent.ini
# 83行目:追記

dnsmasq_config_file = /etc/neutron/dnsmasq-neutron.conf
root@network:~#
vi /etc/neutron/dnsmasq-neutron.conf
# 新規作成

dhcp-option-force=26,1450
root@network:~#
for service in l3-agent dhcp-agent metadata-agent linuxbridge-agent; do
systemctl restart neutron-$service
done

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

tenant_network_types =
vxlan
# 166行目:追記

[ml2_type_flat]
flat_networks = physnet1
# 220行目:追記

[ml2_type_vxlan]
vni_ranges = 1:1000
root@node01:~#
vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini
# 114行目:追記

[agent]
prevent_arp_spoofing = True
# 168行目:追記

[vxlan]
enable_vxlan = True
l2_population = True
root@node01:~#
systemctl restart neutron-linuxbridge-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-09-15T04:31:50Z                 |
| description             |                                      |
| distributed             | False                                |
| external_gateway_info   | None                                 |
| flavor_id               | None                                 |
| ha                      | False                                |
| id                      | 605d39c2-393d-48b7-b108-7d6cac175821 |
| name                    | router01                             |
| project_id              | 1ca37b956ae4451892dfcc47f5f98913     |
| revision_number         | None                                 |
| routes                  |                                      |
| status                  | ACTIVE                               |
| tags                    |                                      |
| updated_at              | 2017-09-15T04:31:50Z                 |
+-------------------------+--------------------------------------+
[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-09-15T04:32:06Z                 |
| description               |                                      |
| dns_domain                | None                                 |
| id                        | fcfcf86c-40a6-4c79-9431-feb74dc5a6bc |
| ipv4_address_scope        | None                                 |
| ipv6_address_scope        | None                                 |
| is_default                | False                                |
| is_vlan_transparent       | None                                 |
| mtu                       | 1450                                 |
| name                      | int_net                              |
| port_security_enabled     | True                                 |
| project_id                | 1ca37b956ae4451892dfcc47f5f98913     |
| provider:network_type     | vxlan                                |
| provider:physical_network | None                                 |
| provider:segmentation_id  | 47                                   |
| qos_policy_id             | None                                 |
| revision_number           | 2                                    |
| router:external           | Internal                             |
| segments                  | None                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| updated_at                | 2017-09-15T04:32:06Z                 |
+---------------------------+--------------------------------------+

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

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-09-15T04:32:29Z                 |
| description             |                                      |
| dns_nameservers         | 10.0.0.10                            |
| enable_dhcp             | True                                 |
| gateway_ip              | 192.168.100.1                        |
| host_routes             |                                      |
| id                      | 65e69dd1-0b8c-43d7-9c44-b8099a2e0f82 |
| ip_version              | 4                                    |
| ipv6_address_mode       | None                                 |
| ipv6_ra_mode            | None                                 |
| name                    | subnet1                              |
| network_id              | fcfcf86c-40a6-4c79-9431-feb74dc5a6bc |
| project_id              | 1ca37b956ae4451892dfcc47f5f98913     |
| revision_number         | 0                                    |
| segment_id              | None                                 |
| service_types           |                                      |
| subnetpool_id           | None                                 |
| tags                    |                                      |
| updated_at              | 2017-09-15T04:32:29Z                 |
| use_default_subnet_pool | None                                 |
+-------------------------+--------------------------------------+

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

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-09-15T04:32:58Z                 |
| description               |                                      |
| dns_domain                | None                                 |
| id                        | 5adc2598-4ebe-4110-b6bf-47d9e2b5c48e |
| ipv4_address_scope        | None                                 |
| ipv6_address_scope        | None                                 |
| is_default                | False                                |
| is_vlan_transparent       | None                                 |
| mtu                       | 1500                                 |
| name                      | ext_net                              |
| port_security_enabled     | True                                 |
| project_id                | 1ca37b956ae4451892dfcc47f5f98913     |
| provider:network_type     | flat                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | None                                 |
| qos_policy_id             | None                                 |
| revision_number           | 3                                    |
| router:external           | External                             |
| segments                  | None                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| updated_at                | 2017-09-15T04:32:58Z                 |
+---------------------------+--------------------------------------+

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

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-09-15T04:33:21Z                 |
| description             |                                      |
| dns_nameservers         | 10.0.0.10                            |
| enable_dhcp             | False                                |
| gateway_ip              | 10.0.0.1                             |
| host_routes             |                                      |
| id                      | 6572863d-f10a-456e-932c-2581d39a3349 |
| ip_version              | 4                                    |
| ipv6_address_mode       | None                                 |
| ipv6_ra_mode            | None                                 |
| name                    | subnet2                              |
| network_id              | 5adc2598-4ebe-4110-b6bf-47d9e2b5c48e |
| project_id              | 1ca37b956ae4451892dfcc47f5f98913     |
| revision_number         | 0                                    |
| segment_id              | None                                 |
| service_types           |                                      |
| subnetpool_id           | None                                 |
| tags                    |                                      |
| updated_at              | 2017-09-15T04:33:21Z                 |
| use_default_subnet_pool | None                                 |
+-------------------------+--------------------------------------+

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

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 |
+--------------------------------------+------------+--------+
| 1f46b995-47e3-4858-b0b0-9221867462cc | Ubuntu1604 | active |
+--------------------------------------+------------+--------+

# キーペア作成

root@dlp ~(keystone)#
ssh-keygen -q -N ""

Enter file in which to save the key (/root/.ssh/id_rsa):
root@dlp ~(keystone)#
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| fingerprint | 7c:99:60:16:6e:79:a5:11:fc:71:f5:c2:77:8c:77:77 |
| name        | mykey                                           |
| user_id     | f73e3c2f9e7f4eb793a010f60d5b4674                |
+-------------+-------------------------------------------------+

root@dlp ~(keystone)#
openstack server create --flavor m1.small --image Ubuntu1604 --security-group default --nic net-id=$Int_Net_ID --key-name mykey Ubuntu_1604

root@dlp ~(keystone)#
openstack server list

+-----------+-------------+--------+------------------------+------------+----------+
| ID        | Name        | Status | Networks               | Image      | Flavor   |
+-----------+-------------+--------+------------------------+------------+----------+
| f5ae3046- | Ubuntu_1604 | ACTIVE | int_net=192.168.100.10 | Ubuntu1604 | m1.small |
+-----------+-------------+--------+------------------------+------------+----------+
[8] 作成した仮想マシンインスタンスにフローティングIPを割り当てます。
root@dlp ~(keystone)#
openstack floating ip create ext_net

Created a new floatingip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2017-09-15T04:37:15Z                 |
| description         |                                      |
| fixed_ip_address    | None                                 |
| floating_ip_address | 10.0.0.210                           |
| floating_network_id | 5adc2598-4ebe-4110-b6bf-47d9e2b5c48e |
| id                  | 024031d1-197e-4bf9-add3-c0bfc2a04305 |
| name                | 10.0.0.210                           |
| port_id             | None                                 |
| project_id          | 1ca37b956ae4451892dfcc47f5f98913     |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| updated_at          | 2017-09-15T04:37:15Z                 |
+---------------------+--------------------------------------+

root@dlp ~(keystone)#
openstack server add floating ip Ubuntu_1604 10.0.0.210

# 設定確認

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2017-09-15T04:37:15Z                 |
| description         |                                      |
| fixed_ip_address    | 192.168.100.10                       |
| floating_ip_address | 10.0.0.210                           |
| floating_network_id | 5adc2598-4ebe-4110-b6bf-47d9e2b5c48e |
| id                  | 024031d1-197e-4bf9-add3-c0bfc2a04305 |
| name                | 10.0.0.210                           |
| port_id             | ac2ed703-ead9-4237-8696-c10aaba5fdfa |
| project_id          | 1ca37b956ae4451892dfcc47f5f98913     |
| revision_number     | 3                                    |
| router_id           | 605d39c2-393d-48b7-b108-7d6cac175821 |
| status              | ACTIVE                               |
| updated_at          | 2017-09-15T04:49:37Z                 |
+---------------------+--------------------------------------+
[9] 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。
# ICMP 許可

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

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2017-09-15T04:39:02Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | de3df98b-093b-447e-ab8d-87fab7cf8347 |
| name              | None                                 |
| port_range_max    | None                                 |
| port_range_min    | None                                 |
| project_id        | 1ca37b956ae4451892dfcc47f5f98913     |
| protocol          | icmp                                 |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | 8df4495b-961c-41e5-9da0-a895d9a39ac8 |
| updated_at        | 2017-09-15T04:39:02Z                 |
+-------------------+--------------------------------------+

# SSH 許可

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

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2017-09-15T04:39:17Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | a7559a52-a41e-4e9c-825f-9531d3ee2b76 |
| name              | None                                 |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| project_id        | 1ca37b956ae4451892dfcc47f5f98913     |
| protocol          | tcp                                  |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | 8df4495b-961c-41e5-9da0-a895d9a39ac8 |
| updated_at        | 2017-09-15T04:39:17Z                 |
+-------------------+--------------------------------------+

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

+-----------+-------------+-----------+------------+-----------------------------------+-------------------+
| ID        | IP Protocol | IP Range  | Port Range | Remote Security Group             | Security Group    |
+-----------+-------------+-----------+------------+-----------------------------------+-------------------+
| 5adaebb5- | None        | None      |            | 8df4495b-961c-41e5-9da0-a895d9ac8 | 8df4495b-961c-... |
| 782d21b9- | None        | None      |            | None                              | 8df4495b-961c-... |
| a7559a52- | tcp         | 0.0.0.0/0 | 22:22      | None                              | 8df4495b-961c-... |
| d6604a9d- | None        | None      |            | None                              | 8df4495b-961c-... |
| d8a7bf04- | None        | None      |            | 8df4495b-961c-41e5-9da0-a895d9ac8 | 8df4495b-961c-... |
| de3df98b- | icmp        | 0.0.0.0/0 |            | None                              | 8df4495b-961c-... |
+-----------+-------------+-----------+------------+-----------------------------------+-------------------+

[10] 仮想マシンインスタンスに割りあてたフローティングIPあてに SSH 接続することで、インスタンスにログインできます。
root@dlp ~(keystone)#
ssh ubuntu@10.0.0.210

The authenticity of host '10.0.0.210 (10.0.0.210)' can't be established.
ECDSA key fingerprint is SHA256:CdtOqoerKy4q54iALeVFH+SJFX1RLFmUe3VQAlxbXAI.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.210' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-93-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
Last login: Fri Sep 15 11:26:30 2017
ubuntu@ubuntu-1604:~$    
# ログインできた
関連コンテンツ