Ubuntu 16.04
Sponsored Link

OpenStack Mitaka (三鷹) : Neutron ネットワーク構成(VXLAN)2016/05/30

 
OpenStack Network Service(Neutron)による仮想ネットワークの構成です。
例として、VXLAN タイプのプロバイダーネットワークを構成します。
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      |  |     |       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
# 101行目: tenant_network_types に値を追記

tenant_network_types =
vxlan
# 152行目:追記

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

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

tenant_network_types =
vxlan
# 152行目:追記

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

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

[linux_bridge]
physical_interface_mappings = physnet1:eth1
# 171行目あたり:変更 & 追記 (local_ip は物理インターフェースのIPを指定)

[vxlan]
enable_vxlan =
True
local_ip = 10.0.0.50
l2_population = True
# 100行目:追記

[agent]
prevent_arp_spoofing = True
root@network:~#
vi /etc/neutron/dhcp_agent.ini
# 81行目:追記

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:~#
echo 'net.bridge.bridge-nf-call-iptables=1' >> /etc/sysctl.conf

root@node01:~#
echo 'net.bridge.bridge-nf-call-ip6tables=1' >> /etc/sysctl.conf

root@node01:~#
sysctl -p

root@node01:~#
vi /etc/neutron/plugins/ml2/ml2_conf.ini
# 101行目: tenant_network_types に値を追記

tenant_network_types =
vxlan
# 152行目:追記

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

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

[linux_bridge]
physical_interface_mappings = physnet1:eth1
# 171行目:変更 & 追記 (local_ip は物理インターフェースのIPを指定)

[vxlan]
enable_vxlan = True
local_ip = 10.0.0.51
l2_population = True
# 100行目:追記

[agent]
prevent_arp_spoofing = True
root@node01:~#
systemctl restart neutron-linuxbridge-agent

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

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

Created a new router:
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | True                                 |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| description             |                                      |
| distributed             | False                                |
| external_gateway_info   |                                      |
| ha                      | False                                |
| id                      | 70a2c69f-6a5c-42f6-b46a-33ac9f0b81bf |
| name                    | router01                             |
| routes                  |                                      |
| status                  | ACTIVE                               |
| tenant_id               | 61bb62a97e394b8db8f95aa05a678771     |
+-------------------------+--------------------------------------+

root@dlp ~(keystone)#
Router_ID=`neutron router-list | grep router01 | awk '{ print $2 }'`

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

root@dlp ~(keystone)#
neutron net-create int_net --provider:network_type vxlan

Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2016-05-31T11:03:26                  |
| description               |                                      |
| id                        | b8f55572-e940-4d48-ac34-08a842982a33 |
| ipv4_address_scope        |                                      |
| ipv6_address_scope        |                                      |
| mtu                       | 1450                                 |
| name                      | int_net                              |
| port_security_enabled     | True                                 |
| provider:network_type     | vxlan                                |
| provider:physical_network |                                      |
| provider:segmentation_id  | 78                                   |
| router:external           | False                                |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| tenant_id                 | 61bb62a97e394b8db8f95aa05a678771     |
| updated_at                | 2016-05-31T11:03:26                  |
+---------------------------+--------------------------------------+

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

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                                     |
| created_at        | 2016-05-31T11:04:16                                  |
| description       |                                                      |
| dns_nameservers   | 10.0.0.1                                             |
| enable_dhcp       | True                                                 |
| gateway_ip        | 192.168.100.1                                        |
| host_routes       |                                                      |
| id                | 86305acd-a037-4050-804c-34f6f0d8d1ee                 |
| ip_version        | 4                                                    |
| ipv6_address_mode |                                                      |
| ipv6_ra_mode      |                                                      |
| name              |                                                      |
| network_id        | b8f55572-e940-4d48-ac34-08a842982a33                 |
| subnetpool_id     |                                                      |
| tenant_id         | 61bb62a97e394b8db8f95aa05a678771                     |
| updated_at        | 2016-05-31T11:04:16                                  |
+-------------------+------------------------------------------------------+

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 230ac899-054c-4b53-893e-432968685874 to router 70a2c69f-6a5c-42f6-b46a-33ac9f0b81bf.
[6] 外部接続用のネットワークを作成し、仮想ルーターに関連付けます。
# 外部用ネットワーク作成

