next up previous contents
Next: Self-service Network Up: Virtual Network Previous: Virtual Network   Contents

Proivder Network

  1. 要開始 instance 前,必須先產生 virtual networks,載入 openstack 管理者 admin 環境變數。
    [root@ip112 ~]# source admin.token
    
  2. 產生新的網路,-share 允許所有 projects 使用,-external 設定為對外網路。
    [root@ip112 ~]# openstack network create  --share --external \
    --provider-physical-network provider \
    --provider-network-type flat provider
    +---------------------------+--------------------------------------+
    | Field                     | Value                                |
    +---------------------------+--------------------------------------+
    | admin_state_up            | UP                                   |
    | availability_zone_hints   |                                      |
    | availability_zones        |                                      |
    | created_at                | 2018-05-26T07:25:41Z                 |
    | description               |                                      |
    | dns_domain                | None                                 |
    | id                        | 0b0ebcee-057b-4798-bf73-5dd449e7879a |
    | ipv4_address_scope        | None                                 |
    | ipv6_address_scope        | None                                 |
    | is_default                | False                                |
    | is_vlan_transparent       | None                                 |
    | mtu                       | 1500                                 |
    | name                      | provider                             |
    | port_security_enabled     | True                                 |
    | project_id                | e28adc716118434c96b5833867faa08c     |
    | provider:network_type     | flat                                 |
    | provider:physical_network | provider                             |
    | provider:segmentation_id  | None                                 |
    | qos_policy_id             | None                                 |
    | revision_number           | 5                                    |
    | router:external           | External                             |
    | segments                  | None                                 |
    | shared                    | True                                 |
    | status                    | ACTIVE                               |
    | subnets                   |                                      |
    | tags                      |                                      |
    | updated_at                | 2018-05-26T07:25:41Z                 |
    +---------------------------+--------------------------------------+
    
  3. 查詢 network,出現 provider。
    [root@controller ~]# openstack network list
    +--------------------------------------+----------+---------+
    | ID                                   | Name     | Subnets |
    +--------------------------------------+----------+---------+
    | 0b0ebcee-057b-4798-bf73-5dd449e7879a | provider |         |
    +--------------------------------------+----------+---------+
    
  4. 產生子網域 163.17.10.0/24,此網段為 provider 橋接對外網卡 em2 的網段。
    [root@controller ~]# grep provider:em2 -R /etc/neutron/
    /etc/neutron/plugins/ml2/linuxbridge_agent.ini:physical_interface_mappings = provider:em2
    
    [root@ip112 ~]# openstack subnet create --network provider \
    --allocation-pool start=163.17.10.113,end=163.17.10.200 \
    --dns-nameserver 8.8.8.8 --gateway 163.17.10.254 \
    --subnet-range 163.17.10.0/24 provider
    +-------------------+--------------------------------------+
    | Field             | Value                                |
    +-------------------+--------------------------------------+
    | allocation_pools  | 163.17.10.113-163.17.10.200          |
    | cidr              | 163.17.10.0/24                       |
    | created_at        | 2018-05-26T07:32:01Z                 |
    | description       |                                      |
    | dns_nameservers   | 8.8.8.8                              |
    | enable_dhcp       | True                                 |
    | gateway_ip        | 163.17.10.254                        |
    | host_routes       |                                      |
    | id                | 2a7287d7-4a4f-43cc-beb2-bc9c023af929 |
    | ip_version        | 4                                    |
    | ipv6_address_mode | None                                 |
    | ipv6_ra_mode      | None                                 |
    | name              | provider                             |
    | network_id        | 0b0ebcee-057b-4798-bf73-5dd449e7879a |
    | project_id        | e28adc716118434c96b5833867faa08c     |
    | revision_number   | 0                                    |
    | segment_id        | None                                 |
    | service_types     |                                      |
    | subnetpool_id     | None                                 |
    | tags              |                                      |
    | updated_at        | 2018-05-26T07:32:01Z                 |
    +-------------------+--------------------------------------+
    
  5. 查詢網路 provider 出現 subnet。
    [root@controller ~]# openstack network list
    +--------------------------------------+----------+--------------------------------------+
    | ID                                   | Name     | Subnets                              |
    +--------------------------------------+----------+--------------------------------------+
    | 0b0ebcee-057b-4798-bf73-5dd449e7879a | provider | 2a7287d7-4a4f-43cc-beb2-bc9c023af929 |
    +--------------------------------------+----------+--------------------------------------+
    
  6. 查詢網路 subnet,id 為 2a7287d7-4a4f-43cc-beb2-bc9c023af929,出現 subnet 網段為 163.17.10.0/24。
    [root@controller ~]# openstack subnet list
    +--------------------------------------+----------+--------------------------------------+----------------+
    | ID                                   | Name     | Network                              | Subnet         |
    +--------------------------------------+----------+--------------------------------------+----------------+
    | 2a7287d7-4a4f-43cc-beb2-bc9c023af929 | provider | 0b0ebcee-057b-4798-bf73-5dd449e7879a | 163.17.10.0/24 |
    +--------------------------------------+----------+--------------------------------------+----------------+
    
  7. 查詢 port,subnet 2a7287d7-4a4f-43cc-beb2-bc9c023af929 有一個 port,IP 為 163.17.10.113 為產生網路時設定的 IP 起點。
    [root@controller ~]# openstack port list
    +--------------------------------------+------+-------------------+----------------------------
    | ID                                   | Name | MAC Address       | Fixed IP Addresses         
    +--------------------------------------+------+-------------------+----------------------------
    | 0e5cf9d2-eed5-41e0-978b-f816ba0e85d6 |      | fa:16:3e:d3:7a:11 | ip_address='163.17.10.113',
    +--------------------------------------+------+-------------------+----------------------------
    --------------------------------------------------+--------+
                                                      | Status |
    --------------------------------------------------+--------+
     subnet_id='2a7287d7-4a4f-43cc-beb2-bc9c023af929' | ACTIVE |
    --------------------------------------------------+--------+
    
  8. ping 163.17.10.113 port,成功回覆。
    [root@controller ~]# ping -c3 163.17.10.113
    PING 163.17.10.113 (163.17.10.113) 56(84) bytes of data.
    64 bytes from 163.17.10.113: icmp_seq=1 ttl=64 time=0.055 ms
    64 bytes from 163.17.10.113: icmp_seq=2 ttl=64 time=0.043 ms
    64 bytes from 163.17.10.113: icmp_seq=3 ttl=64 time=0.042 ms
    
    --- 163.17.10.113 ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2000ms
    rtt min/avg/max/mdev = 0.042/0.046/0.055/0.009 ms
    



De-Yu Wang 2018-12-12