Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[regression] Multipass corrupts packet filter rules (iptables) on older distros such as Bionic #2183

Closed
townsend2010 opened this issue Jul 23, 2021 · 31 comments · Fixed by #2190

Comments

@townsend2010
Copy link
Contributor

We have an issue that seems clearly related, and reproduction is even more fundamental (no name resolution involved, can't ping an ip address):

sudo docker run -it --rm alpine /bin/sh
/ # ping 1.1.1.1

works fine.

then on host system:
sudo snap install multipass

After that, the ping in the docker container stops working.

This error seems to have popped up relatively recently (ca. last week). We observed it first in a more complicated environment, where docker is used to run some CI, and multipass is run by snapcraft, but what I showed here is the minimal setup to reproduce it.

Originally posted by @julius-ziegler in #1435 (comment)

@townsend2010
Copy link
Contributor Author

townsend2010 commented Jul 23, 2021

Hi @julius-ziegler,

We made some fairly significant changes to detecting when iptables and/or nftables are in use, and I'm guessing we've missed a case.

Which distro are you using?

Could you also please post the output of:

  • $ sudo iptables-legacy --table filter --list-rules
  • $ sudo iptables-legacy --table nat --list-rules
  • $ sudo iptables-legacy --table mangle --list-rules
  • $ sudo iptables-legacy --table filter --list-rules

We'll go from there. Thanks!

@julius-ziegler
Copy link

Sorry for the lengthy dumps, this is the output of the commands, in the "broken" state

-P INPUT ACCEPT
-P FORWARD DROP
-P OUTPUT ACCEPT
-N DOCKER
-N DOCKER-ISOLATION-STAGE-1
-N DOCKER-ISOLATION-STAGE-2
-N DOCKER-USER
-A INPUT -i mpqemubr0 -p tcp -m tcp --dport 53 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A INPUT -i mpqemubr0 -p udp -m udp --dport 53 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A INPUT -i mpqemubr0 -p udp -m udp --dport 67 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A INPUT -i lxdbr0 -p tcp -m tcp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A INPUT -i lxdbr0 -p udp -m udp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A INPUT -i lxdbr0 -p udp -m udp --dport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A FORWARD -i mpqemubr0 -o mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A FORWARD -s 10.167.112.0/24 -i mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A FORWARD -d 10.167.112.0/24 -o mpqemubr0 -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A FORWARD -j DOCKER-USER
-A FORWARD -j DOCKER-ISOLATION-STAGE-1
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o docker0 -j DOCKER
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A FORWARD -o lxdbr0 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A FORWARD -i lxdbr0 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A FORWARD -i mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -o mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -o mpqemubr0 -p tcp -m tcp --sport 53 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A OUTPUT -o mpqemubr0 -p udp -m udp --sport 53 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A OUTPUT -o mpqemubr0 -p udp -m udp --sport 67 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A OUTPUT -o lxdbr0 -p tcp -m tcp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A OUTPUT -o lxdbr0 -p udp -m udp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A OUTPUT -o lxdbr0 -p udp -m udp --sport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A DOCKER-ISOLATION-STAGE-1 -i docker0 ! -o docker0 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -j RETURN
-A DOCKER-ISOLATION-STAGE-2 -o docker0 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -j RETURN
-A DOCKER-USER -j RETURN


-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-N DOCKER
-A PREROUTING -i ens3 -p tcp -m tcp --dport 7000 -j DNAT --to-destination 10.108.72.164:80
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 10.167.112.0/24 ! -d 10.167.112.0/24 -m comment --comment "generated for Multipass network mpqemubr0" -j MASQUERADE
-A POSTROUTING -s 10.167.112.0/24 ! -d 10.167.112.0/24 -p udp -m comment --comment "generated for Multipass network mpqemubr0" -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 10.167.112.0/24 ! -d 10.167.112.0/24 -p tcp -m comment --comment "generated for Multipass network mpqemubr0" -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 10.167.112.0/24 -d 255.255.255.255/32 -m comment --comment "generated for Multipass network mpqemubr0" -j RETURN
-A POSTROUTING -s 10.167.112.0/24 -d 224.0.0.0/24 -m comment --comment "generated for Multipass network mpqemubr0" -j RETURN
-A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
-A POSTROUTING -s 10.108.72.0/24 ! -d 10.108.72.0/24 -m comment --comment "generated for LXD network lxdbr0" -j MASQUERADE
-A DOCKER -i docker0 -j RETURN


-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-A POSTROUTING -o mpqemubr0 -p udp -m udp --dport 68 -m comment --comment "generated for Multipass network mpqemubr0" -j CHECKSUM --checksum-fill
-A POSTROUTING -o lxdbr0 -p udp -m udp --dport 68 -m comment --comment "generated for LXD network lxdbr0" -j CHECKSUM --checksum-fill


-P INPUT ACCEPT
-P FORWARD DROP
-P OUTPUT ACCEPT
-N DOCKER
-N DOCKER-ISOLATION-STAGE-1
-N DOCKER-ISOLATION-STAGE-2
-N DOCKER-USER
-A INPUT -i mpqemubr0 -p tcp -m tcp --dport 53 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A INPUT -i mpqemubr0 -p udp -m udp --dport 53 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A INPUT -i mpqemubr0 -p udp -m udp --dport 67 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A INPUT -i lxdbr0 -p tcp -m tcp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A INPUT -i lxdbr0 -p udp -m udp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A INPUT -i lxdbr0 -p udp -m udp --dport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A FORWARD -i mpqemubr0 -o mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A FORWARD -s 10.167.112.0/24 -i mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A FORWARD -d 10.167.112.0/24 -o mpqemubr0 -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A FORWARD -j DOCKER-USER
-A FORWARD -j DOCKER-ISOLATION-STAGE-1
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o docker0 -j DOCKER
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A FORWARD -o lxdbr0 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A FORWARD -i lxdbr0 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A FORWARD -i mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -o mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -o mpqemubr0 -p tcp -m tcp --sport 53 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A OUTPUT -o mpqemubr0 -p udp -m udp --sport 53 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A OUTPUT -o mpqemubr0 -p udp -m udp --sport 67 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
-A OUTPUT -o lxdbr0 -p tcp -m tcp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A OUTPUT -o lxdbr0 -p udp -m udp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A OUTPUT -o lxdbr0 -p udp -m udp --sport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
-A DOCKER-ISOLATION-STAGE-1 -i docker0 ! -o docker0 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -j RETURN
-A DOCKER-ISOLATION-STAGE-2 -o docker0 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -j RETURN
-A DOCKER-USER -j RETURN

I also made a dump in the "working" state. This is only the diff between "working" and "broken":

8,10d7
< -A INPUT -i lxdbr0 -p tcp -m tcp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
< -A INPUT -i lxdbr0 -p udp -m udp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
< -A INPUT -i lxdbr0 -p udp -m udp --dport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
13a11,16
> -A INPUT -i lxdbr0 -p tcp -m tcp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
> -A INPUT -i lxdbr0 -p udp -m udp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
> -A INPUT -i lxdbr0 -p udp -m udp --dport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
> -A FORWARD -i mpqemubr0 -o mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
> -A FORWARD -s 10.167.112.0/24 -i mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
> -A FORWARD -d 10.167.112.0/24 -o mpqemubr0 -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
22,24d24
< -A FORWARD -i mpqemubr0 -o mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
< -A FORWARD -s 10.41.95.0/24 -i mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
< -A FORWARD -d 10.41.95.0/24 -o mpqemubr0 -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
27,29d26
< -A OUTPUT -o lxdbr0 -p tcp -m tcp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
< -A OUTPUT -o lxdbr0 -p udp -m udp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
< -A OUTPUT -o lxdbr0 -p udp -m udp --sport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
32a30,32
> -A OUTPUT -o lxdbr0 -p tcp -m tcp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
> -A OUTPUT -o lxdbr0 -p udp -m udp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
> -A OUTPUT -o lxdbr0 -p udp -m udp --sport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
47a48,52
> -A POSTROUTING -s 10.167.112.0/24 ! -d 10.167.112.0/24 -m comment --comment "generated for Multipass network mpqemubr0" -j MASQUERADE
> -A POSTROUTING -s 10.167.112.0/24 ! -d 10.167.112.0/24 -p udp -m comment --comment "generated for Multipass network mpqemubr0" -j MASQUERADE --to-ports 1024-65535
> -A POSTROUTING -s 10.167.112.0/24 ! -d 10.167.112.0/24 -p tcp -m comment --comment "generated for Multipass network mpqemubr0" -j MASQUERADE --to-ports 1024-65535
> -A POSTROUTING -s 10.167.112.0/24 -d 255.255.255.255/32 -m comment --comment "generated for Multipass network mpqemubr0" -j RETURN
> -A POSTROUTING -s 10.167.112.0/24 -d 224.0.0.0/24 -m comment --comment "generated for Multipass network mpqemubr0" -j RETURN
50,54d54
< -A POSTROUTING -s 10.41.95.0/24 ! -d 10.41.95.0/24 -m comment --comment "generated for Multipass network mpqemubr0" -j MASQUERADE
< -A POSTROUTING -s 10.41.95.0/24 ! -d 10.41.95.0/24 -p udp -m comment --comment "generated for Multipass network mpqemubr0" -j MASQUERADE --to-ports 1024-65535
< -A POSTROUTING -s 10.41.95.0/24 ! -d 10.41.95.0/24 -p tcp -m comment --comment "generated for Multipass network mpqemubr0" -j MASQUERADE --to-ports 1024-65535
< -A POSTROUTING -s 10.41.95.0/24 -d 255.255.255.255/32 -m comment --comment "generated for Multipass network mpqemubr0" -j RETURN
< -A POSTROUTING -s 10.41.95.0/24 -d 224.0.0.0/24 -m comment --comment "generated for Multipass network mpqemubr0" -j RETURN
63d62
< -A POSTROUTING -o lxdbr0 -p udp -m udp --dport 68 -m comment --comment "generated for LXD network lxdbr0" -j CHECKSUM --checksum-fill
64a64
> -A POSTROUTING -o lxdbr0 -p udp -m udp --dport 68 -m comment --comment "generated for LXD network lxdbr0" -j CHECKSUM --checksum-fill
74,76d73
< -A INPUT -i lxdbr0 -p tcp -m tcp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
< -A INPUT -i lxdbr0 -p udp -m udp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
< -A INPUT -i lxdbr0 -p udp -m udp --dport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
79a77,82
> -A INPUT -i lxdbr0 -p tcp -m tcp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
> -A INPUT -i lxdbr0 -p udp -m udp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
> -A INPUT -i lxdbr0 -p udp -m udp --dport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
> -A FORWARD -i mpqemubr0 -o mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
> -A FORWARD -s 10.167.112.0/24 -i mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
> -A FORWARD -d 10.167.112.0/24 -o mpqemubr0 -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
88,90d90
< -A FORWARD -i mpqemubr0 -o mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
< -A FORWARD -s 10.41.95.0/24 -i mpqemubr0 -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
< -A FORWARD -d 10.41.95.0/24 -o mpqemubr0 -m conntrack --ctstate RELATED,ESTABLISHED -m comment --comment "generated for Multipass network mpqemubr0" -j ACCEPT
93,95d92
< -A OUTPUT -o lxdbr0 -p tcp -m tcp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
< -A OUTPUT -o lxdbr0 -p udp -m udp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
< -A OUTPUT -o lxdbr0 -p udp -m udp --sport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
98a96,98
> -A OUTPUT -o lxdbr0 -p tcp -m tcp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
> -A OUTPUT -o lxdbr0 -p udp -m udp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT
> -A OUTPUT -o lxdbr0 -p udp -m udp --sport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT

Hope this helps!
Thanks!

@townsend2010
Copy link
Contributor Author

Hey @julius-ziegler,

Thanks for those dumps. It will be helpful.

When you say the difference between "working" and "broken", do mean "working" is Multipass v.1.6.2 and "broken" is Multipass v1.7 with everything else being the same?

@julius-ziegler
Copy link

No, I can restore "working" state by

sudo snap disable multipass + reboot

or equally

sudo snap remove multipass + reboot

@julius-ziegler
Copy link

I will experiment a bit with downgrading multipass, I did not think of this before.

@townsend2010
Copy link
Contributor Author

Oh, that's really weird because, if I'm reading the diff correctly, "working" has Multipass-related rules in the tables and I'm not sure how it would if the snap is disabled/removed.

@townsend2010 townsend2010 changed the title [regression] Wrong packet filtering possibly used [regression] Docker network does not work when Multipass is running Jul 23, 2021
@julius-ziegler
Copy link

Yes, that is strange indeed. But I just double checked, this is exactly how the tables look at the moment, and the ping is working.

@julius-ziegler
Copy link

Here are the logs as txt file, I like to look at them like this with something like meld:

logs.zip

@townsend2010
Copy link
Contributor Author

So the one difference I see is that in the "broken" state, we are first in the various sets of rules whereas when it's working, we are last. I'll see if maybe I missed a flag on the refactoring of this for nftables support.

@julius-ziegler
Copy link

It is not trivial to go back to 1.6.2 for a regression test, right? Via the snap store it seems to not be possible.

Thanks again!

@townsend2010
Copy link
Contributor Author

Another difference in the refactoring is that we now use iptables in the core20 snap and before, we included iptables in the Multipass snap itself. It could be iptables in the core20 snap is doing something unexpected.

Right, going back to the older version is not trivial at all and we'll just pass on that for now. I'll keep digging.

@Saviq
Copy link
Collaborator

Saviq commented Jul 23, 2021

It is not trivial to go back to 1.6.2 for a regression test, right? Via the snap store it seems to not be possible.

Actually a snap revert multipass should do :)

