Only Ubuntu 16.04 image cannot getting ipv4 on Ubuntu 22.04

Hello,

LXD version 5.8 (I first notice in version 5.3). Host OS Ubuntu 22.04. I have created several Ubuntu containers, but only 16.04 cannot getting ipv4(ipv6 only)

+----------------+---------+------------------------+-----------------------------------------------+-----------+-----------+
| ubuntu1404     | RUNNING | 10.207.109.35 (eth0)   | fd42:8422:1ba2:df25:216:3eff:fee1:956d (eth0) | CONTAINER | 0         |
+----------------+---------+------------------------+-----------------------------------------------+-----------+-----------+
| ubuntu1604     | RUNNING |                        | fd42:8422:1ba2:df25:216:3eff:fe68:82a2 (eth0) | CONTAINER | 0         |
+----------------+---------+------------------------+-----------------------------------------------+-----------+-----------+
| ubuntu1804     | RUNNING | 10.207.109.119 (eth0)  | fd42:8422:1ba2:df25:216:3eff:fe56:d52c (eth0) | CONTAINER | 0         |
+----------------+---------+------------------------+-----------------------------------------------+-----------+-----------+
| ubuntu2004     | RUNNING | 10.207.109.87 (eth0)   | fd42:8422:1ba2:df25:216:3eff:fe92:752b (eth0) | CONTAINER | 0         |
+----------------+---------+------------------------+-----------------------------------------------+-----------+-----------+
$ lxc config show ubuntu1604 --expanded
architecture: x86_64
config:
  image.architecture: amd64
  image.description: ubuntu 16.04 LTS amd64 (release) (20211001)
  image.label: release
  image.os: ubuntu
  image.release: xenial
  image.serial: "20211001"
  image.type: squashfs
  image.version: "16.04"
  volatile.base_image: 712a5836865525eecd8b429afa7430e8a2480aeff68804c59a0524dc8b7683ab
  volatile.cloud-init.instance-id: bcc7b258-db61-41f7-b13d-b143f50e422c
  volatile.eth0.host_name: veth632dfd74
  volatile.eth0.hwaddr: 00:16:3e:68:82:a2
  volatile.idmap.base: "0"
  volatile.idmap.current: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.power: RUNNING
  volatile.uuid: 7b0bb001-c61b-4d38-ae97-19916b542041
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: lxdbr0
    type: nic
  root:
    path: /
    pool: default
    type: disk
ephemeral: false
profiles:
- default
stateful: false
description: ""

$ lxc config show ubuntu1804 --expanded
architecture: x86_64
config:
  image.architecture: amd64
  image.description: ubuntu 18.04 LTS amd64 (release) (20221117)
  image.label: release
  image.os: ubuntu
  image.release: bionic
  image.serial: "20221117"
  image.type: squashfs
  image.version: "18.04"
  volatile.base_image: 9146fc9ba932ee07d02287a52986f311811b69112e646ed0bc18ecb39143b692
  volatile.cloud-init.instance-id: 62875c59-098f-4eea-8052-79ad87bb9d87
  volatile.eth0.host_name: veth8e53045a
  volatile.eth0.hwaddr: 00:16:3e:56:d5:2c
  volatile.idmap.base: "0"
  volatile.idmap.current: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.power: RUNNING
  volatile.uuid: 6717352c-52a9-4f6d-bbe0-809fb5338acf
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: lxdbr0
    type: nic
  root:
    path: /
    pool: default
    type: disk
ephemeral: false
profiles:
- default
stateful: false
description: ""

~$ lxc exec ubuntu1604 -- 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
38: eth0@if39: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:68:82:a2 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fd42:8422:1ba2:df25:216:3eff:fe68:82a2/64 scope global mngtmpaddr dynamic
       valid_lft 3134sec preferred_lft 3134sec
    inet6 fe80::216:3eff:fe68:82a2/64 scope link
       valid_lft forever preferred_lft forever
~$ lxc exec ubuntu1604 -- ip r
~$
~$ lxc exec ubuntu1604 -- ps aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0  36436  1592 ?        Ss   07:54   0:00 /sbin/init
root          24  0.0  0.0  37764  1700 pts/1    Rs+  08:12   0:00 ps aux

$ lxc exec ubuntu1604 -- dhclient
~$ lxc exec ubuntu1604 -- 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
38: eth0@if39: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:68:82:a2 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.207.109.95/24 brd 10.207.109.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fd42:8422:1ba2:df25:216:3eff:fe68:82a2/64 scope global mngtmpaddr dynamic
       valid_lft 3592sec preferred_lft 3592sec
    inet6 fe80::216:3eff:fe68:82a2/64 scope link
       valid_lft forever preferred_lft forever
$ lxc exec ubuntu1604 -- ip r
default via 10.207.109.1 dev eth0
10.207.109.0/24 dev eth0  proto kernel  scope link  src 10.207.109.95
~$ lxc exec ubuntu1604 -- ping google.com
ping: unknown host google.com

ip 192.168.0.1 is my router

~$ lxc exec ubuntu1604 -- ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=63 time=0.336 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=63 time=0.383 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=63 time=0.526 ms
64 bytes from 192.168.0.1: icmp_seq=4 ttl=63 time=0.575 ms
^C
--- 192.168.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3074ms
rtt min/avg/max/mdev = 0.336/0.455/0.575/0.098 ms

But this ip will not persistent, so I have to run dhclient to get the ip

To stop the container (Ubuntu 16.04), I need to run with --force options. Not need the option for other container. I have tried to delete and created container with Ubuntu 16.04 several times, but still cannot getting ipv4

My ufw is inactive. I have run LXD for 3 years, but I forgot if I ever created Ubuntu 16.04 container and got the same problem. But Iā€™m sure that the container that I created, will get ipv4.

Is Ubuntu 16.04 image have the problem? How to get ip and dns right on the image?

Thanks in advanced

You need to use cgroupv1 to start Ubuntu 16.04 containers. Or use a LXD VM instead.

See Does Ubuntu 16.04 lxc container work on Ubuntu 22.04 lxd host? - #3 by giox969

1 Like