root@dlp ~(keystone)#
neutron net-create ext_net --router:external True --provider:physical_network physnet1 --provider:network_type flat

Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2016-05-31T11:04:58                  |
| description               |                                      |
| id                        | c106a185-c9d9-45b2-93f7-c124c080da97 |
| ipv4_address_scope        |                                      |
| ipv6_address_scope        |                                      |
| is_default                | False                                |
| mtu                       | 1500                                 |
| name                      | ext_net                              |
| port_security_enabled     | True                                 |
| provider:network_type     | flat                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  |                                      |
| router:external           | True                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| tenant_id                 | 61bb62a97e394b8db8f95aa05a678771     |
| updated_at                | 2016-05-31T11:04:59                  |
+---------------------------+--------------------------------------+

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

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                                  |
| created_at        | 2016-05-31T11:05:17                          |
| description       |                                              |
| dns_nameservers   | 10.0.0.1                                     |
| enable_dhcp       | False                                        |
| gateway_ip        | 10.0.0.1                                     |
| host_routes       |                                              |
| id                | f9da6488-df9c-4f40-8998-304a5632a0a9         |
| ip_version        | 4                                            |
| ipv6_address_mode |                                              |
| ipv6_ra_mode      |                                              |
| name              |                                              |
| network_id        | c106a185-c9d9-45b2-93f7-c124c080da97         |
| subnetpool_id     |                                              |
| tenant_id         | 61bb62a97e394b8db8f95aa05a678771             |
| updated_at        | 2016-05-31T11:05:17                          |
+-------------------+----------------------------------------------+

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 70a2c69f-6a5c-42f6-b46a-33ac9f0b81bf
[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 |
+--------------------------------------+------------+--------+--------+
| d7e743c4-c1f5-458b-abc5-2d9176c07a93 | Ubuntu1604 | ACTIVE |        |
+--------------------------------------+------------+--------+--------+

root@dlp ~(keystone)#
nova boot --flavor 2 --image Ubuntu1604 --security-groups default --nic net-id=$Int_Net_ID Ubuntu_1604

root@dlp ~(keystone)#
nova list

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

Created a new floatingip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| description         |                                      |
| dns_domain          |                                      |
| dns_name            |                                      |
| fixed_ip_address    |                                      |
| floating_ip_address | 10.0.0.201                           |
| floating_network_id | c106a185-c9d9-45b2-93f7-c124c080da97 |
| id                  | 2af3610a-ad49-4cdf-ac41-d1bd0e57916b |
| port_id             |                                      |
| router_id           |                                      |
| status              | DOWN                                 |
| tenant_id           | 61bb62a97e394b8db8f95aa05a678771     |
+---------------------+--------------------------------------+

root@dlp ~(keystone)#
Device_ID=`nova list | grep Ubuntu_1604 | 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 2af3610a-ad49-4cdf-ac41-d1bd0e57916b
# 設定確認

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| description         |                                      |
| dns_domain          |                                      |
| dns_name            |                                      |
| fixed_ip_address    | 192.168.100.3                        |
| floating_ip_address | 10.0.0.201                           |
| floating_network_id | c106a185-c9d9-45b2-93f7-c124c080da97 |
| id                  | 2af3610a-ad49-4cdf-ac41-d1bd0e57916b |
| port_id             | a0043817-b893-49d6-83ab-8ed60700117d |
| router_id           | 70a2c69f-6a5c-42f6-b46a-33ac9f0b81bf |
| status              | DOWN                                 |
| tenant_id           | 61bb62a97e394b8db8f95aa05a678771     |
+---------------------+--------------------------------------+
[9] 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。
# ICMP 許可

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

Created a new security_group_rule:
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| description       |                                      |
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| id                | 67699149-a85e-4334-91cc-48865147b7fd |
| port_range_max    |                                      |
| port_range_min    |                                      |
| protocol          | icmp                                 |
| remote_group_id   |                                      |
| remote_ip_prefix  |                                      |
| security_group_id | 04d72bc2-a73e-4803-b93a-0e22e69bae9f |
| tenant_id         | 61bb62a97e394b8db8f95aa05a678771     |
+-------------------+--------------------------------------+

# 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                                |
+-------------------+--------------------------------------+
| description       |                                      |
| direction         | ingress                              |
| ethertype         | IPv4                                 |
| id                | 492eb253-3314-420a-98ee-3d652aecbe86 |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| protocol          | tcp                                  |
| remote_group_id   |                                      |
| remote_ip_prefix  |                                      |
| security_group_id | 04d72bc2-a73e-4803-b93a-0e22e69bae9f |
| tenant_id         | 61bb62a97e394b8db8f95aa05a678771     |
+-------------------+--------------------------------------+

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

+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
| id                                   | security_group | direction | ethertype | port/protocol | remote          |
+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
| 492eb253-3314-420a-98ee-3d652aecbe86 | default        | ingress   | IPv4      | 22/tcp        | any             |
| 67699149-a85e-4334-91cc-48865147b7fd | default        | ingress   | IPv4      | icmp          | any             |
| 6976acfc-c439-44f1-b8a1-be9b917ebef2 | default        | ingress   | IPv4      | any           | default (group) |
| 710640ac-f8ac-4d29-b708-861476758f83 | default        | ingress   | IPv6      | any           | default (group) |
| 7ab15e66-e89b-4c72-b7b9-a7a216d14a81 | default        | egress    | IPv4      | any           | any             |
| 825efe36-22a0-4037-9cb9-3622b798fea0 | default        | egress    | IPv6      | any           | any             |
+--------------------------------------+----------------+-----------+-----------+---------------+-----------------+
[10] 仮想マシンインスタンスに割りあてたフローティングIPあてに SSH 接続することで、インスタンスにログインできます。
root@dlp ~(keystone)#
ssh xerus@10.0.0.201

The authenticity of host '10.0.0.201 (10.0.0.201)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
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.
xerus@10.0.0.201's password:
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-22-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

0 packages can be updated.
0 updates are security updates.

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

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

xerus@ubuntu:~$    
# ログインできた
関連コンテンツ