OpenStack Victoria : Neutron ネットワークを構成 (VXLAN)2021/08/31 |
OpenStack Network Service(Neutron)による仮想ネットワークの構成です。
例として、VXLAN タイプのネットワークを構成します。
事前に以下のように Control ノード、 Network ノード、 Compute ノードの 各 Neutron サービスノードを構築済みであることが前提です。
また、当例では Network ノードが 2つのネットワークインターフェースを持っているものとします。
また、下例で eth1 の方は IP なしでインターフェースを UP しています。 IP なしでのインターフェース UP の設定はこちらの [1] を参照ください。 ------------+---------------------------+---------------------------+------------ | | | 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|(UP with no IP) |
[1] | Control ノードで以下のように設定変更します。 |
root@dlp ~(keystone)#
vi /etc/neutron/plugins/ml2/ml2_conf.ini # 139行目 : 設定確認 tenant_network_types = vxlan # 174行目 : 変更 [ml2_type_flat] ..... ..... flat_networks = physnet1
# 222行目 : 設定確認 vni_ranges = 1:100 systemctl restart neutron-api neutron-rpc-server |
[2] | Network ノードで以下のように設定変更します。 |
root@network:~#
vi /etc/neutron/plugins/ml2/ml2_conf.ini # 139行目 : 設定確認 tenant_network_types = vxlan # 174行目 : 変更 [ml2_type_flat] ..... ..... flat_networks = physnet1
# 222行目 : 設定確認 vni_ranges = 1:100
root@network:~#
vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini # 136行目 : 追記 [agent]
prevent_arp_spoofing = True
# 162行目 : 追記 [linux_bridge]
physical_interface_mappings = physnet1:eth1
# 225行目 : コメント解除 enable_vxlan = true
root@network:~#
vi /etc/neutron/dhcp_agent.ini # 68行目 : 追記
dnsmasq_config_file = /etc/neutron/dnsmasq-neutron.conf
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 # 139行目 : 設定確認 tenant_network_types = vxlan # 174行目 : 変更 [ml2_type_flat] ..... ..... flat_networks = physnet1
# 222行目 : 設定確認 vni_ranges = 1:100
root@node01:~#
vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini # 136行目 : 追記 [agent]
prevent_arp_spoofing = True
# 225行目 : コメント解除 enable_vxlan = true systemctl restart neutron-linuxbridge-agent |
[4] | 仮想ルーターを作成します。作業場所はどこでもよいですが、当例では Control ノード上で作業します。 |
# 仮想ルーター作成 root@dlp ~(keystone)# openstack router create router01 +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2021-08-31T23:44:09Z | | description | | | distributed | False | | external_gateway_info | null | | flavor_id | None | | ha | False | | id | 91eeffee-49ba-4328-aaae-7b652fd7dfef | | name | router01 | | project_id | 14c0b23f6f574380b9687f326debf0fe | | revision_number | 1 | | routes | | | status | ACTIVE | | tags | | | updated_at | 2021-08-31T23:44:09Z | +-------------------------+--------------------------------------+ |
[5] | 内部用のネットワークを作成し、仮想ルーターに関連付けます。 |
# 内部用ネットワーク作成 root@dlp ~(keystone)# openstack network create private --provider-network-type vxlan +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2021-08-31T23:44:30Z | | description | | | dns_domain | None | | id | f30adecb-7c0b-4829-a5bd-d0836b3bffe2 | | ipv4_address_scope | None | | ipv6_address_scope | None | | is_default | False | | is_vlan_transparent | None | | mtu | 1450 | | name | private | | port_security_enabled | True | | project_id | 14c0b23f6f574380b9687f326debf0fe | | provider:network_type | vxlan | | provider:physical_network | None | | provider:segmentation_id | 1 | | qos_policy_id | None | | revision_number | 1 | | router:external | Internal | | segments | None | | shared | False | | status | ACTIVE | | subnets | | | tags | | | updated_at | 2021-08-31T23:44:31Z | +---------------------------+--------------------------------------+ # 内部用ネットワークにサブネット作成 root@dlp ~(keystone)# openstack subnet create private-subnet --network private \ --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 | 2021-08-31T23:46:07Z | | description | | | dns_nameservers | 10.0.0.10 | | dns_publish_fixed_ip | None | | enable_dhcp | True | | gateway_ip | 192.168.100.1 | | host_routes | | | id | b2892d90-0b42-4785-b666-15688d9aaa5d | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | private-subnet | | network_id | f30adecb-7c0b-4829-a5bd-d0836b3bffe2 | | prefix_length | None | | project_id | 14c0b23f6f574380b9687f326debf0fe | | revision_number | 0 | | segment_id | None | | service_types | | | subnetpool_id | None | | tags | | | updated_at | 2021-08-31T23:46:07Z | +----------------------+--------------------------------------+ # 仮想ルーターに内部ネットワークを設定 root@dlp ~(keystone)# openstack router add subnet router01 private-subnet
|
[6] | 外部接続用のネットワークを作成し、仮想ルーターに関連付けます。 |
# 外部用ネットワーク作成 root@dlp ~(keystone)# openstack network create \ --provider-physical-network physnet1 \ --provider-network-type flat --external public +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2021-08-31T23:46:41Z | | description | | | dns_domain | None | | id | 70d34670-7e68-4605-816b-244634a0a323 | | ipv4_address_scope | None | | ipv6_address_scope | None | | is_default | False | | is_vlan_transparent | None | | mtu | 1500 | | name | public | | port_security_enabled | True | | project_id | 14c0b23f6f574380b9687f326debf0fe | | provider:network_type | flat | | provider:physical_network | physnet1 | | provider:segmentation_id | None | | qos_policy_id | None | | revision_number | 1 | | router:external | External | | segments | None | | shared | False | | status | ACTIVE | | subnets | | | tags | | | updated_at | 2021-08-31T23:46:41Z | +---------------------------+--------------------------------------+ # 外部用ネットワークにサブネット作成 root@dlp ~(keystone)# openstack subnet create public-subnet \ --network public --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 | 2021-08-31T23:47:01Z | | description | | | dns_nameservers | 10.0.0.10 | | dns_publish_fixed_ip | None | | enable_dhcp | False | | gateway_ip | 10.0.0.1 | | host_routes | | | id | 103cd703-3fc3-429a-a68b-52643757c619 | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | public-subnet | | network_id | 70d34670-7e68-4605-816b-244634a0a323 | | prefix_length | None | | project_id | 14c0b23f6f574380b9687f326debf0fe | | revision_number | 0 | | segment_id | None | | service_types | | | subnetpool_id | None | | tags | | | updated_at | 2021-08-31T23:47:01Z | +----------------------+--------------------------------------+ # 仮想ルーターにゲートウェイを設定 root@dlp ~(keystone)# openstack router set router01 --external-gateway public |
[7] | 作成したネットワークは、外部用はデフォルトで全プロジェクトがアクセス可能ですが、内部用はデフォルトでは [admin] プロジェクトのみがアクセス可能なため、内部ネットワークを利用させたいプロジェクトにアクセス権限を付与しておきます。 |
# ネットワーク RBAC リスト表示 root@dlp ~(keystone)# openstack network rbac list +--------------------------------------+-------------+--------------------------------------+ | ID | Object Type | Object ID | +--------------------------------------+-------------+--------------------------------------+ | de912fb5-8fef-482a-adcb-dc99be94a70c | network | 70d34670-7e68-4605-816b-244634a0a323 | +--------------------------------------+-------------+--------------------------------------+ # RBAC の詳細 # [access_as_external] のみ全プロジェクトがアクセス可能な状態 root@dlp ~(keystone)# openstack network rbac show de912fb5-8fef-482a-adcb-dc99be94a70c +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | action | access_as_external | | id | de912fb5-8fef-482a-adcb-dc99be94a70c | | name | None | | object_id | 70d34670-7e68-4605-816b-244634a0a323 | | object_type | network | | project_id | 14c0b23f6f574380b9687f326debf0fe | | target_project_id | * | +-------------------+--------------------------------------+ # 作成済みネットワーク一覧 root@dlp ~(keystone)# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 70d34670-7e68-4605-816b-244634a0a323 | public | 103cd703-3fc3-429a-a68b-52643757c619 | | f30adecb-7c0b-4829-a5bd-d0836b3bffe2 | private | b2892d90-0b42-4785-b666-15688d9aaa5d | +--------------------------------------+---------+--------------------------------------+ # 作成済みプロジェクト一覧 root@dlp ~(keystone)# openstack project list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 14c0b23f6f574380b9687f326debf0fe | admin | | 1718217eee4b4f2ea143d65122864fe0 | service | | cba75a02a921457db62b660f3d0b57c4 | hiroshima | +----------------------------------+-----------+ # [private] への [access_as_shared] アクセス権を [hiroshima] プロジェクトに付与 root@dlp ~(keystone)# netID=$(openstack network list | grep private | awk '{ print $2 }') root@dlp ~(keystone)# prjID=$(openstack project list | grep hiroshima | awk '{ print $2 }') root@dlp ~(keystone)# openstack network rbac create --target-project $prjID --type network --action access_as_shared $netID +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | action | access_as_shared | | id | e9c6a173-4b40-41dd-89d0-34ff7b4cbcb3 | | name | None | | object_id | f30adecb-7c0b-4829-a5bd-d0836b3bffe2 | | object_type | network | | project_id | 14c0b23f6f574380b9687f326debf0fe | | target_project_id | cba75a02a921457db62b660f3d0b57c4 | +-------------------+--------------------------------------+ |
[8] | 内部ネットワークへのアクセス権を付与したプロジェクトに所属する任意のユーザーでログインし、 作成した内部ネットワークをインスタンスに紐付けてインスタンスを作成・起動します。 |
# 利用可能な [flavor] 確認 debian@dlp ~(keystone)$ openstack flavor list +----+----------+------+------+-----------+-------+-----------+ | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public | +----+----------+------+------+-----------+-------+-----------+ | 0 | m1.small | 2048 | 10 | 0 | 1 | True | +----+----------+------+------+-----------+-------+-----------+ # 利用可能なイメージ確認 debian@dlp ~(keystone)$ openstack image list +--------------------------------------+----------+--------+ | ID | Name | Status | +--------------------------------------+----------+--------+ | 773971b3-b4be-4b07-aa06-fe8ca76b395d | Debian11 | active | +--------------------------------------+----------+--------+ # 利用可能なネットワーク確認 debian@dlp ~(keystone)$ openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 70d34670-7e68-4605-816b-244634a0a323 | public | 103cd703-3fc3-429a-a68b-52643757c619 | | f30adecb-7c0b-4829-a5bd-d0836b3bffe2 | private | b2892d90-0b42-4785-b666-15688d9aaa5d | +--------------------------------------+---------+--------------------------------------+ # インスタンス用のセキュリティグループを作成 debian@dlp ~(keystone)$ openstack security group create secgroup01 +-----------------+-------------------------------------------------------------------------+ | Field | Value | +-----------------+-------------------------------------------------------------------------+ | created_at | 2021-08-31T23:50:58Z | | description | secgroup01 | | id | f7c62a05-57cf-4057-9063-064d9e8f19ac | | name | secgroup01 | | project_id | cba75a02a921457db62b660f3d0b57c4 | | revision_number | 1 | | rules | created_at='2021-08-31T23:50:58Z', direction='egress', ethertype='..... | | | created_at='2021-08-31T23:50:58Z', direction='egress', ethertype='..... | | stateful | True | | tags | [] | | updated_at | 2021-08-31T23:50:58Z | +-----------------+-------------------------------------------------------------------------+ # インスタンス接続用の SSH キーペア作成 debian@dlp ~(keystone)$ ssh-keygen -q -N "" Enter file in which to save the key (/home/debian/.ssh/id_rsa): # 公開鍵登録 debian@dlp ~(keystone)$ openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | fingerprint | e9:49:9f:bf:73:1d:1a:39:48:91:c5:a1:43:ff:07:df | | name | mykey | | user_id | 62a91aa559f64acab11861ed7cd51ecc | +-------------+-------------------------------------------------+debian@dlp ~(keystone)$ netID=$(openstack network list | grep private | awk '{ print $2 }')
debian@dlp ~(keystone)$
debian@dlp ~(keystone)$ openstack server create --flavor m1.small --image Debian11 --security-group secgroup01 --nic net-id=$netID --key-name mykey Debian-11
openstack server list +--------------------------------------+-----------+--------+-------------------------+----------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+-------------------------+----------+----------+ | 86981ae7-d713-414f-966c-ac22387a3226 | Debian-11 | ACTIVE | private=192.168.100.211 | Debian11 | m1.small | +--------------------------------------+-----------+--------+-------------------------+----------+----------+ |
[9] | 作成した仮想マシンインスタンスにフローティングIP を割り当てます。 |
debian@dlp ~(keystone)$ openstack floating ip create public +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | created_at | 2021-08-31T23:55:56Z | | description | | | dns_domain | None | | dns_name | None | | fixed_ip_address | None | | floating_ip_address | 10.0.0.249 | | floating_network_id | 70d34670-7e68-4605-816b-244634a0a323 | | id | 037fba2b-d0a4-425f-a3ee-d3891f03ae27 | | name | 10.0.0.249 | | port_details | None | | port_id | None | | project_id | cba75a02a921457db62b660f3d0b57c4 | | qos_policy_id | None | | revision_number | 0 | | router_id | None | | status | DOWN | | subnet_id | None | | tags | [] | | updated_at | 2021-08-31T23:55:56Z | +---------------------+--------------------------------------+
debian@dlp ~(keystone)$
openstack server add floating ip Debian-11 10.0.0.249
# 設定確認 debian@dlp ~(keystone)$ openstack floating ip show 10.0.0.249 +---------------------+------------------------------------------------------------------------+ | Field | Value | +---------------------+------------------------------------------------------------------------+ | created_at | 2021-08-31T23:55:56Z | | description | | | dns_domain | None | | dns_name | None | | fixed_ip_address | 192.168.100.211 | | floating_ip_address | 10.0.0.249 | | floating_network_id | 70d34670-7e68-4605-816b-244634a0a323 | | id | 037fba2b-d0a4-425f-a3ee-d3891f03ae27 | | name | 10.0.0.249 | | port_details | admin_state_up='True', device_id='86981ae7-d713-414f-966c-ac22387..... | | port_id | 748fe8d9-19e5-473e-8031-1b195ef8f548 | | project_id | cba75a02a921457db62b660f3d0b57c4 | | qos_policy_id | None | | revision_number | 2 | | router_id | 91eeffee-49ba-4328-aaae-7b652fd7dfef | | status | ACTIVE | | subnet_id | None | | tags | [] | | updated_at | 2021-08-31T23:56:31Z | +---------------------+------------------------------------------------------------------------+debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+-------------------------------------+----------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+-------------------------------------+----------+----------+ | 86981ae7-d713-414f-966c-ac22387a3226 | Debian-11 | ACTIVE | private=192.168.100.211, 10.0.0.249 | Debian11 | m1.small | +--------------------------------------+-----------+--------+-------------------------------------+----------+----------+ |
[10] | 起動した仮想マシンインスタンスに SSH 接続できるように、先に作成したセキュリティグループにポート許可の設定を追加します。 |
# ICMP 許可 debian@dlp ~(keystone)$ openstack security group rule create --protocol icmp --ingress secgroup01 +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2021-08-31T23:57:50Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 2cf2d179-19e6-487a-8ed0-a4cf74f96add | | name | None | | port_range_max | None | | port_range_min | None | | project_id | cba75a02a921457db62b660f3d0b57c4 | | protocol | icmp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | f7c62a05-57cf-4057-9063-064d9e8f19ac | | tags | [] | | updated_at | 2021-08-31T23:57:50Z | +-------------------+--------------------------------------+ # SSH 許可 debian@dlp ~(keystone)$ openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01 +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2021-08-31T23:58:04Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | bb7f1afb-851e-4c1c-84db-4adbf7f438fc | | name | None | | port_range_max | 22 | | port_range_min | 22 | | project_id | cba75a02a921457db62b660f3d0b57c4 | | protocol | tcp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | f7c62a05-57cf-4057-9063-064d9e8f19ac | | tags | [] | | updated_at | 2021-08-31T23:58:04Z | +-------------------+--------------------------------------+debian@dlp ~(keystone)$ openstack security group rule list secgroup01 +--------------------------------------+-------------+-----------+-----------+------------+-----------------------+ | ID | IP Protocol | Ethertype | IP Range | Port Range | Remote Security Group | +--------------------------------------+-------------+-----------+-----------+------------+-----------------------+ | 2cf2d179-19e6-487a-8ed0-a4cf74f96add | icmp | IPv4 | 0.0.0.0/0 | | None | | 32cc619d-72e8-4f64-86b5-434a4135dad1 | None | IPv6 | ::/0 | | None | | 56316681-731f-413c-9b50-cc9cb5f61442 | None | IPv4 | 0.0.0.0/0 | | None | | bb7f1afb-851e-4c1c-84db-4adbf7f438fc | tcp | IPv4 | 0.0.0.0/0 | 22:22 | None | +--------------------------------------+-------------+-----------+-----------+------------+-----------------------+ |
[11] | 仮想マシンインスタンスに割りあてられたフローティング IP 宛てに SSH 接続することで、インスタンスに SSH ログインできます。 |
debian@dlp ~(keystone)$ openstack server list +--------------------------------------+-----------+--------+-------------------------------------+----------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-----------+--------+-------------------------------------+----------+----------+ | 86981ae7-d713-414f-966c-ac22387a3226 | Debian-11 | ACTIVE | private=192.168.100.211, 10.0.0.249 | Debian11 | m1.small | +--------------------------------------+-----------+--------+-------------------------------------+----------+----------+debian@dlp ~(keystone)$ ssh debian@10.0.0.249 The authenticity of host '10.0.0.249 (10.0.0.249)' can't be established. ECDSA key fingerprint is SHA256:97kilq+UUx4mUedQ6gdw+gKIf/D1ZumKK1DrhRbOmAo. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.0.0.249' (ECDSA) to the list of known hosts. Linux debian-11 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) 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-11:~$ # ログインできた |
Sponsored Link |
|