next up previous contents
Next: Nova Compute and Controller Up: Quantum 網路服務 Previous: 設定 openvswitch   Contents

設定用戶網路

  1. 使用一般用戶 myuser,設定私有網路。
    [root@kvm4 ~(keystone_quantum)]# source keystonerc_myuser 
    [root@kvm4 ~(keystone_myuser)]#
    
  2. 產生名為 router1 的路由。
    [root@kvm4 ~(keystone_myuser)]# quantum router-create router1
    Created a new router:
    +-----------------------+--------------------------------------+
    | Field                 | Value                                |
    +-----------------------+--------------------------------------+
    | admin_state_up        | True                                 |
    | external_gateway_info |                                      |
    | id                    | 8ab14c8e-c533-47f6-ab63-fc277fada633 |
    | name                  | router1                              |
    | status                | ACTIVE                               |
    | tenant_id             | 6c26d132e38f4b83a1d9f5a777beeb52     |
    +-----------------------+--------------------------------------+
    
  3. 產生名為 private 的網路。
    [root@kvm4 ~(keystone_myuser)]# quantum net-create private
    Created a new network:
    +-----------------+--------------------------------------+
    | Field           | Value                                |
    +-----------------+--------------------------------------+
    | admin_state_up  | True                                 |
    | id              | 48e9c08e-158d-4c6a-9623-b4eeaea5716c |
    | name            | private                              |
    | router:external | False                                |
    | shared          | False                                |
    | status          | ACTIVE                               |
    | subnets         |                                      |
    | tenant_id       | 6c26d132e38f4b83a1d9f5a777beeb52     |
    +-----------------+--------------------------------------+
    
  4. 產生網路 private 的子網路,名為 subpriv,網域為 192.168.32.0/24。
    [root@kvm4 ~(keystone_myuser)]# quantum subnet-create --name subpriv private 192.168.32.0/24
    Created a new subnet:
    +------------------+----------------------------------------------------+
    | Field            | Value                                              |
    +------------------+----------------------------------------------------+
    | allocation_pools | {"start": "192.168.32.2", "end": "192.168.32.254"} |
    | cidr             | 192.168.32.0/24                                    |
    | dns_nameservers  |                                                    |
    | enable_dhcp      | True                                               |
    | gateway_ip       | 192.168.32.1                                       |
    | host_routes      |                                                    |
    | id               | af75410d-6cf3-457c-a393-891641e563db               |
    | ip_version       | 4                                                  |
    | name             | subpriv                                            |
    | network_id       | 48e9c08e-158d-4c6a-9623-b4eeaea5716c               |
    | tenant_id        | 6c26d132e38f4b83a1d9f5a777beeb52                   |
    +------------------+----------------------------------------------------+
    
  5. 設定子網路 subpriv 的路由為 router1。
    [root@kvm4 ~(keystone_myuser)]# quantum router-interface-add router1 subpriv
    Added interface to router router1
    
  6. 確認 interface。
    [root@kvm4 ~(keystone_myuser)]# quantum port-list 
    +--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
    | id                                   | name | mac_address       | fixed_ips                                                                           |
    +--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
    | 2083dc85-3b21-4aec-b88f-b4865fab4b4d |      | fa:16:3e:b4:ca:2d | {"subnet_id": "af75410d-6cf3-457c-a393-891641e563db", "ip_address": "192.168.32.1"} |
    +--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
    
  7. 為產生對外的公開網路,先匯入管理者 admin 的環境變數。
    [root@kvm4 ~(keystone_myuser)]# source keystonerc_admin 
    [root@kvm4 ~(keystone_admin)]#
    
  8. 產生名為 public 的公開網路。
    [root@kvm4 ~(keystone_admin)]# quantum net-create \
    --tenant-id services public -- --router:external=True
    Created a new network:
    +---------------------------+--------------------------------------+
    | Field                     | Value                                |
    +---------------------------+--------------------------------------+
    | admin_state_up            | True                                 |
    | id                        | f9179863-802b-4a9c-b711-206dc9a5a9b4 |
    | name                      | public                               |
    | provider:network_type     | local                                |
    | provider:physical_network |                                      |
    | provider:segmentation_id  |                                      |
    | router:external           | True                                 |
    | shared                    | False                                |
    | status                    | ACTIVE                               |
    | subnets                   |                                      |
    | tenant_id                 | services                             |
    +---------------------------+--------------------------------------+
    
  9. 產生網路 public 的子網路,名為 subpub,網域必須為目前對外網域,故為 192.168.122.0/24,gateway 要設定正確,否則無法連接外部網路。目前 192.168.122.0/24 網域已存在 dhcp,所以此子網路關閉 dhcp,且 ip 開始至結束的範圍也要避開已正在使用的 ip。
    [root@kvm4 ~(keystone_admin)]# quantum subnet-create \
    --tenant-id services \
    --allocation-pool start=192.168.122.10,end=192.168.122.99 \
    --gateway 192.168.122.1 \
    --disable-dhcp \
    --name subpub public 192.168.122.0/24
    Created a new subnet:
    +------------------+------------------------------------------------------+
    | Field            | Value                                                |
    +------------------+------------------------------------------------------+
    | allocation_pools | {"start": "192.168.122.10", "end": "192.168.122.99"} |
    | cidr             | 192.168.122.0/24                                     |
    | dns_nameservers  |                                                      |
    | enable_dhcp      | False                                                |
    | gateway_ip       | 192.168.122.1                                        |
    | host_routes      |                                                      |
    | id               | 76055bb3-ebb3-4e75-8971-64d90c5d8af6                 |
    | ip_version       | 4                                                    |
    | name             | subpub                                               |
    | network_id       | f9179863-802b-4a9c-b711-206dc9a5a9b4                 |
    | tenant_id        | services                                             |
    +------------------+------------------------------------------------------+
    
  10. 設定網路 public,作為路由 router1 的 gateway。
    [root@kvm4 ~(keystone_admin)]# quantum router-gateway-set router1 public
    Set gateway for router router1
    
  11. 列出 port,發現網路 public 的路由已被指定 ip 為 192.168.122.10。
    [root@kvm4 ~(keystone_admin)]# quantum port-list
    +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
    | id                                   | name | mac_address       | fixed_ips                                                                             |
    +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
    | 68e1526f-523b-41ba-bc9b-e8d0804bacd7 |      | fa:16:3e:97:53:5a | {"subnet_id": "69336db7-7888-48ef-a2c8-acb4a29ed224", "ip_address": "192.168.32.1"}   |
    | c66c16a0-6314-468b-b354-59263711ae7b |      | fa:16:3e:d5:97:7c | {"subnet_id": "6973d14c-ae1a-4759-af7a-3ee3c4eb63c2", "ip_address": "192.168.122.10"} |
    +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
    
  12. 匯入一般使用者 myuser 環境變數。
    [root@kvm4 ~(keystone_admin)]# source keystonerc_myuser 
    [root@kvm4 ~(keystone_myuser)]#
    
  13. 在網路 public 中產生浮動 ip。
    [root@kvm4 ~(keystone_myuser)]# quantum floatingip-create public
    Created a new floatingip:
    +---------------------+--------------------------------------+
    | Field               | Value                                |
    +---------------------+--------------------------------------+
    | fixed_ip_address    |                                      |
    | floating_ip_address | 192.168.122.10                       |
    | floating_network_id | f9179863-802b-4a9c-b711-206dc9a5a9b4 |
    | id                  | 9a01e37b-8927-4311-9b6e-9615df28eb0f |
    | port_id             |                                      |
    | router_id           |                                      |
    | tenant_id           | 6c26d132e38f4b83a1d9f5a777beeb52     |
    +---------------------+--------------------------------------+
    
  14. 列出浮動 ip 為 192.168.122.10。
    [root@kvm4 ~(keystone_myuser)]# quantum floatingip-list 
    +--------------------------------------+------------------+---------------------+---------+
    | id                                   | fixed_ip_address | floating_ip_address | port_id |
    +--------------------------------------+------------------+---------------------+---------+
    | 9a01e37b-8927-4311-9b6e-9615df28eb0f |                  | 192.168.122.10      |         |
    +--------------------------------------+------------------+---------------------+---------+
    


2015-12-29