1

所以我在 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

但不幸的是,什么也没发生,我仍然有这个问题。任何建议都会非常有帮助。

4

2 回答 2

1

案子

我遇到服务器电源故障,导致 ping 浮动 ip,有时超时,有时正常。

当我执行“openstack port list”检查端口详细信息时,端口状态为N/A. 在仪表板中,端口状态为creating

解决方案

从 DHCP 更新一个 ip,并将浮动 ip 与 vm 重新绑定。这将保持浮动IP。

操作步骤

  1. 分离接口,选择虚拟机的内部接口。

  2. 连接接口并选择网络。

  3. 浮动 IP 关联的虚拟机。

于 2021-04-22T03:25:44.697 回答
1

所以,我从来没有弄清楚那里的真正问题是什么。但我做了一些改变,它终于对我有用。所以:

1.我卸载了我电脑上的微堆栈。

sudo snap remove microstack --purge

2.我安装了我在microstack.run网站上找到的最新微堆栈。就我而言,我使用了 beta 和 devmode 标志,但我建议您访问microstack.run以查看最推荐的微堆栈

   sudo snap install microstack --beta --devmode

   sudo microstack init --auto --control

3.我保持网络配置与安装微堆栈时相同。我做了这些改变:

   (openstack) subnet set --dhcp external-subnet
   (openstack) subnet set --dhcp test-subnet
   (openstack) subnet set --dns-nameserver 8.8.8.8 external-subnet
   (openstack) subnet set --dns-nameserver 8.8.8.8 test-subnet
   (openstack) network set --share external
   (openstack) network set --share test

4.我在主机上运行了我在bugs.launchpad.net/microstack/+bug/1812415找到的这些命令:

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

5.我创建了图像并启动了一个新实例。最后我设法 ping 8.8.8.8 并可以访问 Internet。

ubuntu@osm:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=114 time=29.3 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=114 time=28.4 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=114 time=28.6 ms

在这一点上,我想提一下,我将安全组规则保持原样。

我希望所有这些对其他人也有帮助。

于 2020-11-19T19:20:12.590 回答