OpenStack Newton : Neutron ネットワーク構成 (FLAT)2016/10/23 |
OpenStack Network Service(Neutron)による仮想ネットワークの構成です。
また、Network ノードと Compute ノードはネットワークインターフェースを二つ持っていることを前提とします。
| +-------------+ +----+----+ | Name Server | | Gateway | +------+------+ +----+----+ |10.0.0.10 |10.0.0.1 | | +------------+-----------------+------------------+ | | | | 10.0.0.200-10.0.0.250 eth0|10.0.0.30 | eth0|10.0.0.50 | +-----------------+ +--------+---------+ | +-----------+----------+ | +---| Virtual Machine | | [ Control Node ] | | | [ Network Node ] | | | +-----------------+ | Keystone | | | DHCP Agent | | | +-----------------+ | Glance | | | L3 Agent |eth1 | |---| Virtual Machine | | Nova API | | | L2 Agent | | | +-----------------+ | Neutron Server | | | Metadata Agent | | | +-----------------+ +------------------+ | +----------------------+ +-----+---| Virtual Machine | | | +-----------------+ | +----------------------+ | +-----------------+ | eth0| [ Compute Node ] | |---| Virtual Machine | +-----| Nova Compute |eth1 | +-----------------+ 10.0.0.51| L2 Agent | | +-----------------+ +----------------------+ +---| Virtual Machine | +-----------------+ |
[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 # 154行目:追記 [ml2_type_flat]
flat_networks = physnet1
[root@network ~]#
vi /etc/neutron/plugins/ml2/openvswitch_agent.ini # 181行目:追記 [ovs]
bridge_mappings = physnet1:br-eth1
systemctl restart neutron-openvswitch-agent |
[2] | ネットワークを作成します。作業場所はどこでもよいですが、ここでは Control ノード上で作業します。 |
[root@dlp ~(keystone)]#
tenantID=`openstack project list | grep service | awk '{print $2}'` # 「sharednet1」という名前のネットワークを作成 [root@dlp ~(keystone)]# neutron net-create --tenant-id $tenantID sharednet1 \ --shared --provider:network_type flat --provider:physical_network physnet1 Created a new network: +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | availability_zone_hints | | | availability_zones | | | created_at | 2016-10-25T07:14:44Z | | description | | | id | e1ac6f12-c77d-4c9a-b453-6ac67c783831 | | ipv4_address_scope | | | ipv6_address_scope | | | mtu | 1500 | | name | sharednet1 | | port_security_enabled | True | | project_id | fb1ebfb4fe2a4ef3918d02932f4de062 | | provider:network_type | flat | | provider:physical_network | physnet1 | | provider:segmentation_id | | | revision_number | 3 | | router:external | False | | shared | True | | status | ACTIVE | | subnets | | | tags | | | tenant_id | fb1ebfb4fe2a4ef3918d02932f4de062 | | updated_at | 2016-10-25T07:14:44Z | +---------------------------+--------------------------------------+ # 作成した「sharednet1」に「10.0.0.0/24」のサブネットを作成 [root@dlp ~(keystone)]# neutron subnet-create \ --tenant-id $tenantID --gateway 10.0.0.1 --dns-nameserver 10.0.0.1 \ --allocation-pool start=10.0.0.200,end=10.0.0.250 sharednet1 10.0.0.0/24 Created a new subnet: +-------------------+----------------------------------------------+ | Field | Value | +-------------------+----------------------------------------------+ | allocation_pools | {"start": "10.0.0.200", "end": "10.0.0.250"} | | cidr | 10.0.0.0/24 | | created_at | 2016-10-25T07:15:20Z | | description | | | dns_nameservers | 10.0.0.1 | | enable_dhcp | True | | gateway_ip | 10.0.0.1 | | host_routes | | | id | 6034d9f8-d4a8-43db-b6a6-936403622807 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | | | network_id | e1ac6f12-c77d-4c9a-b453-6ac67c783831 | | project_id | fb1ebfb4fe2a4ef3918d02932f4de062 | | revision_number | 2 | | service_types | | | subnetpool_id | | | tenant_id | fb1ebfb4fe2a4ef3918d02932f4de062 | | updated_at | 2016-10-25T07:15:20Z | +-------------------+----------------------------------------------+ # 設定確認 [root@dlp ~(keystone)]# neutron net-list +--------------------------------------+------------+--------------------------------------------------+ | id | name | subnets | +--------------------------------------+------------+--------------------------------------------------+ | e1ac6f12-c77d-4c9a-b453-6ac67c783831 | sharednet1 | 6034d9f8-d4a8-43db-b6a6-936403622807 10.0.0.0/24 | +--------------------------------------+------------+--------------------------------------------------+ |
[3] | 作成したネットワークをインスタンスに紐付けてインスタンスを作成・起動します。 |
[root@dlp ~(keystone)]# netID=`neutron net-list | grep sharednet1 | awk '{print $2}'` [root@dlp ~(keystone)]# openstack image list +--------------------------------------+---------+--------+ | ID | Name | Status | +--------------------------------------+---------+--------+ | 0f695de0-2bf6-4a51-93ea-0c87ac6a3d07 | CentOS7 | active | +--------------------------------------+---------+--------+
[root@dlp ~(keystone)]#
[root@dlp ~(keystone)]# openstack server create --flavor m1.small --image CentOS7 --security-group default --nic net-id=$netID CentOS_7
openstack server list +-----------+----------+--------+-----------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------+----------+--------+-----------------------+------------+ | f1908b43- | CentOS_7 | ACTIVE | sharednet1=10.0.0.201 | CentOS7 | +-----------+----------+--------+-----------------------+------------+ |
[4] | 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。 |
# ICMP 許可 [root@dlp ~(keystone)]# neutron security-group-rule-create --direction ingress --protocol icmp default Created a new security_group_rule: +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2016-10-25T05:43:31Z | | description | | | direction | ingress | | ethertype | IPv4 | | id | bcb97399-f401-4c20-b7db-c3c25fc816b4 | | port_range_max | | | port_range_min | | | project_id | 150e205a8791426e8028a94699fb8848 | | protocol | icmp | | remote_group_id | | | remote_ip_prefix | | | revision_number | 1 | | security_group_id | 572bb509-9c34-44cf-ab38-408e5b9cddb8 | | tenant_id | 150e205a8791426e8028a94699fb8848 | | updated_at | 2016-10-25T05:43:31Z | +-------------------+--------------------------------------+ # SSH 許可 [root@dlp ~(keystone)]# neutron security-group-rule-create --direction ingress --protocol tcp --port_range_min 22 --port_range_max 22 default Created a new security_group_rule: +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2016-10-25T05:43:48Z | | description | | | direction | ingress | | ethertype | IPv4 | | id | 5aae60db-71e2-4b7e-9eda-bd556dbed8aa | | port_range_max | 22 | | port_range_min | 22 | | project_id | 150e205a8791426e8028a94699fb8848 | | protocol | tcp | | remote_group_id | | | remote_ip_prefix | | | revision_number | 1 | | security_group_id | 572bb509-9c34-44cf-ab38-408e5b9cddb8 | | tenant_id | 150e205a8791426e8028a94699fb8848 | | updated_at | 2016-10-25T05:43:48Z | +-------------------+--------------------------------------+[root@dlp ~(keystone)]# neutron security-group-rule-list +--------------------------------------+----------------+-----------+-----------+---------------+-----------------+ | id | security_group | direction | ethertype | port/protocol | remote | +--------------------------------------+----------------+-----------+-----------+---------------+-----------------+ | 1867284b-45e6-4c64-95f7-408c7c00a82f | default | egress | IPv4 | any | any | | 5aae60db-71e2-4b7e-9eda-bd556dbed8aa | default | ingress | IPv4 | 22/tcp | any | | b44e29e3-a37b-41fa-9169-1bc102e3891d | default | egress | IPv6 | any | any | | bcb97399-f401-4c20-b7db-c3c25fc816b4 | default | ingress | IPv4 | icmp | any | | d534b39e-34ab-4f34-ae30-7205a7c6c511 | default | ingress | IPv4 | any | default (group) | | d672c429-55a1-4e7a-9ae8-99ee0cab0df8 | default | ingress | IPv6 | any | default (group) | +--------------------------------------+----------------+-----------+-----------+---------------+-----------------+ |
[5] | インスタンスにログインします。 |
[root@dlp ~(keystone)]# ssh 10.0.0.201
The authenticity of host '10.0.0.201 (10.0.0.201)' can't be established.
ECDSA key fingerprint is 9b:1f:83:37:ef:3e:01:80:4e:dc:38:50:6f:a0:83:2d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.201' (ECDSA) to the list of known hosts.
root@10.0.0.201's password:
Last login: Mon Oct 24 17:20:01 2016
[root@localhost ~]# # ログインできた
|
Sponsored Link |