所以我在 Ubuntu 18.04 LTS PC 上安装了 Microstack。好吧,我可以从主机(安装了 miccostack)SSH 到我的虚拟机,但我的虚拟机无法访问互联网。
我创建了一个名为 osm 的实例,并关联了一个浮动 ip。
(openstack) server list
+--------------------------------------+------+--------+-----------------------------------+------------+-----------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+------+--------+-----------------------------------+------------+-----------+
| e12dc245-da35-424a-a9b2-06067e2f5555 | osm | ACTIVE | test=192.168.222.246, 10.20.20.30 | ubuntu1804 | m1.medium |
+--------------------------------------+------+--------+-----------------------------------+------------+-----------+
这是我的网络列表
(openstack) network list
+--------------------------------------+----------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+----------+--------------------------------------+
| c4968a12-662f-4ca6-8392-a6dc3f81e3ba | external | bcd86099-e801-477b-bf0c-978ec84bb708 |
| f83255dd-42d1-4fed-ad21-e9d1ec887fa8 | test | a7064161-4d11-4ca7-be55-47e5a6d92724 |
+--------------------------------------+----------+--------------------------------------+
每个网络都有自己的子网,其中包含以下详细信息:external-subnet
(openstack) subnet show external-subnet
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| allocation_pools | 10.20.20.1-10.20.20.82 |
| cidr | 10.20.20.0/24 |
| created_at | 2020-07-06T08:06:26Z |
| description | |
| dns_nameservers | 8.8.4.4, 8.8.8.8 |
| enable_dhcp | False |
| gateway_ip | 10.20.20.83 |
| host_routes | |
| id | bcd86099-e801-477b-bf0c-978ec84bb708 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| location | Munch({'cloud': '', 'region_name': '', 'zone': None, 'project': Munch({'id': '54ba9ffa36ca424fac395b6c774fd2a3', 'name': 'admin', 'domain_id': None, 'domain_name': 'default'})}) |
| name | external-subnet |
| network_id | c4968a12-662f-4ca6-8392-a6dc3f81e3ba |
| prefix_length | None |
| project_id | 54ba9ffa36ca424fac395b6c774fd2a3 |
| revision_number | 22 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2020-10-12T10:49:35Z |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
测试子网
(openstack) subnet show test-subnet
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| allocation_pools | 192.168.222.2-192.168.222.254 |
| cidr | 192.168.222.0/24 |
| created_at | 2020-07-06T08:06:20Z |
| description | |
| dns_nameservers | 8.8.4.4, 8.8.8.8 |
| enable_dhcp | True |
| gateway_ip | 192.168.222.1 |
| host_routes | |
| id | a7064161-4d11-4ca7-be55-47e5a6d92724 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| location | Munch({'cloud': '', 'region_name': '', 'zone': None, 'project': Munch({'id': '54ba9ffa36ca424fac395b6c774fd2a3', 'name': 'admin', 'domain_id': None, 'domain_name': 'default'})}) |
| name | test-subnet |
| network_id | f83255dd-42d1-4fed-ad21-e9d1ec887fa8 |
| prefix_length | None |
| project_id | 54ba9ffa36ca424fac395b6c774fd2a3 |
| revision_number | 7 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2020-10-12T10:49:52Z |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
这些是有关连接到外部和测试网络的路由器的信息
(openstack) router list
+--------------------------------------+-------------+--------+-------+----------------------------------+-------------+-------+
| ID | Name | Status | State | Project | Distributed | HA |
+--------------------------------------+-------------+--------+-------+----------------------------------+-------------+-------+
| b935bc17-d379-4aa8-b040-5a770741de23 | test-router | ACTIVE | UP | 54ba9ffa36ca424fac395b6c774fd2a3 | False | False |
+--------------------------------------+-------------+--------+-------+----------------------------------+-------------+-------+
(openstack) router show test-router
+-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | nova |
| created_at | 2020-07-06T08:06:28Z |
| description | |
| distributed | False |
| external_gateway_info | {"network_id": "c4968a12-662f-4ca6-8392-a6dc3f81e3ba", "external_fixed_ips": [{"subnet_id": "bcd86099-e801-477b-bf0c-978ec84bb708", "ip_address": "10.20.20.83"}], "enable_snat": true} |
| flavor_id | None |
| ha | False |
| id | b935bc17-d379-4aa8-b040-5a770741de23 |
| interfaces_info | [{"port_id": "6f935a4f-e1b0-41bf-aefb-dd6f9b929f69", "ip_address": "192.168.222.1", "subnet_id": "a7064161-4d11-4ca7-be55-47e5a6d92724"}] |
| location | Munch({'cloud': '', 'region_name': '', 'zone': None, 'project': Munch({'id': '54ba9ffa36ca424fac395b6c774fd2a3', 'name': 'admin', 'domain_id': None, 'domain_name': 'default'})}) |
| name | test-router |
| project_id | 54ba9ffa36ca424fac395b6c774fd2a3 |
| revision_number | 23 |
| routes | |
| status | ACTIVE |
| tags | |
| updated_at | 2020-10-11T14:52:29Z |
+-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
我的虚拟机可以 ping 192.168.222.1(gateway),10.20.20.83(gateway),10.20.20.1(host-microstack),但无法访问互联网。例如我无法 ping 8.8.8.8
ubuntu@osm:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 10.20.20.30 icmp_seq=1 Destination Host Unreachable
From 10.20.20.30 icmp_seq=2 Destination Host Unreachable
From 10.20.20.30 icmp_seq=3 Destination Host Unreachable
From 10.20.20.30 icmp_seq=4 Destination Host Unreachable
^C
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 0 received, +4 errors, 100% packet loss, time 4055ms
pipe 3
我认为问题可能与 10.20.20.30 端口的状态为 N/A 的事实有关,但我不确定
(openstack) port list
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------+--------+
| ID | Name | MAC Address | Fixed IP Addresses | Status |
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------+--------+
| 029f8880-9e7c-4b9e-a8e8-b27496ec542e | | fa:16:3e:2e:ac:b5 | ip_address='10.20.20.30', subnet_id='bcd86099-e801-477b-bf0c-978ec84bb708' | N/A |
| 6f935a4f-e1b0-41bf-aefb-dd6f9b929f69 | | fa:16:3e:0d:65:36 | ip_address='192.168.222.1', subnet_id='a7064161-4d11-4ca7-be55-47e5a6d92724' | ACTIVE |
| 9c46a483-ee64-4d0a-8eb4-aa2b5cc083b7 | | fa:16:3e:66:da:8a | ip_address='10.20.20.83', subnet_id='bcd86099-e801-477b-bf0c-978ec84bb708' | ACTIVE |
| c2444040-b8d5-4009-8019-10779ecb7d92 | | fa:16:3e:4e:93:c8 | ip_address='192.168.222.246', subnet_id='a7064161-4d11-4ca7-be55-47e5a6d92724' | ACTIVE |
| cc79a6f2-a4c1-47de-b27b-9a2018dab595 | | fa:16:3e:e4:17:32 | ip_address='192.168.222.2', subnet_id='a7064161-4d11-4ca7-be55-47e5a6d92724' | ACTIVE |
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------+--------+
在搜索此问题时,我发现对主机(安装了 Microstack)执行这些命令可能会解决问题
sudo iptables -t nat -A POSTROUTING -s 10.20.20.1/24 ! -d 10.20.20.1/24 -j MASQUERADE
sudo sysctl net.ipv4.ip_forward=1
但不幸的是,什么也没发生,我仍然有这个问题。任何建议都会非常有帮助。