Score:0

LXC instances do not have IPv4 addresses

br flag

I've had limited success in having LXC instances acquire an IPv4 address. It has worked at creation, but if I reboot the host, all addresses are lost.

Host Ubuntu 21.10

Client version: 4.21

Server version: 4.21

Image Ubuntu 21.10

tgl@electra:~$ lxd version
4.21
tgl@electra:~$ lxc version
Client version: 4.21
Server version: 4.21
tgl@electra:~$ lxc list
+---------+---------+------+---------------------------------------------+-----------+-----------+
|  NAME   |  STATE  | IPV4 |                     IPV6                      |   TYPE    | SNAPSHOTS |
+---------+---------+------+---------------------------------------------+-----------+-----------+
| mariadb | RUNNING |      | fd42:594a:5292:77f3:216:3eff:fe3c:7abe (eth0) | CONTAINER | 0         |
+---------+---------+------+---------------------------------------------+-----------+-----------+
| nginx1  | RUNNING |      | fd42:594a:5292:77f3:216:3eff:fe85:b910 (eth0) | CONTAINER | 0         |
+---------+---------+------+---------------------------------------------+-----------+-----------+
| nginx2  | RUNNING |      | fd42:594a:5292:77f3:216:3eff:feb3:3103 (eth0) | CONTAINER | 0         |
+---------+---------+------+---------------------------------------------+-----------+-----------+
| nginx3  | RUNNING |      | fd42:594a:5292:77f3:216:3eff:feaf:5288 (eth0) | CONTAINER | 0         |
+---------+---------+------+---------------------------------------------+-----------+-----------+
| proxy   | RUNNING |      | fd42:594a:5292:77f3:216:3eff:fee7:5013 (eth0) | CONTAINER | 0         |
+---------+---------+------+---------------------------------------------+-----------+-----------+
tgl@electra:~$ lxc network list
+--------+----------+---------+----------------+---------------------------+-------------+---------+
|  NAME  |   TYPE   | MANAGED |      IPV4      |           IPV6            | DESCRIPTION | USED BY |
+--------+----------+---------+----------------+---------------------------+-------------+---------+
| eth0   | physical | NO      |                |                           |             | 0       |
+--------+----------+---------+----------------+---------------------------+-------------+---------+
| lxdbr0 | bridge   | YES     | 10.88.102.1/24 | fd42:594a:5292:77f3::1/64 |             | 6       |
+--------+----------+---------+----------------+---------------------------+-------------+---------+
tgl@electra:~$ 
Score:4
cn flag

This worked for me:

sudo ufw allow in on lxdbr0
sudo ufw route allow in on lxdbr0
sudo ufw route allow out on lxdbr0

Via: https://discuss.linuxcontainers.org/t/lxd-bridge-doesnt-work-with-ipv4-and-ufw-with-nftables/10034/17

Score:0
br flag

I've now found a couple resources:

https://discuss.linuxcontainers.org/t/containers-not-getting-ipv4/6668/37

https://discuss.linuxcontainers.org/t/lxd-bridge-doesnt-work-with-ipv4-and-ufw-with-nftables/10034/16

I am using lxd from snap on Ubuntu 21.10. After reading the second linked discussion, I disabled and removed ufw and re-install with snap.

sudo ufw disable
sudo apt remove ufw
sudo apt purge ufw
sudo snap install ufw
sudo ufw enable

Then sudo systemctl reload snap.lxd.daemon. The nginx process in each instance also needed to be restarted. Everything worked on reboot, too.

Alternately, you may have success with these two new ufw rules.

sudo ufw allow in on lxdbr0
sudo ufw route allow in on lxdbr0
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.