I was happily using LXD containers for a couple of years now, recently I have noticed problem accessing internet from within my containers, restarting lxd and restarting the host machine previously resolved the problem. But this time nothing is helping, I have even tried uninstalling lxd and re-installing it.
My system:
Host: Ubuntu 20.04
LXD version 4.13
I am using all default configuration values during the installation, nothing is special.
root@debashis-ThinkPad:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s31f6: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether e8:6a:64:89:01:31 brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default qlen 1000
link/ether 20:79:18:5f:4d:bc brd ff:ff:ff:ff:ff:ff
inet 192.168.87.20/24 brd 192.168.87.255 scope global dynamic noprefixroute wlp2s0
valid_lft 46677sec preferred_lft 46677sec
inet6 fe80::57d:6815:66b4:c320/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: enx3c18a0ba710c: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether 3c:18:a0:ba:71:0c brd ff:ff:ff:ff:ff:ff
6: br-2c0eaa4592c2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:66:2e:07:40 brd ff:ff:ff:ff:ff:ff
inet 172.26.0.1/16 brd 172.26.255.255 scope global br-2c0eaa4592c2
valid_lft forever preferred_lft forever
7: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:50:85:c8:87 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
11: lxdbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:c9:45:47 brd ff:ff:ff:ff:ff:ff
inet 10.235.48.1/24 scope global lxdbr0
valid_lft forever preferred_lft forever
inet6 fd42:a188:52d4:442d::1/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fec9:4547/64 scope link
valid_lft forever preferred_lft forever
13: vethf473a9d8@if12: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master lxdbr0 state UP group default qlen 1000
link/ether 32:ab:5f:19:85:b1 brd ff:ff:ff:ff:ff:ff link-netnsid 0
root@debashis-ThinkPad:~# ip r
default via 192.168.87.1 dev wlp2s0 proto dhcp metric 600
10.235.48.0/24 dev lxdbr0 proto kernel scope link src 10.235.48.1
169.254.0.0/16 dev wlp2s0 scope link metric 1000
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
172.26.0.0/16 dev br-2c0eaa4592c2 proto kernel scope link src 172.26.0.1 linkdown
192.168.87.0/24 dev wlp2s0 proto kernel scope link src 192.168.87.20 metric 600
For the record, I’ve seen this exact problem as well with recent lxd using the Snap package installed by following the instructions at Linux Containers - LXD - Getting started. I’ve been generally annoyed with having to use snapd for this so I’ve recently switched over to the (not yet Debian-included) upcoming lxd package for Debian from https://apt.calenhad.com/
Interestingly enough, I’ve had the exact same problem with lxd installed from that package though. After email conversation with Mathias Gibbens (thanks!), the root cause seems to be the iptables package on my system, causing lxd to be confused. And iptables is in turn installed because it’s a dependency by the docker.io package, i.e. Docker…
So the problem will probably go away if you uninstall docker.io, but until then the workaround described above can perhaps be of help for other people who also use Docker + LXD on the same machine.