一.网络选项1


创建提供商网络

创建提供商网络

  1. #创建网络
  2. openstack network create --share --external --provider-physical-network provider --provider-network-type flat provider
  3. #创建子网
  4. openstack subnet create --network provider --allocation-pool start=START_IP_ADDRESS,end=END_IP_ADDRESS --dns-nameserver DNS_RESOLVER --gateway PROVIDER_NETWORK_GATEWAY --subnet-range PROVIDER_NETWORK_CIDR provider
  5. #例子
  6. openstack subnet create --network provider --allocation-pool start=10.0.0.100,end=10.0.0.250 --dns-nameserver 8.8.4.4 --gateway 10.0.0.1 --subnet-range 10.0.0.0/24 provider

二.网络选项2


如果使用网络选项2,需要创建提供商网络和自助网络

1.创建提供商网络

创建提供商网络

  1. #创建网络
  2. openstack network create --share --external --provider-physical-network provider --provider-network-type flat provider
  3. #创建子网
  4. openstack subnet create --network provider --allocation-pool start=10.0.0.100,end=10.0.0.250 --dns-nameserver 8.8.4.4 --gateway 10.0.0.1 --subnet-range 10.0.0.0/24 provider

2.创建自助网络

创建自助网络

  1. #创建网络
  2. openstack network create selfservice
  3. #创建子网
  4. openstack subnet create --network selfservice --dns-nameserver DNS_RESOLVER --gateway SELFSERVICE_NETWORK_GATEWAY --subnet-range SELFSERVICE_NETWORK_CIDR selfservice
  5. #例子
  6. openstack subnet create --network selfservice --dns-nameserver 192.168.189.2 --gateway 10.0.0.1 --subnet-range 10.0.0.0/24 selfservice

3.创建路由器

  1. #创建路由器
  2. openstack router create router
  3. #将自助服务网络子网添加为路由器上的接口:
  4. openstack router add subnet router selfservice
  5. #在路由器上的提供程序网络上设置网关
  6. openstack router set router --external-gateway provider

4.验证

  1. #列出网络命名空间。您应该看到一个命名空间qrouter和两个命名空间qdhcp
  2. $ ip netns
  3. qrouter-89dd2083-a160-4d75-ab3a-14239f01ea0b
  4. qdhcp-7c6f9b37-76b4-463e-98d8-27e5686ed083
  5. qdhcp-0e62efcd-8cee-46c7-b163-d8df05c3c5ad
  6. #列出端口(和路由器相连的端口)
  7. $ openstack port list --router router
  8. +--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
  9. | ID | Name | MAC Address | Fixed IP Addresses | Status |
  10. +--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
  11. | bff6605d-824c-41f9-b744-21d128fc86e1 | | fa:16:3e:2f:34:9b | ip_address='172.16.1.1', subnet_id='3482f524-8bff-4871-80d4-5774c2730728' | ACTIVE |
  12. | d6fe98db-ae01-42b0-a860-37b1661f5950 | | fa:16:3e:e8:c1:41 | ip_address='203.0.113.102', subnet_id='5cc70da8-4ee7-4565-be53-b9c011fca011' | ACTIVE |
  13. +--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
  14. $ ping -c 4 203.0.113.102
  15. PING 203.0.113.102 (203.0.113.102) 56(84) bytes of data.
  16. 64 bytes from 203.0.113.102: icmp_req=1 ttl=64 time=0.619 ms
  17. 64 bytes from 203.0.113.102: icmp_req=2 ttl=64 time=0.189 ms
  18. 64 bytes from 203.0.113.102: icmp_req=3 ttl=64 time=0.165 ms
  19. 64 bytes from 203.0.113.102: icmp_req=4 ttl=64 time=0.216 ms
  20. --- 203.0.113.102 ping statistics ---
  21. rtt min/avg/max/mdev = 0.165/0.297/0.619/0.187 ms