@julius-ziegler
Copy link

@Saviq I am getting
error: cannot revert "multipass": no revision to revert to

@townsend2010 I forgot to mention that when shelling into the multipass instance, I also do not get internet (can't ping the host e.g.).

@Saviq
Copy link
Collaborator

Saviq commented Jul 26, 2021

@Saviq I am getting
error: cannot revert "multipass": no revision to revert to

That might be because the refresh was too long ago, not sure.

@townsend2010
Copy link
Contributor Author

townsend2010 commented Jul 26, 2021

@julius-ziegler,

I've been trying to chase this down to no avail. I looked at what we are doing when setting up the tables between 1.6.2 and 1.7 and our logic is still the same. I'm still stumped on how you have persistent Multipass entries in your iptables rules when Multipass is disabled/removed. At any rate, I'm doubting this is a regression in 1.7 though.

I also installed docker on my machine, issued the same command as you, and ping inside the docker container works regardless if Multipass is installed or not.

Now, let's try to drill down into differences between our hosts. Could you please provide the following?

  • Distro and version your host machine is running.
  • Kernel version of the host.
  • Version of Docker you are using.
  • Although I don't see it in your iptables dumps, but are you running any special firewalls, VPN, etc?

Thanks!

@julius-ziegler
Copy link

This problem has hit us so hard because it occurred on a very busy server running a couple of services via docker (but there is also some kubernetes and lxd stuff on it). Equivalently complicated is the whole environment on the server.

I will try to reproduce it myself on a "cleaner" server.

@Saviq
Copy link
Collaborator

Saviq commented Jul 26, 2021

@julius-ziegler I temporarily published 1.6.2 to the stable/1.6 channel, if you would like to downgrade to confirm this wasn't a problem before.

@julius-ziegler
Copy link

Thanks a ton @Saviq, I actually can not reproduce the problem with 1.6.2.

@Saviq
Copy link
Collaborator

Saviq commented Jul 26, 2021

@julius-ziegler that's a great data point then.

Can you please dump all of your tables again and compare to those when broken with 1.7.0?

@julius-ziegler
Copy link

This is the log of the iptables commands in the "works-with-1.6.2" state. It is identical to the broken state, except for some (randomized/dynamically-chosen?) IP addresses

works-with-1.6.2.zip

@townsend2010
Copy link
Contributor Author

townsend2010 commented Jul 26, 2021

I'm starting to think this may be some incompatibility of iptables in the core20 snap (which 1.7 uses now) and the core18 snap (which 1.6.2 used) and whatever kernel you are running. It would be very helpful to know the answers to what I asked in #2183 (comment).

@townsend2010
Copy link
Contributor Author

For reference, the version of iptables in core18 is 1.6.1 and in core20 is 1.8.4.

@julius-ziegler
Copy link

Here is some data on the affected machine:

Linux eleonora.lan 4.15.0-151-generic #157-Ubuntu SMP Fri Jul 9 23:07:57 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Ubuntu 18.04.5 LTS

Docker version 19.03.11, build 42e35e61f3

Here is configured networks. The lxd one might be something exotic. I will try to get my colleague involved in the discussion who knows more about this.

IP address for ens3: 192.168.179.4
IP address for enx00e04c00055a: 192.168.178.4
IP address for lxdbr0: 10.108.72.1
IP address for docker0: 172.17.0.1
IP address for mpqemubr0: 10.129.65.1

@younishd
Copy link

younishd commented Jul 29, 2021

Hi, I just read through this issue which affected our company network (I am said colleague) and while most things have already been said by @julius-ziegler I wanted to add a few things:

I was able to reproduce this issue in an empty ubuntu bionic VM:

I installed docker then successfully ran:

docker run -it --rm alpine /bin/sh -c "ping 1.1.1.1"

I then installed multipass:

snap install multipass

Now, the above ping no longer works.

This dismisses the explanation that this issue is caused by the host being otherwise cluttered with miscellaneous iptables rules.

I tested this with:

multipass  1.7.0
multipassd 1.7.0

I'm still stumped on how you have persistent Multipass entries in your iptables rules when Multipass is disabled/removed.

@townsend2010 The reason for the rules being persistent was that we used iptables-persistent to restore rules on reboot. This is however not the reason for the connectivity problem, because I did try to remove all non-essential rules (including all multipass rules) back then and the result did not change — which is now confirmed by the above-mentioned test in a sterile VM environment.


EDIT:
We also found out that doing:

snap disconnect multipass:firewall-control

followed by a reboot is enough to regain connectivity.

@townsend2010
Copy link
Contributor Author

Hey @julius-ziegler & @younishd,

I'm able to reproduce this in a Bionic VM as described in #2183 (comment). An interesting data point is that this does work using a Focal VM, so it's looking like there may be some incompatibility with Bionic and the version of iptables-legacy that ships inside the core20 snap. I'll see if there is some way to work around this.

@townsend2010
Copy link
Contributor Author

Hey @julius-ziegler and @younishd,

I finally found the issue in our code and have proposed a fix. After CI successfully runs on the PR, you should be able to test this via $ snap refresh multipass --channel edge/pr2190.

Due to the nature of the bug, the iptables are messed up, so you'll need to reboot the machine after refreshing Multipass.

Thanks!

@townsend2010 townsend2010 changed the title [regression] Docker network does not work when Multipass is running [regression] Multipass corrupts iptables on older distros such as Bionic Aug 4, 2021
@townsend2010 townsend2010 changed the title [regression] Multipass corrupts iptables on older distros such as Bionic [regression] Multipass corrupts packet filter rules (iptables) on older distros such as Bionic Aug 4, 2021
@townsend2010
Copy link
Contributor Author

The symptom of this issue is that on older distros such as Bionic, installing version 1.7 of Multipass would cause any NAT'ed networks such as LXD, Docker, etc. to no longer have access outside of the host.

This was due to a change in Multipass where it tries to detect if nftables or legacy iptables are in use. On kernels older than 5.2, nftables isn't properly supported, but the logic to detect the kernel version was broken, so iptables-nft was being called on older kernels and thus, corrupt the packet filter rules.

@julius-ziegler
Copy link

@townsend2010 thanks, we will give it a whirl. Ironically, we are just in the process of moving the affected service to a Focal machine.

@townsend2010
Copy link
Contributor Author

Hi @julius-ziegler,

Yeah, Focal will not be affected by this since the kernel can handle the iptables-nft call. But it's still good to have this regression fixed and thanks for pointing it out and your patience!

bors bot added a commit that referenced this issue Aug 5, 2021
2190: [firewall] Fix detection of nftables support in kernel r=Saviq a=townsend2010

Fixes #2183 

Co-authored-by: Chris Townsend <christopher.townsend@canonical.com>
bors bot added a commit that referenced this issue Aug 5, 2021
2190: [firewall] Fix detection of nftables support in kernel r=Saviq a=townsend2010

Fixes #2183 

Co-authored-by: Chris Townsend <christopher.townsend@canonical.com>
bors bot added a commit that referenced this issue Aug 5, 2021
2190: [firewall] Fix detection of nftables support in kernel r=Saviq a=townsend2010

Fixes #2183 

Co-authored-by: Chris Townsend <christopher.townsend@canonical.com>
bors bot added a commit that referenced this issue Aug 5, 2021
2190: [firewall] Fix detection of nftables support in kernel r=Saviq a=townsend2010

Fixes #2183 

Co-authored-by: Chris Townsend <christopher.townsend@canonical.com>
bors bot added a commit that referenced this issue Aug 5, 2021
2190: [firewall] Fix detection of nftables support in kernel r=Saviq a=townsend2010

Fixes #2183 

Co-authored-by: Chris Townsend <christopher.townsend@canonical.com>
bors bot added a commit that referenced this issue Aug 5, 2021
2190: [firewall] Fix detection of nftables support in kernel r=Saviq a=townsend2010

Fixes #2183 

2191: Fix compilation with Clang 12 on Linux. r=Saviq a=luis4a0

Clang is picky with lambda captures.

Co-authored-by: Chris Townsend <christopher.townsend@canonical.com>
Co-authored-by: Luis Peñaranda <luis.penaranda@canonical.com>
bors bot added a commit that referenced this issue Aug 5, 2021
2190: [firewall] Fix detection of nftables support in kernel r=Saviq a=townsend2010

Fixes #2183 

Co-authored-by: Chris Townsend <christopher.townsend@canonical.com>
@bors bors bot closed this as completed in 8e0fa20 Aug 5, 2021
Saviq pushed a commit that referenced this issue Aug 12, 2021
2190: [firewall] Fix detection of nftables support in kernel r=Saviq a=townsend2010

Fixes #2183 

Co-authored-by: Chris Townsend <christopher.townsend@canonical.com>
Saviq added a commit that referenced this issue Aug 12, 2021
2190: [firewall] Fix detection of nftables support in kernel r=Saviq a=townsend2010

Fixes #2183

Co-authored-by: Chris Townsend <christopher.townsend@canonical.com>
@Saviq
Copy link
Collaborator

Saviq commented Aug 16, 2021

This is now released as version 1.7.1 in the Snap Store (revision 5309).

@zippy-zebu
Copy link

zippy-zebu commented Sep 21, 2021

Hello, after update there is still no connectivity. Ping simply doesn't work. Nor anything else...apt update. Last working version 1.6.

@Saviq Can you restore stable/1.6 channel. I tried with snap refresh multipass --channel stable/1.6 but it still installs 1.7.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants