OpenStack Ocata : Neutron ネットワーク構成(VXLAN)2017/03/15 |
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 # 115行目: tenant_network_types に値を追記 tenant_network_types = vxlan
# 166行目:追記 [ml2_type_flat]
flat_networks = physnet1
# 220行目:追記 [ml2_type_vxlan]
vni_ranges = 1:1000
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
# 181行目:追記 [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
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 # 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
# 181行目:追記 [vxlan]
enable_vxlan = True
l2_population = True 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-03-16T05:47:22Z | | description | | | distributed | False | | external_gateway_info | None | | flavor_id | None | | ha | False | | id | 3dd71e78-6f72-4ea9-95cd-94f2fdfd58b7 | | name | router01 | | project_id | ef6b5d01da394383a1afba725735a727 | | revision_number | None | | routes | | | status | ACTIVE | | updated_at | 2017-03-16T05:47:22Z | +-------------------------+--------------------------------------+ |
[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-03-16T05:47:59Z | | description | | | dns_domain | None | | id | 428b6cd1-2df4-446c-a1c2-0cab74a730ac | | ipv4_address_scope | None | | ipv6_address_scope | None | | is_default | None | | mtu | 1450 | | name | int_net | | port_security_enabled | True | | project_id | ef6b5d01da394383a1afba725735a727 | | provider:network_type | vxlan | | provider:physical_network | None | | provider:segmentation_id | 80 | | qos_policy_id | None | | revision_number | 3 | | router:external | Internal | | segments | None | | shared | False | | status | ACTIVE | | subnets | | | updated_at | 2017-03-16T05:47:59Z | +---------------------------+--------------------------------------+ # 内部用ネットワークにサブネット作成 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-16T05:48:40Z | | description | | | dns_nameservers | 10.0.0.10 | | enable_dhcp | True | | gateway_ip | 192.168.100.1 | | host_routes | | | id | e4ad1184-3d88-4ac4-b89d-cf509cb0c52e | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | subnet1 | | network_id | 428b6cd1-2df4-446c-a1c2-0cab74a730ac | | project_id | ef6b5d01da394383a1afba725735a727 | | revision_number | 2 | | segment_id | None | | service_types | | | subnetpool_id | None | | updated_at | 2017-03-16T05:48:40Z | +-------------------+--------------------------------------+ # 仮想ルーターに内部ネットワークを設定 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-03-16T05:49:43Z | | description | | | dns_domain | None | | id | febd4268-45ce-4690-8252-d4ebdab9bccc | | ipv4_address_scope | None | | ipv6_address_scope | None | | is_default | False | | mtu | 1500 | | name | ext_net | | port_security_enabled | True | | project_id | ef6b5d01da394383a1afba725735a727 | | provider:network_type | flat | | provider:physical_network | physnet1 | | provider:segmentation_id | None | | qos_policy_id | None | | revision_number | 4 | | router:external | External | | segments | None | | shared | False | | status | ACTIVE | | subnets | | | updated_at | 2017-03-16T05:49:44Z | +---------------------------+--------------------------------------+ # 外部用ネットワークにサブネット作成 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-03-16T05:50:21Z | | description | | | dns_nameservers | 10.0.0.10 | | enable_dhcp | False | | gateway_ip | 10.0.0.1 | | host_routes | | | id | 4059076f-63b8-4167-bb04-79258025fb81 | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | subnet2 | | network_id | febd4268-45ce-4690-8252-d4ebdab9bccc | | project_id | ef6b5d01da394383a1afba725735a727 | | revision_number | 2 | | segment_id | None | | service_types | | | subnetpool_id | None | | updated_at | 2017-03-16T05:50:21Z | +-------------------+--------------------------------------+ # 仮想ルーターにゲートウェイを設定 root@dlp ~(keystone)# openstack router set router01 --external-gateway ext_net |
[7] | 内部ネットワークを関連付けた仮想マシンインスタンスを作成して起動します。 |
root@dlp ~(keystone)#
root@dlp ~(keystone)# Int_Net_ID=`openstack network list | grep int_net | awk '{ print $2 }'` openstack image list +--------------------------------------+------------+--------+ | ID | Name | Status | +--------------------------------------+------------+--------+ | 94b334bf-178f-46b2-ac6f-4e49de6442a1 | Ubuntu1604 | active | +--------------------------------------+------------+--------+root@dlp ~(keystone)# openstack server create --flavor m1.small --image Ubuntu1604 --security-group default --nic net-id=$Int_Net_ID Ubuntu_1604 root@dlp ~(keystone)# openstack server list +--------------------+-------------+--------+---------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------+-------------+--------+---------------------+------------+ | 17ae3ad9-0a0d- | Ubuntu_1604 | ACTIVE | int_net=192.168.100 | Ubuntu1604 | | 485d- | | | .8 | | | b1c1-461821b0b1d2 | | | | | +--------------------+-------------+--------+---------------------+------------+ |
[8] | 作成した仮想マシンインスタンスにフローティングIPを割り当てます。 |
root@dlp ~(keystone)# openstack floating ip create ext_net Created a new floatingip: +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2017-03-16T05:53:04Z | | description | | | fixed_ip_address | None | | floating_ip_address | 10.0.0.205 | | floating_network_id | febd4268-45ce-4690-8252-d4ebdab9bccc | | id | 14425492-59c8-41eb-b2ce-5a396789b4ea | | name | None | | port_id | None | | project_id | ef6b5d01da394383a1afba725735a727 | | revision_number | 1 | | router_id | None | | status | DOWN | | updated_at | 2017-03-16T05:53:04Z | +---------------------+--------------------------------------+
root@dlp ~(keystone)#
openstack server add floating ip Ubuntu_1604 10.0.0.205 # 設定確認 root@dlp ~(keystone)# openstack floating ip show 10.0.0.205 +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2017-03-16T05:53:04Z | | description | | | fixed_ip_address | 192.168.100.8 | | floating_ip_address | 10.0.0.205 | | floating_network_id | febd4268-45ce-4690-8252-d4ebdab9bccc | | id | 14425492-59c8-41eb-b2ce-5a396789b4ea | | name | None | | port_id | 223f7838-ae6b-404a-b524-63715a8055d6 | | project_id | ef6b5d01da394383a1afba725735a727 | | revision_number | 2 | | router_id | 3dd71e78-6f72-4ea9-95cd-94f2fdfd58b7 | | status | ACTIVE | | updated_at | 2017-03-16T05:53:45Z | +---------------------+--------------------------------------+ |
[9] | 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。 |
# ICMP 許可 root@dlp ~(keystone)# openstack security group rule create --protocol icmp --ingress default +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2017-03-10T06:45:14Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | faf40532-ceea-41ad-a5fb-11b857c022ce | | name | None | | port_range_max | None | | port_range_min | None | | project_id | 763d3fd7411e4b42982d4d7022f1e335 | | protocol | icmp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 1 | | security_group_id | cb6894d3-846b-4135-8cc6-25842b67c6a6 | | updated_at | 2017-03-10T06:45:14Z | +-------------------+--------------------------------------+ # SSH 許可 root@dlp ~(keystone)# openstack security group rule create --protocol tcp --dst-port 22:22 default +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2017-03-10T06:45:31Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 15421d61-0343-40f9-8086-2e53e526248d | | name | None | | port_range_max | 22 | | port_range_min | 22 | | project_id | 763d3fd7411e4b42982d4d7022f1e335 | | protocol | tcp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 1 | | security_group_id | cb6894d3-846b-4135-8cc6-25842b67c6a6 | | updated_at | 2017-03-10T06:45:31Z | +-------------------+--------------------------------------+root@dlp ~(keystone)# openstack security group rule list +------------+-------------+-----------+------------+-----------------------+----------------+ | ID | IP Protocol | IP Range | Port Range | Remote Security Group | Security Group | +------------+-------------+-----------+------------+-----------------------+----------------+ | 15421d61-0 | tcp | 0.0.0.0/0 | 22:22 | None | cb6894d3-846b- | | 343-40f9-8 | | | | | 4135-8cc6-2584 | | 086-2e53e5 | | | | | 2b67c6a6 | | 26248d | | | | | | | 9928f5fc-8 | None | None | | None | cb6894d3-846b- | | c94-4458-8 | | | | | 4135-8cc6-2584 | | 3a6-9a8678 | | | | | 2b67c6a6 | | 8fb5ee | | | | | | | bce04897-a | None | None | | cb6894d3-846b-4135-8c | cb6894d3-846b- | | 9b2-4b80-8 | | | | c6-25842b67c6a6 | 4135-8cc6-2584 | | 709-6fbcbf | | | | | 2b67c6a6 | | 459ef7 | | | | | | | faf40532 | icmp | 0.0.0.0/0 | | None | cb6894d3-846b- | | -ceea- | | | | | 4135-8cc6-2584 | | 41ad-a5fb- | | | | | 2b67c6a6 | | 11b857c022 | | | | | | | ce | | | | | | | fba7a2cb- | None | None | | cb6894d3-846b-4135-8c | cb6894d3-846b- | | 03fa-4c11 | | | | c6-25842b67c6a6 | 4135-8cc6-2584 | | -aadd-ebab | | | | | 2b67c6a6 | | 85838be9 | | | | | | | fe1ae047 | None | None | | None | cb6894d3-846b- | | -9bdd-43b1 | | | | | 4135-8cc6-2584 | | -b6bd-62fa | | | | | 2b67c6a6 | | 17442d87 | | | | | | +------------+-------------+-----------+------------+-----------------------+----------------+ |
[10] | 仮想マシンインスタンスに割りあてたフローティングIPあてに SSH 接続することで、インスタンスにログインできます。 |
root@dlp ~(keystone)# ssh ubuntu@10.0.0.205
The authenticity of host '10.0.0.205 (10.0.0.205)' can't be established.
ECDSA key fingerprint is SHA256:hb0tkx8NUhkoyhBHfEEY2Hs0L+wXHRwfE953hgK0CpQ.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.205' (ECDSA) to the list of known hosts.
ubuntu@10.0.0.205's password:
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-66-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Last login: Wed Mar 15 09:46:46 2017
ubuntu@ubuntu:~$ # ログインできた
|
Sponsored Link |
|