Microstack-My VMs cannot access the Internet

2.5k views Asked by At

So I have installes Microstack in an Ubuntu 18.04 LTS PC. Well i can ssh to my VM from the host(where miccostack is installed), but my VM cannot access the Internet.

I have created an instance named osm and i have associated a floating ip to it.

(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 |
+--------------------------------------+------+--------+-----------------------------------+------------+-----------+



This is my network list

 (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 |
+--------------------------------------+----------+--------------------------------------+

Each network has its own subnet with these details: 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                                                                                                                                                              |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

test-subnet

(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                                                                                                                                                                |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

These are the information about the router which is connected to the external and test network

(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                                                                                                                                                                    |
+-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

My VM can ping 192.168.222.1(gateway),10.20.20.83(gateway),10.20.20.1(host-microstack) but cannot access the internet. For example i cannot 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

I assume that maybe the problem is related to the fact that the status of the port at 10.20.20.30 is N/A, but I am not sure

(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 |
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------+--------+

While I was searching for this issue I found that executing these commands to the host machine(where Microstack is installed) may fix the problem

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

But unfortunatelly nothing happened and I still have this issue. Any piece of advice would be really helpful.

3

There are 3 answers

0
Xiao Han On

Case

I encountered a server power failure, resulting ping floating ip, sometime timeout and sometime ok.

when I execute "openstack port list" check the port detail, port status is N/A. In Dashboard the port status is creating

Solution

renew an ip from DHCP, and re-bind floating ip with the vm. That will keep the floating ip.

Operation steps

  1. Separate the interface and select the internal interface of the virtual machine.

  2. Connect the interface and select the network.

  3. Floating IP associated virtual machine.

0
tariro On

I started having this issue as well. I tried the solution suggested above of adding a POSTROUTING rule. This worked for me for a short while. After reboot I faced the same error and applying the POSTROUTING rule didn't resolve it.

Checking the iptable rules with sudo iptables -L -v -n --line-numbers and sudo iptables -L -v -n -t nat --line-numbers showed that the packets were being consumed by iptable rules set by docker. To resolve this, in addition to sudo iptables -t nat -A POSTROUTING -s 10.20.20.1/24 ! -d 10.20.20.1/24 -j MASQUERADE I also inserted FORWARD rules for the microstack IP range like below.

sudo iptables -I FORWARD -s 10.20.20.1/24 -j ACCEPT

sudo iptables -I FORWARD -d 10.20.20.1/24 -j ACCEPT

After that I got the traffic flowing. I hope this helps someone else.

0
lydi st On

So, I never figured out what was the real problem there. But I made some changes and it finally worked for me. So:

1.I uninstalled the microstack I had on my PC.

sudo snap remove microstack --purge

2.I installed the latest microstack I found on microstack.run site. In my case I used beta and devmode flags, but I recommend you to visit microstack.run to check what is the most recommended microstack

   sudo snap install microstack --beta --devmode

   sudo microstack init --auto --control

3.I kept the network configuration the same as it was, when microstack was installed. I made these changes:

   (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.I ran these commands I found at bugs.launchpad.net/microstack/+bug/1812415 on the host machine:

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.I created the image and launch a new instance. And finally I managed to ping 8.8.8.8 and have access on the 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

At this point I want to mention that I kept the security group rules the way it was.

I hope all these be helpful to someone else too.