OpenStack Rocky : Neutron ネットワークを構成する (FLAT)2018/08/31 |
OpenStack Network Service(Neutron)による仮想ネットワークの構成です。
例として、FLAT タイプのプロバイダーネットワークを構成します。
事前に以下のように Control ノード、 Network ノード、 Compute ノードの 各 Neutron サービスノードを構築済みであることが前提です。
また、当例では Network ノードと Compute ノードが二つのネットワークインターフェースを持っているものとします。
------------+---------------------------+---------------------------+------------ | | | 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を追加 [root@network ~]# ovs-vsctl add-port br-eth1 eth1
[root@network ~]#
vi /etc/neutron/plugins/ml2/ml2_conf.ini # 181行目:追記 [ml2_type_flat]
flat_networks = physnet1
[root@network ~]#
vi /etc/neutron/plugins/ml2/openvswitch_agent.ini # 194行目:追記 [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 Created a new network: +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2018-08-31T06:00:22Z | | description | | | dns_domain | None | | id | 31b6274c-cdf7-4381-b0f2-f3cd238efac2 | | 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 | ece4ac6c7e764a979e36ba0b2faf848e | | provider:network_type | flat | | provider:physical_network | physnet1 | | provider:segmentation_id | None | | qos_policy_id | None | | revision_number | 0 | | router:external | Internal | | segments | None | | shared | True | | status | ACTIVE | | subnets | | | tags | | | updated_at | 2018-08-31T06:00:23Z | +---------------------------+--------------------------------------+ # [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 | 2018-08-31T06:00:50Z | | description | | | dns_nameservers | 10.0.0.10 | | enable_dhcp | True | | gateway_ip | 10.0.0.1 | | host_routes | | | id | f0745084-3229-484c-ba89-51865a17db42 | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | subnet1 | | network_id | 31b6274c-cdf7-4381-b0f2-f3cd238efac2 | | project_id | ece4ac6c7e764a979e36ba0b2faf848e | | revision_number | 0 | | segment_id | None | | service_types | | | subnetpool_id | None | | tags | | | updated_at | 2018-08-31T06:00:50Z | +-------------------+--------------------------------------+ # 設定確認 [root@dlp ~(keystone)]# openstack network list +--------------------------------------+------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+------------+--------------------------------------+ | 31b6274c-cdf7-4381-b0f2-f3cd238efac2 | sharednet1 | f0745084-3229-484c-ba89-51865a17db42 | +--------------------------------------+------------+--------------------------------------+ |
[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 | +--------------------------------------+---------+--------+ | 05269b20-9625-46b6-8377-3893c70906bd | CentOS7 | active | +--------------------------------------+---------+--------+ # 利用可能なネットワーク確認 [cent@dlp ~(keystone)]$ openstack network list +--------------------------------------+------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+------------+--------------------------------------+ | 31b6274c-cdf7-4381-b0f2-f3cd238efac2 | sharednet1 | f0745084-3229-484c-ba89-51865a17db42 | +--------------------------------------+------------+--------------------------------------+ # インスタンス用のセキュリティグループを作成 [cent@dlp ~(keystone)]$ openstack security group create secgroup01 +-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ | Field | Value | +-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ | created_at | 2018-08-31T06:03:46Z | | description | secgroup01 | | id | a45a7ec0-fa37-4477-921e-54cdccfe0aee | | name | secgroup01 | | project_id | cabdf1684bf8495289ba64f16281d8cd | | revision_number | 1 | | rules | created_at='2018-08-31T06:03:46Z', direction='egress', ethertype='IPv4', id='39139c6c-5453-4f98-9b64-9f51b7a6f043', updated_at='2018-08-31T06:03:46Z' | | | created_at='2018-08-31T06:03:47Z', direction='egress', ethertype='IPv6', id='7906ac2b-5261-43f8-a3b1-b9726ef555bc', updated_at='2018-08-31T06:03:47Z' | | tags | [] | | updated_at | 2018-08-31T06:03:46Z | +-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ # インスタンス接続用の 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 | +-------------+-------------------------------------------------+ | fingerprint | 0b:3d:7f:df:8a:06:95:8f:7c:91:18:99:44:6b:59:4c | | name | mykey | | user_id | 5da9a7ce84334c71bddaf7ebc2e34ead | +-------------+-------------------------------------------------+[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 CentOS7 --security-group secgroup01 --nic net-id=$netID --key-name mykey CentOS_7
openstack server list +--------------------------------------+----------+--------+-----------------------+---------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+----------+--------+-----------------------+---------+----------+ | 0ecc07c2-197d-4863-ad50-d2846dcb7cca | CentOS_7 | ACTIVE | sharednet1=10.0.0.204 | CentOS7 | m1.small | +--------------------------------------+----------+--------+-----------------------+---------+----------+ |
[4] | 起動した仮想マシンインスタンスに SSH 接続できるように、先に作成したセキュリティグループにポート許可の設定を追加します。 |
# ICMP 許可 [cent@dlp ~(keystone)]$ openstack security group rule create --protocol icmp --ingress secgroup01 +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2018-08-31T06:05:44Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | bbd5b382-845e-4e06-bbc1-6bbf8a11dd84 | | name | None | | port_range_max | None | | port_range_min | None | | project_id | cabdf1684bf8495289ba64f16281d8cd | | protocol | icmp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | a45a7ec0-fa37-4477-921e-54cdccfe0aee | | updated_at | 2018-08-31T06:05:44Z | +-------------------+--------------------------------------+ # SSH 許可 [cent@dlp ~(keystone)]$ openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01 +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2018-08-31T06:06:00Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 24cadf7c-963d-4ab5-b730-ec2b32f88234 | | name | None | | port_range_max | 22 | | port_range_min | 22 | | project_id | cabdf1684bf8495289ba64f16281d8cd | | protocol | tcp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | a45a7ec0-fa37-4477-921e-54cdccfe0aee | | updated_at | 2018-08-31T06:06:00Z | +-------------------+--------------------------------------+[cent@dlp ~(keystone)]$ openstack security group rule list +--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+ | ID | IP Protocol | IP Range | Port Range | Remote Security Group | Security Group | +--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+ | 24cadf7c-963d-4ab5-b730-ec2b32f88234 | tcp | 0.0.0.0/0 | 22:22 | None | a45a7ec0-fa37-4477-921e-54cdccfe0aee | | 39139c6c-5453-4f98-9b64-9f51b7a6f043 | None | None | | None | a45a7ec0-fa37-4477-921e-54cdccfe0aee | | 613a6466-552d-4e7c-9d12-7ae2d0328d9f | None | None | | fed8b67f-a614-441d-a898-12b554d5007d | fed8b67f-a614-441d-a898-12b554d5007d | | 7906ac2b-5261-43f8-a3b1-b9726ef555bc | None | None | | None | a45a7ec0-fa37-4477-921e-54cdccfe0aee | | bbd5b382-845e-4e06-bbc1-6bbf8a11dd84 | icmp | 0.0.0.0/0 | | None | a45a7ec0-fa37-4477-921e-54cdccfe0aee | | c127b405-3c40-4cdd-b7b2-96cf22e7d6b3 | None | None | | fed8b67f-a614-441d-a898-12b554d5007d | fed8b67f-a614-441d-a898-12b554d5007d | | e960b3f5-4008-4fb6-b3c9-da617554826c | None | None | | None | fed8b67f-a614-441d-a898-12b554d5007d | | f3fbe6ae-4f6f-4761-a1d5-cd473d556f48 | None | None | | None | fed8b67f-a614-441d-a898-12b554d5007d | +--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+ |
[5] | インスタンスにログインします。 |
[cent@dlp ~(keystone)]$ ssh centos@10.0.0.204
The authenticity of host '10.0.0.204 (10.0.0.204)' can't be established.
ECDSA key fingerprint is SHA256:a6aknOruK4Or1IjIZbgYgp+IswyON5L7gjQtGpG0SVw.
ECDSA key fingerprint is MD5:1f:b0:09:b7:eb:3b:54:ff:3f:e2:9d:b3:46:20:08:e7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.204' (ECDSA) to the list of known hosts.
[centos@centos-7 ~]$ # ログインできた
|
Sponsored Link |