OpenStack Pike : Neutron ネットワークを構成する (FLAT)2017/09/13 |
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 | | L2 Agent | | Libvirt | | Memcached httpd | | L3 Agent | | Nova Compute | | Keystone Glance | | Metadata Agent | | L2 Agent | | Nova API | | | | | | Neutron Server | | | | | | Metadata Agent | | | | | +-----------------------+ +-----------+-----------+ +-----------+-----------+ |eth1 |eth1 |
[1] | Network ノード および Compute ノードの両方で以下のように設定します。 |
root@network:~#
vi /etc/neutron/plugins/ml2/ml2_conf.ini # 166行目:追記 [ml2_type_flat]
flat_networks = physnet1
root@network:~#
vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini # 132行目:追記 [linux_bridge]
physical_interface_mappings = physnet1:eth1
# 176行目:コメント解除して変更 enable_vxlan = false
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 | 2017-09-20T01:39:43Z | | description | | | dns_domain | None | | id | 2ad1fd9f-0267-4955-943c-77f8f833b0a1 | | 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 | 2ead0580b5fa47c991632cef3e66811c | | provider:network_type | flat | | provider:physical_network | physnet1 | | provider:segmentation_id | None | | qos_policy_id | None | | revision_number | 2 | | router:external | Internal | | segments | None | | shared | True | | status | ACTIVE | | subnets | | | tags | | | updated_at | 2017-09-20T01:39: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 Created a new subnet: +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | allocation_pools | 10.0.0.200-10.0.0.254 | | cidr | 10.0.0.0/24 | | created_at | 2017-09-20T01:40:06Z | | description | | | dns_nameservers | 10.0.0.10 | | enable_dhcp | True | | gateway_ip | 10.0.0.1 | | host_routes | | | id | 8232b687-7628-4b6b-8bb6-dcf7ca3fdd3c | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | subnet1 | | network_id | 2ad1fd9f-0267-4955-943c-77f8f833b0a1 | | project_id | 2ead0580b5fa47c991632cef3e66811c | | revision_number | 0 | | segment_id | None | | service_types | | | subnetpool_id | None | | tags | | | updated_at | 2017-09-20T01:40:06Z | | use_default_subnet_pool | None | +-------------------------+--------------------------------------+ # 設定確認 root@dlp ~(keystone)# openstack network list +--------------------------------------+------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+------------+--------------------------------------+ | 2ad1fd9f-0267-4955-943c-77f8f833b0a1 | sharednet1 | 8232b687-7628-4b6b-8bb6-dcf7ca3fdd3c | +--------------------------------------+------------+--------------------------------------+ |
[3] | 作成したネットワークをインスタンスに紐付けてインスタンスを作成・起動します。 |
root@dlp ~(keystone)# netID=`openstack network list | grep sharednet1 | awk '{ print $2 }'` root@dlp ~(keystone)# openstack image list +--------------------------------------+------------+--------+ | ID | Name | Status | +--------------------------------------+------------+--------+ | 1f46b995-47e3-4858-b0b0-9221867462cc | Ubuntu1604 | active | +--------------------------------------+------------+--------+ # キーペア作成 root@dlp ~(keystone)# ssh-keygen -q -N "" Enter file in which to save the key (/root/.ssh/id_rsa): # 公開鍵登録 root@dlp ~(keystone)# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | fingerprint | b3:d6:64:1a:6f:4e:14:63:88:76:15:a4:bd:af:a6:34 | | name | mykey | | user_id | 09d8dfa20e0f40eaae448d369943b195 | +-------------+-------------------------------------------------+
root@dlp ~(keystone)#
root@dlp ~(keystone)# openstack server create --flavor m1.small --image Ubuntu1604 --security-group default --nic net-id=$netID --key-name mykey Ubuntu_1604
openstack server list +--------------------------+-------------+--------+-----------------------+------------+----------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------+-------------+--------+-----------------------+------------+----------+ | 8a7e2586-83ff-4a24-a105- | Ubuntu_1604 | ACTIVE | sharednet1=10.0.0.207 | Ubuntu1604 | m1.small | +--------------------------+-------------+--------+-----------------------+------------+----------+ |
[4] | 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。 |
# ICMP 許可 root@dlp ~(keystone)# openstack security group rule create --protocol icmp --ingress default Created a new security_group_rule: +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2017-09-20T01:44:20Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 75161c5a-86f5-461b-a7ee-fa5c93d4d001 | | name | None | | port_range_max | None | | port_range_min | None | | project_id | 1ca37b956ae4451892dfcc47f5f98913 | | protocol | icmp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | 759a51f1-293e-4eab-90ad-cd2d0947f7aa | | updated_at | 2017-09-20T01:44:20Z | +-------------------+--------------------------------------+ # SSH 許可 root@dlp ~(keystone)# openstack security group rule create --protocol tcp --dst-port 22:22 default Created a new security_group_rule: +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2017-09-20T01:44:37Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 186b327c-0a1a-4edd-96dd-4bd6f4861505 | | name | None | | port_range_max | 22 | | port_range_min | 22 | | project_id | 1ca37b956ae4451892dfcc47f5f98913 | | protocol | tcp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | 759a51f1-293e-4eab-90ad-cd2d0947f7aa | | updated_at | 2017-09-20T01:44:37Z | +-------------------+--------------------------------------+root@dlp ~(keystone)# openstack security group rule list +-----------+-------------+-----------+------------+---------------------------------+-------------------+ | ID | IP Protocol | IP Range | Port Range | Remote Security Group | Security Group | +-----------+-------------+-----------+------------+---------------------------------+-------------------+ | 186b327c- | tcp | 0.0.0.0/0 | 22:22 | None | 759a51f1-293e-... | | 6df1271d- | None | None | | None | 759a51f1-293e-... | | 75161c5a- | icmp | 0.0.0.0/0 | | None | 759a51f1-293e-... | | ab4d81fe- | None | None | | 759a51f1-293e-4eab-90ad-cd2d094 | 759a51f1-293e-... | | c00a8f45- | None | None | | 759a51f1-293e-4eab-90ad-cd2d094 | 759a51f1-293e-... | | c983653c- | None | None | | None | 759a51f1-293e-... | +-----------+-------------+-----------+------------+---------------------------------+-------------------+ |
[5] | インスタンスにログインします。 |
root@dlp ~(keystone)# ssh ubuntu@10.0.0.207
The authenticity of host '10.0.0.207 (10.0.0.207)' can't be established.
ECDSA key fingerprint is SHA256:CdtOqoerKy4q54iALeVFH+SJFX1RLFmUe3VQAlxbXAI.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.207' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-93-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Last login: Fri Sep 15 11:26:30 2017
ubuntu@ubuntu-1604:~$ # ログインできた
|
Sponsored Link |
|