创建OpenStack外部网络并分配浮动IP
source openrc
neutron net-create ext-net --provider:network_type local --router:external True
neutron subnet-create ext-net --name ext-subnet --allocation-pool start=168.5.24.30,end=168.5.24.39 --disable-dhcp --gateway 168.5.24.1 168.5.24.0/24
source demo_openrc
neutron router-create demo-router
neutron router-interface-add demo-router demo-subnet
neutron router-gateway-set demo-router ext-net
neutron floatingip-create ext-net
Created a new floatingip:
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| fixed_ip_address | |
| floating_ip_address | 168.5.24.185 |
| floating_network_id | db0e051e-1e79-4b35-ba27-bd3cd8f08703 |
| id | 082f8e34-35f1-489c-8c09-3be23136cdd2 |
| port_id | |
| router_id | |
| status | DOWN |
| tenant_id | 80eead718ac94ecf9a63c3d502058ab0 |
+---------------------+--------------------------------------+
nova floating-ip-associate demo-instance1 168.5.24.185
====================================================================================
[root@node-1 ~]# neutron port-list|grep '168.5.27.3'
| 64f9188a-5a5f-4d8a-8ed8-ec4818ceee48 | | fa:16:3e:65:44:54 | {"subnet_id": "d947ce39-4c3e-4caa-a94c-0323c368857e", "ip_address": "168.5.27.3"} |
[root@node-1 ~]# neutron port-show 64f9188a-5a5f-4d8a-8ed8-ec4818ceee48|grep device_id
| device_id | dhcp9b3b6618-0449-5cf4-ba1a-1bd2727132bc-17168876-0f7e-4324-8f63-977d11c780e0 |
[root@node-1 ~]# ip netns list
qrouter-5d60141c-f751-4ec7-b1d8-dd98d5df52af
vrouter
qdhcp-17168876-0f7e-4324-8f63-977d11c780e0
haproxy
qdhcp-9d667ec8-5ed4-45c0-a4c9-6e3febee9e94
[root@node-1 ~]# ip netns exec qdhcp-17168876-0f7e-4324-8f63-977d11c780e0 bash
[root@node-1 ~]# ip addr show
38: tap64f9188a-5a: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
link/ether fa:16:3e:65:44:54 brd ff:ff:ff:ff:ff:ff
inet 168.5.27.3/24 brd 168.5.27.255 scope global tap64f9188a-5a
inet6 fe80::f816:3eff:fe65:4454/64 scope link
valid_lft forever preferred_lft forever
39: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
[root@node-1 ~]# ssh 168.5.27.2
root@168.5.27.2's password:
# ping 218.85.157.99