Thank you both for your messages: I continued my experiments and I have some more info to share.
The default configuration should work all the time, and if there are any situations where it randomly does not work, then itâs a bug that must be resolved.
I am starting to think that this is the case: I now have two ârealâ (bare-metal) machines configured identically, these are my workstation and my laptop. Both show the same behavior by which containers do not get IPs.
As a test, on the workstation I installed LXD 3.0 from snap by following these instructions (thank you, stgraber) and⊠everything works out of the box. Containers do get an IP, and they can access the internet without problems.
For example, if you create a container before you run lxd init, then lxdbr0 does not exist, and that container will not be able to get proper network configuration.
I tend to exclude cases like this: I followed the instructions in the tutorial very carefully, and never used containers before. I even followed the instructions here to restart the procedure a few times.
Can you show:
Since the snap install works flawlessly, that is enough for my âpractical purposesâ. However, I think that my system is âpretty standardâ (Ubuntu 16.04 with default LXD installation): so I will keep my laptop at the âoldâ LXD in order to be able to share data with you, and maybe trace down some bug. Here is the info you requested (from laptop):
The problem:
matteo@matteo-laptop:~$ lxc list
+-------+---------+------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+-------+---------+------+------+------------+-----------+
| test | RUNNING | | | PERSISTENT | 0 |
+-------+---------+------+------+------------+-----------+
| test2 | RUNNING | | | PERSISTENT | 0 |
+-------+---------+------+------+------------+-----------+
Container config (note that I reverted the experiments with macvlan
and using bridged
now, but that does not help):
matteo@matteo-laptop:~$ lxc config show --expanded test
architecture: x86_64
config:
environment.http_proxy: ""
user.network_mode: link-local
volatile.base_image: 353b1a2c367ec983fd9d1532171618cd967e96d77a06f6b6e024c39ec010e8d7
volatile.eth0.hwaddr: 00:16:3e:1a:04:ba
volatile.idmap.base: "0"
volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":165536,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":165536,"Nsid":0,"Maprange":65536}]'
volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":165536,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":165536,"Nsid":0,"Maprange":65536}]'
volatile.last_state.power: RUNNING
devices:
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
type: disk
ephemeral: false
profiles:
- default
stateful: false
description: ""
matteo@matteo-laptop:~$ lxc config show --expanded test2
architecture: x86_64
config:
environment.http_proxy: ""
user.network_mode: link-local
volatile.base_image: 353b1a2c367ec983fd9d1532171618cd967e96d77a06f6b6e024c39ec010e8d7
volatile.eth0.hwaddr: 00:16:3e:0c:6d:d3
volatile.idmap.base: "0"
volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":165536,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":165536,"Nsid":0,"Maprange":65536}]'
volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":165536,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":165536,"Nsid":0,"Maprange":65536}]'
volatile.last_state.power: RUNNING
devices:
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
type: disk
ephemeral: false
profiles:
- default
stateful: false
description: ""
Processes:
matteo@matteo-laptop:~$ lxc exec test -- ps fauxww
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 367 0.0 0.0 37760 2076 ? Rs+ 08:10 0:00 ps fauxww
root 1 0.1 0.0 37516 4148 ? Ss 07:59 0:00 /sbin/init
root 52 0.0 0.0 41724 1816 ? Ss 07:59 0:00 /lib/systemd/systemd-udevd
root 59 0.0 0.0 35272 4612 ? Ss 07:59 0:00 /lib/systemd/systemd-journald
root 285 0.0 0.0 20096 1544 ? Ss 07:59 0:00 /lib/systemd/systemd-logind
root 286 0.0 0.0 27728 1752 ? Ss 07:59 0:00 /usr/sbin/cron -f
daemon 287 0.0 0.0 26044 1460 ? Ss 07:59 0:00 /usr/sbin/atd -f
root 288 0.0 0.0 65508 3680 ? Ss 07:59 0:00 /usr/sbin/sshd -D
syslog 290 0.0 0.0 186896 2320 ? Ssl 07:59 0:00 /usr/sbin/rsyslogd -n
root 291 0.0 0.0 274488 3980 ? Ssl 07:59 0:00 /usr/lib/accountsservice/accounts-daemon
message+ 293 0.0 0.0 42888 2420 ? Ss 07:59 0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root 304 0.0 0.1 289364 20028 ? Ssl 07:59 0:00 /usr/lib/snapd/snapd
root 311 0.0 0.0 277176 4184 ? Ssl 07:59 0:00 /usr/lib/policykit-1/polkitd --no-debug
root 347 0.0 0.0 14472 1388 console Ss+ 07:59 0:00 /sbin/agetty --noclear --keep-baud console 115200 38400 9600 linux
matteo@matteo-laptop:~$ lxc exec test2 -- ps fauxww
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 410 0.0 0.0 37760 2108 ? R 08:14 0:00 ps fauxww
root 1 0.0 0.0 37528 4168 ? Ss 08:07 0:00 /sbin/init
root 53 0.0 0.0 35272 4560 ? Ss 08:07 0:00 /lib/systemd/systemd-journald
root 59 0.0 0.0 41724 1872 ? Ss 08:07 0:00 /lib/systemd/systemd-udevd
daemon 286 0.0 0.0 26044 1440 ? Ss 08:07 0:00 /usr/sbin/atd -f
root 289 0.0 0.0 20096 1540 ? Ss 08:07 0:00 /lib/systemd/systemd-logind
message+ 292 0.0 0.0 42888 2320 ? Ss 08:07 0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root 297 0.0 0.1 222164 20508 ? Ssl 08:07 0:00 /usr/lib/snapd/snapd
root 298 0.0 0.0 65508 3484 ? Ss 08:07 0:00 /usr/sbin/sshd -D
root 299 0.0 0.0 272868 3936 ? Ssl 08:07 0:00 /usr/lib/accountsservice/accounts-daemon
root 300 0.0 0.0 26068 1656 ? Ss 08:07 0:00 /usr/sbin/cron -f
syslog 301 0.0 0.0 186896 2368 ? Ssl 08:07 0:00 /usr/sbin/rsyslogd -n
root 319 0.0 0.0 277176 4192 ? Ssl 08:07 0:00 /usr/lib/policykit-1/polkitd --no-debug
root 338 0.0 0.0 12840 1276 console Ss+ 08:07 0:00 /sbin/agetty --noclear --keep-baud console 115200 38400 9600 linux
Kernel ring (only the last 60 lines, to keep it short):
matteo@matteo-laptop:~$ dmesg | tail -n60
[ 23.086051] audit: type=1400 audit(1525334382.221:30): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/usr/bin/lxc-start" pid=2897 comm="apparmor_parser"
[ 23.109252] audit: type=1400 audit(1525334382.245:31): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="lxc-container-default" pid=2904 comm="apparmor_parser"
[ 23.109281] audit: type=1400 audit(1525334382.245:32): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="lxc-container-default-cgns" pid=2904 comm="apparmor_parser"
[ 23.109302] audit: type=1400 audit(1525334382.245:33): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="lxc-container-default-with-mounting" pid=2904 comm="apparmor_parser"
[ 23.109321] audit: type=1400 audit(1525334382.245:34): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="lxc-container-default-with-nesting" pid=2904 comm="apparmor_parser"
[ 23.328789] audit: type=1400 audit(1525334382.465:35): apparmor="STATUS" operation="profile_load" profile="unconfined" name="lxd-test_</var/lib/lxd>" pid=2989 comm="apparmor_parser"
[ 23.439892] eth0: renamed from mcBC61SU
[ 23.466854] device lxdbr0 entered promiscuous mode
[ 24.491475] audit: type=1400 audit(1525334383.629:36): apparmor="STATUS" operation="profile_load" label="lxd-test_</var/lib/lxd>//&:lxd-test_<var-lib-lxd>://unconfined" name="/usr/bin/lxc-start" pid=3215 comm="apparmor_parser"
[ 24.493367] audit: type=1400 audit(1525334383.629:37): apparmor="STATUS" operation="profile_load" label="lxd-test_</var/lib/lxd>//&:lxd-test_<var-lib-lxd>://unconfined" name="/usr/lib/snapd/snap-confine" pid=3217 comm="apparmor_parser"
[ 24.493391] audit: type=1400 audit(1525334383.629:38): apparmor="STATUS" operation="profile_load" label="lxd-test_</var/lib/lxd>//&:lxd-test_<var-lib-lxd>://unconfined" name="/usr/lib/snapd/snap-confine//mount-namespace-capture-helper" pid=3217 comm="apparmor_parser"
[ 24.495235] audit: type=1400 audit(1525334383.633:39): apparmor="STATUS" operation="profile_load" label="lxd-test_</var/lib/lxd>//&:lxd-test_<var-lib-lxd>://unconfined" name="/usr/lib/lxd/lxd-bridge-proxy" pid=3216 comm="apparmor_parser"
[ 27.163652] Loading iSCSI transport class v2.0-870.
[ 27.442281] usb 1-1: new low-speed USB device number 5 using xhci_hcd
[ 27.574961] usb 1-1: New USB device found, idVendor=046d, idProduct=c069
[ 27.574970] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 27.574977] usb 1-1: Product: USB Laser Mouse
[ 27.574982] usb 1-1: Manufacturer: Logitech
[ 27.575328] usb 1-1: ep 0x81 - rounding interval to 64 microframes, ep desc says 80 microframes
[ 27.604064] usbcore: registered new interface driver usbhid
[ 27.604073] usbhid: USB HID core driver
[ 27.612999] input: Logitech USB Laser Mouse as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/0003:046D:C069.0002/input/input16
[ 27.667238] hid-generic 0003:046D:C069.0002: input,hidraw1: USB HID v1.10 Mouse [Logitech USB Laser Mouse] on usb-0000:00:14.0-1/input0
[ 30.356687] acer_wmi: Unknown function number - 6 - 1
[ 251.159833] usb 1-6: new high-speed USB device number 6 using xhci_hcd
[ 251.365367] usb 1-6: New USB device found, idVendor=1058, idProduct=0820
[ 251.365378] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=5
[ 251.365384] usb 1-6: Product: My Passport 0820
[ 251.365390] usb 1-6: Manufacturer: Western Digital
[ 251.365395] usb 1-6: SerialNumber: 575841314539344637435741
[ 251.386600] usb-storage 1-6:1.0: USB Mass Storage device detected
[ 251.386668] scsi host4: usb-storage 1-6:1.0
[ 251.386805] usbcore: registered new interface driver usb-storage
[ 251.388607] usbcore: registered new interface driver uas
[ 252.384693] scsi 4:0:0:0: Direct-Access WD My Passport 0820 1012 PQ: 0 ANSI: 6
[ 252.385185] scsi 4:0:0:1: Enclosure WD SES Device 1012 PQ: 0 ANSI: 6
[ 252.386910] sd 4:0:0:0: Attached scsi generic sg3 type 0
[ 252.387386] scsi 4:0:0:1: Attached scsi generic sg4 type 13
[ 252.387680] sd 4:0:0:0: [sdc] Spinning up disk...
[ 253.391826] .ready
[ 258.810806] sd 4:0:0:0: [sdc] 3906963456 512-byte logical blocks: (2.00 TB/1.82 TiB)
[ 258.811430] sd 4:0:0:0: [sdc] Write Protect is off
[ 258.811439] sd 4:0:0:0: [sdc] Mode Sense: 47 00 10 08
[ 258.812012] sd 4:0:0:0: [sdc] No Caching mode page found
[ 258.812023] sd 4:0:0:0: [sdc] Assuming drive cache: write through
[ 258.818118] sdc: sdc1 sdc2 sdc3 sdc4
[ 258.818906] ses 4:0:0:1: Attached Enclosure device
[ 258.820393] sd 4:0:0:0: [sdc] Attached SCSI disk
[ 505.599694] audit_printk_skb: 27 callbacks suppressed
[ 505.599696] audit: type=1400 audit(1525334864.733:49): apparmor="STATUS" operation="profile_load" profile="unconfined" name="lxd-test2_</var/lib/lxd>" pid=4559 comm="apparmor_parser"
[ 505.702781] eth0: renamed from mc7CY9QP
[ 506.175754] audit: type=1400 audit(1525334865.309:50): apparmor="STATUS" operation="profile_load" label="lxd-test2_</var/lib/lxd>//&:lxd-test2_<var-lib-lxd>://unconfined" name="/usr/lib/lxd/lxd-bridge-proxy" pid=4760 comm="apparmor_parser"
[ 506.207618] audit: type=1400 audit(1525334865.341:51): apparmor="STATUS" operation="profile_load" label="lxd-test2_</var/lib/lxd>//&:lxd-test2_<var-lib-lxd>://unconfined" name="/usr/sbin/tcpdump" pid=4761 comm="apparmor_parser"
[ 506.260901] audit: type=1400 audit(1525334865.393:52): apparmor="STATUS" operation="profile_load" label="lxd-test2_</var/lib/lxd>//&:lxd-test2_<var-lib-lxd>://unconfined" name="/sbin/dhclient" pid=4759 comm="apparmor_parser"
[ 506.261158] audit: type=1400 audit(1525334865.397:53): apparmor="STATUS" operation="profile_load" label="lxd-test2_</var/lib/lxd>//&:lxd-test2_<var-lib-lxd>://unconfined" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=4759 comm="apparmor_parser"
[ 506.261394] audit: type=1400 audit(1525334865.397:54): apparmor="STATUS" operation="profile_load" label="lxd-test2_</var/lib/lxd>//&:lxd-test2_<var-lib-lxd>://unconfined" name="/usr/lib/NetworkManager/nm-dhcp-helper" pid=4759 comm="apparmor_parser"
[ 506.261621] audit: type=1400 audit(1525334865.397:55): apparmor="STATUS" operation="profile_load" label="lxd-test2_</var/lib/lxd>//&:lxd-test2_<var-lib-lxd>://unconfined" name="/usr/lib/connman/scripts/dhclient-script" pid=4759 comm="apparmor_parser"
[ 506.362421] audit: type=1400 audit(1525334865.497:56): apparmor="STATUS" operation="profile_load" label="lxd-test2_</var/lib/lxd>//&:lxd-test2_<var-lib-lxd>://unconfined" name="lxc-container-default" pid=4758 comm="apparmor_parser"
[ 506.362757] audit: type=1400 audit(1525334865.497:57): apparmor="STATUS" operation="profile_load" label="lxd-test2_</var/lib/lxd>//&:lxd-test2_<var-lib-lxd>://unconfined" name="lxc-container-default-cgns" pid=4758 comm="apparmor_parser"
[ 506.363055] audit: type=1400 audit(1525334865.497:58): apparmor="STATUS" operation="profile_load" label="lxd-test2_</var/lib/lxd>//&:lxd-test2_<var-lib-lxd>://unconfined" name="lxc-container-default-with-mounting" pid=4758 comm="apparmor_parser"
Kernel version:
matteo@matteo-laptop:~$ uname -a
Linux matteo-laptop 4.4.0-121-generic #145-Ubuntu SMP Fri Apr 13 13:47:23 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Totally willing to share more if you are interested! Meanwhile, thanks for the help!