无法访问使用 Microstack 启动的虚拟机 - 目标主机无法访问

无法访问使用 Microstack 启动的虚拟机 - 目标主机无法访问

我安装了Microstack,并试图Openstack通过我在互联网上找到的糟糕文档来了解其操作。我尝试访问一些已启动的虚拟机,但没有成功。Microstack已经创建了以下两个网络:

microstack.openstack network list
+--------------------------------------+----------+--------------------------------------+
| ID                                   | Name     | Subnets                              |
+--------------------------------------+----------+--------------------------------------+
| 750286d8-2801-4dd3-85d8-85b0e4219b46 | test     | fbe5a4e4-34c7-4b39-a4e5-a447431d78dc |
| e9d9520f-3ad7-4f96-bff5-060beb1c0161 | external | 3041f82a-9be5-4f47-84a4-6229e5eb60cb |

下面,我列出了用于启动虚拟机的安全组:

microstack.openstack security group show 3c69498c-c210-48c8-ba43-fbf60a0c224e
+-----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field           | Value                                                                                                                                                                                                                                          |
+-----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at      | 2020-08-14T17:54:45Z                                                                                                                                                                                                                           |
| description     | Default security group                                                                                                                                                                                                                         |
| id              | 3c69498c-c210-48c8-ba43-fbf60a0c224e                                                                                                                                                                                                           |
| location        | Munch({'cloud': '', 'region_name': '', 'zone': None, 'project': Munch({'id': '37f73779b3cd42dc96044ea0fd6d1e98', 'name': 'admin', 'domain_id': None, 'domain_name': 'default'})})                                                              |
| name            | default                                                                                                                                                                                                                                        |
| project_id      | 37f73779b3cd42dc96044ea0fd6d1e98                                                                                                                                                                                                               |
| revision_number | 3                                                                                                                                                                                                                                              |
| rules           | created_at='2020-08-14T17:54:45Z', direction='egress', ethertype='IPv6', id='1e5c2fed-7c7a-4dd4-9e11-c87d0de012ee', updated_at='2020-08-14T17:54:45Z'                                                                                          |
|                 | created_at='2020-08-14T17:54:45Z', direction='ingress', ethertype='IPv4', id='36394ec6-0f35-4b26-9788-61bf76a08088', remote_group_id='3c69498c-c210-48c8-ba43-fbf60a0c224e', updated_at='2020-08-14T17:54:45Z'                                 |
|                 | created_at='2020-08-14T17:54:45Z', direction='ingress', ethertype='IPv6', id='48986d96-ec57-4f49-aee8-6e1c68e273b1', remote_group_id='3c69498c-c210-48c8-ba43-fbf60a0c224e', updated_at='2020-08-14T17:54:45Z'                                 |
|                 | created_at='2020-08-14T17:56:16Z', direction='ingress', ethertype='IPv4', id='58816267-8df8-4a89-a9c5-31986a441365', port_range_max='22', port_range_min='22', protocol='tcp', remote_ip_prefix='0.0.0.0/0', updated_at='2020-08-14T17:56:16Z' |
|                 | created_at='2020-08-14T17:54:45Z', direction='egress', ethertype='IPv4', id='c75e9aa8-84f3-4d05-9d33-0da7892f7a07', updated_at='2020-08-14T17:54:45Z'                                                                                          |
|                 | created_at='2020-08-14T17:56:14Z', direction='ingress', ethertype='IPv4', id='d029b66c-219e-488d-93af-1f87a9d8b006', protocol='icmp', remote_ip_prefix='0.0.0.0/0', updated_at='2020-08-14T17:56:14Z'                                          |
| tags            | []                                                                                                                                                                                                                                             |
| updated_at      | 2020-08-14T17:56:16Z                                                                                                                                                                                                                           |
+-----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

我已经启动了两个Ubuntu具有可用网络(testexternal)的虚拟机,如下所示:

microstack.openstack server list
+--------------------------------------+-------------+--------+-----------------------------------+-------------+-----------+
| ID                                   | Name        | Status | Networks                          | Image       | Flavor    |
+--------------------------------------+-------------+--------+-----------------------------------+-------------+-----------+
| 4bd80f7c-8c16-4b15-9973-887f0f2517ff | test1   | ACTIVE | external=10.20.20.197             | ubuntu_1804 | m1.medium |
| ca2e690e-e679-4fd7-a507-07f12bcf1c5e | test2   | ACTIVE | test=192.168.222.141              | ubuntu_1804 | m1.medium |

这是用于启动虚拟机的命令:

microstack.openstack server create --flavor m1.medium --image ubuntu_1804 \
--nic net-id=e9d9520f-3ad7-4f96-bff5-060beb1c0161 --key-name mykey \
--security-group 3c69498c-c210-48c8-ba43-fbf60a0c224e test1

然后,当我尝试访问两个启动的虚拟机时,我得到Destination Host Unreachable

ping 10.20.20.197
PING 10.20.20.197 (10.20.20.197) 56(84) bytes of data.
From 10.20.20.1 icmp_seq=1 Destination Host Unreachable

ping 192.168.222.141
PING 192.168.222.141 (192.168.222.141) 56(84) bytes of data.
From 192.168.131.133 icmp_seq=1 Destination Host Unreachable

有人可以解释一下我遗漏了什么吗?

答案1

现在我对 Openstack 有了一点了解,我认为问题在于缺少浮动 IP。下面,我列出了将浮动 IP 关联到虚拟机所需的步骤,并可能解决问题。

  1. external为您的网络创建一个浮动 IP :

    microstack.openstack floating ip create external
    
  2. 创建一个路由器来通信两个网络(内部和外部):

    microstack.openstack router create router1
    
  3. 将网络添加external到路由器:

    microstack.openstack router set router1 --external-gateway external
    
  4. 将您的私有子网添加到路由器(假设您的子网 ID 是f16b8b8c-482e-4cf5-a5d6-74e284b7e0f1):

    microstack.openstack router add subnet router1 f16b8b8c-482e-4cf5-a5d6-74e284b7e0f1
    
  5. 将浮动 IP 关联到您的虚拟机(假设创建的 IP 是10.20.20.92):

    microstack.openstack server add floating ip server_micro 10.20.20.92
    

现在您应该能够进入ping虚拟机并通过它访问它ssh

相关内容