Hi. I just installed Kubuntu 21.10, ufw and snap LXD (in that order) on a new laptop, and am having the same trouble as on my old laptop (having Kubuntu 21.04) when ufw is enabled.
I enable/disable ufw through gufw. No rules have been added.
The problem shows when I do lxc list: I see no addresses when the container has been started while ufw was running (and can only enter it through lxc exec mycontainer bash).
+-------------+---------+------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-------------+---------+------+------+-----------+-----------+
| mycontainer | RUNNING | | | CONTAINER | 0 |
+-------------+---------+------+------+-----------+-----------+
When I disable ufw and restart the container, I see:
+-------------+---------+-----------------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-------------+---------+-----------------------+------+-----------+-----------+
| mycontainer | RUNNING | 10.100.200.150 (eth0) | | CONTAINER | 0 |
+-------------+---------+-----------------------+------+-----------+-----------+
Is there a way to use LXD with ufw? Has anyone else encountered these issues between LXD and ufw?
Perhaps a guide should be written to help users who want to use ufw and LXD together, especially as there is no indication that it was ufw that was causing the lack of IP address, and I had no idea what was going on until I discovered it.
Allowing everything on lxdbr0 through ufw somehow solves the problem, but that seems too permissive.
Your ufw policy is denying incoming and routed traffic by default. This will prevent dhcp and DNS requests from arriving at lxdbr0 interface and will prevent routed traffic between lxdbr0 and your external network.
Hi karjala,
As @tomp mentioned that, I suppose 2 UDP ports: 67 and 68 for DHCP and TCP/UDP 53 for DNS is enough for minimum number of ports and ssh/22 typically.
Regards.
sudo apt install nftables
sudo nft list table inet lxd
You will see the rules that LXD adds to its own lxd nftables table, which normally would take effect if there wasn’t another nftables table with a default drop rule.
You can then replicate those into your ufw ruleset.