OpenStack Wallaby : Neutron ネットワークを構成する (FLAT)2021/04/23 |
OpenStack Network Service(Neutron)による仮想ネットワークの構成です。
例として、FLAT タイプのプロバイダーネットワークを構成します。
事前に以下のように Control ノード、 Network ノード、 Compute ノードの 各 Neutron サービスノードを構築済みであることが前提です。
また、当例では Network ノードと Compute ノードが 2つのネットワークインターフェースを持っているものとします。
------------+---------------------------+---------------------------+------------ | | | eth0|10.0.0.30 eth0|10.0.0.50 eth0|10.0.0.51 +-----------+-----------+ +-----------+-----------+ +-----------+-----------+ | [ Control Node ] | | [ Network Node ] | | [ Compute Node ] | | | | | | | | MariaDB RabbitMQ | | Open vSwitch | | Libvirt | | Memcached httpd | | L2 Agent | | Nova Compute | | Keystone Glance | | L3 Agent | | Open vSwitch | | Nova API | | Metadata Agent | | L2 Agent | | Neutron Server | | | | | | Metadata Agent | | | | | +-----------------------+ +-----------+-----------+ +-----------+-----------+ eth1|(UP with no IP) eth1|(UP with no IP) |
[1] | Network ノード および Compute ノードの両方で以下のように設定します。 |
# ブリッジ追加 [root@network ~]# ovs-vsctl add-br br-eth1
# 追加したブリッジのポートに [eth1] を追加 # [eth1] は環境によって異なるため自身の名称に置き換え [root@network ~]# ovs-vsctl add-port br-eth1 eth1
[root@network ~]#
vi /etc/neutron/plugins/ml2/ml2_conf.ini # 最終行に追記
[ml2_type_flat]
flat_networks = physnet1
[root@network ~]#
vi /etc/neutron/plugins/ml2/openvswitch_agent.ini # 最終行に追記
[ovs]
bridge_mappings = physnet1:br-eth1 systemctl restart neutron-openvswitch-agent |
[2] | ネットワークを作成します。作業場所はどこでもよいですが、当例では Control ノード上で作業します。 |
[root@dlp ~(keystone)]#
projectID=$(openstack project list | grep service | awk '{print $2}') # [sharednet1] という名称のネットワークを作成 [root@dlp ~(keystone)]# openstack network create --project $projectID \ --share --provider-network-type flat --provider-physical-network physnet1 sharednet1 +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2021-04-23T02:08:44Z | | description | | | dns_domain | None | | id | b0bf65f0-8c33-47f1-b58b-4d2dba6d1a01 | | ipv4_address_scope | None | | ipv6_address_scope | None | | is_default | False | | is_vlan_transparent | None | | mtu | 1500 | | name | sharednet1 | | port_security_enabled | True | | project_id | 620c149e6cc84d7e8f446504cd3cd355 | | provider:network_type | flat | | provider:physical_network | physnet1 | | provider:segmentation_id | None | | qos_policy_id | None | | revision_number | 1 | | router:external | Internal | | segments | None | | shared | True | | status | ACTIVE | | subnets | | | tags | | | updated_at | 2021-04-23T02:08:44Z | +---------------------------+--------------------------------------+ # [sharednet1] に [10.0.0.0/24] のサブネットを作成 [root@dlp ~(keystone)]# openstack subnet create subnet1 --network sharednet1 \ --project $projectID --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 +----------------------+--------------------------------------+ | Field | Value | +----------------------+--------------------------------------+ | allocation_pools | 10.0.0.200-10.0.0.254 | | cidr | 10.0.0.0/24 | | created_at | 2021-04-23T02:09:05Z | | description | | | dns_nameservers | 10.0.0.10 | | dns_publish_fixed_ip | None | | enable_dhcp | True | | gateway_ip | 10.0.0.1 | | host_routes | | | id | ba29524c-6e8e-4937-ac5b-1ca45e353f9c | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | subnet1 | | network_id | b0bf65f0-8c33-47f1-b58b-4d2dba6d1a01 | | prefix_length | None | | project_id | 620c149e6cc84d7e8f446504cd3cd355 | | revision_number | 0 | | segment_id | None | | service_types | | | subnetpool_id | None | | tags | | | updated_at | 2021-04-23T02:09:05Z | +----------------------+--------------------------------------+ # 設定確認 [root@dlp ~(keystone)]# openstack network list +--------------------------------------+------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+------------+--------------------------------------+ | b0bf65f0-8c33-47f1-b58b-4d2dba6d1a01 | sharednet1 | ba29524c-6e8e-4937-ac5b-1ca45e353f9c | +--------------------------------------+------------+--------------------------------------+ |
[3] | 任意のユーザーでログインし、作成したネットワークでインスタンスを作成/起動します。 |
# 利用可能な [flavor] 確認 [cent@dlp ~(keystone)]$ openstack flavor list +----+----------+------+------+-----------+-------+-----------+ | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public | +----+----------+------+------+-----------+-------+-----------+ | 0 | m1.small | 2048 | 10 | 0 | 1 | True | +----+----------+------+------+-----------+-------+-----------+ # 利用可能なイメージ確認 [cent@dlp ~(keystone)]$ openstack image list +--------------------------------------+-----------------+--------+ | ID | Name | Status | +--------------------------------------+-----------------+--------+ | a7f1ad19-4d09-498c-8152-404bf626af98 | CentOS-Stream-8 | active | +--------------------------------------+-----------------+--------+ # 利用可能なネットワーク確認 [cent@dlp ~(keystone)]$ openstack network list +--------------------------------------+------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+------------+--------------------------------------+ | b0bf65f0-8c33-47f1-b58b-4d2dba6d1a01 | sharednet1 | ba29524c-6e8e-4937-ac5b-1ca45e353f9c | +--------------------------------------+------------+--------------------------------------+ # インスタンス用のセキュリティグループを作成 [cent@dlp ~(keystone)]$ openstack security group create secgroup01 +-----------------+-------------------------------------------------------------------------------+ | Field | Value | +-----------------+-------------------------------------------------------------------------------+ | created_at | 2021-04-23T02:11:08Z | | description | secgroup01 | | id | e10f49d8-8961-4716-9fd1-50d9bc833848 | | name | secgroup01 | | project_id | 9bdf6ca0e49a416da8df5554fbfdec74 | | revision_number | 1 | | rules | created_at='2021-04-23T02:11:08Z', direction='egress', ethertype='IPv6',..... | | | created_at='2021-04-23T02:11:08Z', direction='egress', ethertype='IPv4',..... | | stateful | True | | tags | [] | | updated_at | 2021-04-23T02:11:08Z | +-----------------+-------------------------------------------------------------------------------+ # インスタンス接続用の SSH キーペア作成 [cent@dlp ~(keystone)]$ ssh-keygen -q -N "" Enter file in which to save the key (/home/cent/.ssh/id_rsa): # 公開鍵登録 [cent@dlp ~(keystone)]$ openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | created_at | None | | fingerprint | 18:f0:6a:99:8d:66:fb:32:e2:df:e6:88:39:55:f4:c5 | | id | mykey | | is_deleted | None | | name | mykey | | type | ssh | | user_id | b7aeb44b614d46f69b4a53ecee906800 | +-------------+-------------------------------------------------+[cent@dlp ~(keystone)]$ netID=$(openstack network list | grep sharednet1 | awk '{ print $2 }')
[cent@dlp ~(keystone)]$
[cent@dlp ~(keystone)]$ openstack server create --flavor m1.small --image CentOS-Stream-8 --security-group secgroup01 --nic net-id=$netID --key-name mykey CentOS-St-8
openstack server list +--------------------------------------+-------------+--------+-----------------------+-----------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-------------+--------+-----------------------+-----------------+----------+ | 5d9feb61-04e4-4504-91bf-4953150ae6c2 | CentOS-St-8 | ACTIVE | sharednet1=10.0.0.252 | CentOS-Stream-8 | m1.small | +--------------------------------------+-------------+--------+-----------------------+-----------------+----------+ |
[4] | 起動した仮想マシンインスタンスに SSH 接続できるように、先に作成したセキュリティグループにポート許可の設定を追加します。 |
# ICMP 許可 [cent@dlp ~(keystone)]$ openstack security group rule create --protocol icmp --ingress secgroup01 +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | created_at | 2021-04-23T02:13:39Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 6320f85b-7283-49a3-8312-41fdba484a1d | | name | None | | port_range_max | None | | port_range_min | None | | project_id | 9bdf6ca0e49a416da8df5554fbfdec74 | | protocol | icmp | | remote_address_group_id | None | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | e10f49d8-8961-4716-9fd1-50d9bc833848 | | tags | [] | | updated_at | 2021-04-23T02:13:39Z | +-------------------------+--------------------------------------+ # SSH 許可 [cent@dlp ~(keystone)]$ openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01 +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | created_at | 2021-04-23T02:13:56Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 83791930-299d-47b8-9594-1db95481f570 | | name | None | | port_range_max | 22 | | port_range_min | 22 | | project_id | 9bdf6ca0e49a416da8df5554fbfdec74 | | protocol | tcp | | remote_address_group_id | None | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | e10f49d8-8961-4716-9fd1-50d9bc833848 | | tags | [] | | updated_at | 2021-04-23T02:13:56Z | +-------------------------+--------------------------------------+[cent@dlp ~(keystone)]$ openstack security group rule list secgroup01 +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ | ID | IP Protocol | Ethertype | IP Range | Port Range | Direction | Remote Security Group | Remote Address Group | +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ | 18507758-24fc-402e-a922-d687df9ae637 | None | IPv6 | ::/0 | | egress | None | None | | 6320f85b-7283-49a3-8312-41fdba484a1d | icmp | IPv4 | 0.0.0.0/0 | | ingress | None | None | | 83791930-299d-47b8-9594-1db95481f570 | tcp | IPv4 | 0.0.0.0/0 | 22:22 | ingress | None | None | | a49b478e-9ee4-4b23-8324-8be901eef459 | None | IPv4 | 0.0.0.0/0 | | egress | None | None | +--------------------------------------+-------------+-----------+-----------+------------+-----------+-----------------------+----------------------+ |
[5] | インスタンスにログインします。 |
[cent@dlp ~(keystone)]$ ssh centos@10.0.0.252 The authenticity of host '10.0.0.252 (10.0.0.252)' can't be established. ECDSA key fingerprint is SHA256:p8sdsHQwuP7j4OG4OCq25UNP3xm7eVrKHCw44TKh7/w. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.0.0.252' (ECDSA) to the list of known hosts. Activate the web console with: systemctl enable --now cockpit.socket [centos@centos-st-8 ~]$ # ログインできた |
Sponsored Link |