大网数据广告活动
服务器运维问答

LXC instances do not have IPv4 addresses

· 52CE 我爱测

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…

问题原文

原帖链接 · Terry G Lorber · CC BY-SA 4.0

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:~$ 

已采纳解答

原帖链接 · Juanmi Taboada · CC BY-SA 4.0

This worked for me:

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

Reboot the system to get the firewall rules enabled. Via: https://discuss.linuxcontainers.org/t/lxd-bridge-doesnt-work-with-ipv4-and-ufw-with-nftables/10034/17

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-01-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。