OpenStack Victoria : Neutron ネットワークを構成 (FLAT)2021/08/31 |
OpenStack Network Service(Neutron)による仮想ネットワークの構成です。
例として、FLAT タイプのネットワークを構成します。
事前に以下のように Control ノード、 Network ノード、 Compute ノードの 各 Neutron サービスノードを構築済みであることが前提です。
また、当例では Network ノードと Compute ノードが 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) eth1|(UP with no IP) |
[1] | Network ノード および Compute ノードの両方で以下のように設定します。 |
root@network:~#
vi /etc/neutron/plugins/ml2/ml2_conf.ini # 174行目 : 変更 [ml2_type_flat] ..... ..... flat_networks = physnet1
root@network:~#
vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini # 162行目 : 追記 [linux_bridge]
physical_interface_mappings = physnet1:eth1
systemctl restart neutron-linuxbridge-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 Created a new network: +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2021-08-31T08:42:39Z | | description | | | dns_domain | None | | id | b5cbb9ab-9600-413e-bdf0-fb3749213367 | | 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 | 1718217eee4b4f2ea143d65122864fe0 | | 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-08-31T08:42:39Z | +---------------------------+--------------------------------------+ # [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 Created a new subnet: +----------------------+--------------------------------------+ | Field | Value | +----------------------+--------------------------------------+ | allocation_pools | 10.0.0.200-10.0.0.254 | | cidr | 10.0.0.0/24 | | created_at | 2021-08-31T08:43:01Z | | description | | | dns_nameservers | 10.0.0.10 | | dns_publish_fixed_ip | None | | enable_dhcp | True | | gateway_ip | 10.0.0.1 | | host_routes | | | id | 4ccef7c3-7318-4479-b372-e52d96e189f3 | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | subnet1 | | network_id | b5cbb9ab-9600-413e-bdf0-fb3749213367 | | prefix_length | None | | project_id | 1718217eee4b4f2ea143d65122864fe0 | | revision_number | 0 | | segment_id | None | | service_types | | | subnetpool_id | None | | tags | | | updated_at | 2021-08-31T08:43:01Z | +----------------------+--------------------------------------+ # 設定確認 root@dlp ~(keystone)# openstack network list +--------------------------------------+------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+------------+--------------------------------------+ | b5cbb9ab-9600-413e-bdf0-fb3749213367 | sharednet1 | 4ccef7c3-7318-4479-b372-e52d96e189f3 | +--------------------------------------+------------+--------------------------------------+ |
[3] | 任意のユーザーでログインし、作成したネットワークをインスタンスに紐付けてインスタンスを作成/起動します。 |
# 利用可能な [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 | +--------------------------------------+------------+--------------------------------------+ | b5cbb9ab-9600-413e-bdf0-fb3749213367 | sharednet1 | 4ccef7c3-7318-4479-b372-e52d96e189f3 | +--------------------------------------+------------+--------------------------------------+ # インスタンス用のセキュリティグループを作成 debian@dlp ~(keystone)$ openstack security group create secgroup01 +-----------------+---------------------------------------------------------------------------+ | Field | Value | +-----------------+---------------------------------------------------------------------------+ | created_at | 2021-08-31T09:11:50Z | | description | secgroup01 | | id | 3917ede8-a357-46cd-af3c-df112b7c4193 | | name | secgroup01 | | project_id | cba75a02a921457db62b660f3d0b57c4 | | revision_number | 1 | | rules | created_at='2021-08-31T09:11:50Z', direction='egress', ethertype='IP..... | | | created_at='2021-08-31T09:11:50Z', direction='egress', ethertype='IP..... | | stateful | True | | tags | [] | | updated_at | 2021-08-31T09:11:50Z | +-----------------+---------------------------------------------------------------------------+ # インスタンス接続用の 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 | ef:8a:e6:db:00:11:30:dd:02:b1:b6:b0:9f:2d:57:02 | | name | mykey | | user_id | 62a91aa559f64acab11861ed7cd51ecc | +-------------+-------------------------------------------------+debian@dlp ~(keystone)$ netID=$(openstack network list | grep sharednet1 | 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 | +--------------------------------------+-----------+--------+-----------------------+----------+----------+ | e2144a46-183e-481e-8b40-5bf517b1431a | Debian-11 | ACTIVE | sharednet1=10.0.0.254 | Debian11 | m1.small | +--------------------------------------+-----------+--------+-----------------------+----------+----------+ |
[4] | 起動した仮想マシンインスタンスに SSH 接続できるように、先に作成したセキュリティグループにポート許可の設定を追加します。 |
# ICMP 許可 debian@dlp ~(keystone)$ openstack security group rule create --protocol icmp --ingress secgroup01 +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2021-08-31T09:15:02Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 45c81656-5cb9-4199-9ffc-8a1657e79e17 | | 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 | 3917ede8-a357-46cd-af3c-df112b7c4193 | | tags | [] | | updated_at | 2021-08-31T09:15:02Z | +-------------------+--------------------------------------+ # SSH 許可 debian@dlp ~(keystone)$ openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01 +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2021-08-31T09:15:17Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 84b92a0d-0237-47ae-a175-d2bce07475f4 | | 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 | 3917ede8-a357-46cd-af3c-df112b7c4193 | | tags | [] | | updated_at | 2021-08-31T09:15:17Z | +-------------------+--------------------------------------+debian@dlp ~(keystone)$ openstack security group rule list secgroup01 +--------------------------------------+-------------+-----------+-----------+------------+-----------------------+ | ID | IP Protocol | Ethertype | IP Range | Port Range | Remote Security Group | +--------------------------------------+-------------+-----------+-----------+------------+-----------------------+ | 1e25e933-e2cd-47a6-b729-7d19ba8b59e8 | None | IPv4 | 0.0.0.0/0 | | None | | 45c81656-5cb9-4199-9ffc-8a1657e79e17 | icmp | IPv4 | 0.0.0.0/0 | | None | | 84b92a0d-0237-47ae-a175-d2bce07475f4 | tcp | IPv4 | 0.0.0.0/0 | 22:22 | None | | efca3489-674f-4bba-8a7a-29eb5ead212d | None | IPv6 | ::/0 | | None | +--------------------------------------+-------------+-----------+-----------+------------+-----------------------+ |
[5] | インスタンスにログインします。 |
debian@dlp ~(keystone)$ ssh debian@10.0.0.254
The authenticity of host '10.0.0.254 (10.0.0.254)' can't be established.
ECDSA key fingerprint is SHA256:InwJlXliarVPnOMqwbUgb9rMo7qY6TeFMbbqoGUOm94.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.0.0.254' (ECDSA) to the list of known hosts.
Linux debian 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:~$ # ログインできた
|
Sponsored Link |