I’m not sure if this is one of the options you’d already discounted, but if you need your containers to have a static IP then you can assign one in LXD and it will create a static DHCP lease for the container’s MAC address that so that it gets it every time.
E.g.
lxc config device override <container> eth0 ipv4.address=n.n.n.n
This avoids needing to setup the IPs manually inside the container.
Regarding your specific question about DHCP option 50 in Ubuntu Focal images, I’ve just tried this now with a fresh image on LXD 4.4:
On my lxdbr0 bridge, setup tcpdump:
sudo tcpdump -pvnl -i lxdbr0 port 67 and port 68
In a separate terminal, launch a new focal container:
lxc launch images:ubuntu/focal c1
This records:
09:26:30.235578 IP (tos 0xc0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 302)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:16:3e:d1:3b:30, length 274, xid 0x19490c97, secs 1, Flags [none]
Client-Ethernet-Address 00:16:3e:d1:3b:30
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
Client-ID Option 61, length 7: ether 00:16:3e:d1:3b:30
Parameter-Request Option 55, length 11:
Subnet-Mask, Default-Gateway, Hostname, Domain-Name
Domain-Name-Server, MTU, Static-Route, Classless-Static-Route
Option 119, NTP, Option 120
MSZ Option 57, length 2: 576
Hostname Option 12, length 2: "c1"
09:26:30.235746 IP (tos 0xc0, ttl 64, id 15859, offset 0, flags [none], proto UDP (17), length 329)
10.109.89.1.67 > 10.109.89.111.68: BOOTP/DHCP, Reply, length 301, xid 0x19490c97, secs 1, Flags [none]
Your-IP 10.109.89.111
Server-IP 10.109.89.1
Client-Ethernet-Address 00:16:3e:d1:3b:30
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Offer
Server-ID Option 54, length 4: 10.109.89.1
Lease-Time Option 51, length 4: 3600
RN Option 58, length 4: 1800
RB Option 59, length 4: 3150
Subnet-Mask Option 1, length 4: 255.255.255.0
BR Option 28, length 4: 10.109.89.255
Default-Gateway Option 3, length 4: 10.109.89.1
Domain-Name-Server Option 6, length 4: 10.109.89.1
Domain-Name Option 15, length 3: "lxd"
Hostname Option 12, length 2: "c1"
09:26:30.237641 IP (tos 0xc0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 314)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:16:3e:d1:3b:30, length 286, xid 0x19490c97, secs 1, Flags [none]
Client-Ethernet-Address 00:16:3e:d1:3b:30
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Request
Client-ID Option 61, length 7: ether 00:16:3e:d1:3b:30
Parameter-Request Option 55, length 11:
Subnet-Mask, Default-Gateway, Hostname, Domain-Name
Domain-Name-Server, MTU, Static-Route, Classless-Static-Route
Option 119, NTP, Option 120
MSZ Option 57, length 2: 576
Server-ID Option 54, length 4: 10.109.89.1
Requested-IP Option 50, length 4: 10.109.89.111
Hostname Option 12, length 2: "c1"
09:26:30.241105 IP (tos 0xc0, ttl 64, id 15860, offset 0, flags [none], proto UDP (17), length 329)
10.109.89.1.67 > 10.109.89.111.68: BOOTP/DHCP, Reply, length 301, xid 0x19490c97, secs 1, Flags [none]
Your-IP 10.109.89.111
Server-IP 10.109.89.1
Client-Ethernet-Address 00:16:3e:d1:3b:30
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: ACK
Server-ID Option 54, length 4: 10.109.89.1
Lease-Time Option 51, length 4: 3600
RN Option 58, length 4: 1800
RB Option 59, length 4: 3150
Subnet-Mask Option 1, length 4: 255.255.255.0
BR Option 28, length 4: 10.109.89.255
Default-Gateway Option 3, length 4: 10.109.89.1
Domain-Name-Server Option 6, length 4: 10.109.89.1
Domain-Name Option 15, length 3: "lxd"
Hostname Option 12, length 2: "c1"
Then if I restart container lxc restart c1
:
09:30:04.115671 IP (tos 0xc0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 302)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:16:3e:d1:3b:30, length 274, xid 0xa0e6bef2, secs 1, Flags [none]
Client-Ethernet-Address 00:16:3e:d1:3b:30
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
Client-ID Option 61, length 7: ether 00:16:3e:d1:3b:30
Parameter-Request Option 55, length 11:
Subnet-Mask, Default-Gateway, Hostname, Domain-Name
Domain-Name-Server, MTU, Static-Route, Classless-Static-Route
Option 119, NTP, Option 120
MSZ Option 57, length 2: 576
Hostname Option 12, length 2: "c1"
09:30:04.115884 IP (tos 0xc0, ttl 64, id 19835, offset 0, flags [none], proto UDP (17), length 329)
10.109.89.1.67 > 10.109.89.111.68: BOOTP/DHCP, Reply, length 301, xid 0xa0e6bef2, secs 1, Flags [none]
Your-IP 10.109.89.111
Server-IP 10.109.89.1
Client-Ethernet-Address 00:16:3e:d1:3b:30
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Offer
Server-ID Option 54, length 4: 10.109.89.1
Lease-Time Option 51, length 4: 3600
RN Option 58, length 4: 1800
RB Option 59, length 4: 3150
Subnet-Mask Option 1, length 4: 255.255.255.0
BR Option 28, length 4: 10.109.89.255
Default-Gateway Option 3, length 4: 10.109.89.1
Domain-Name-Server Option 6, length 4: 10.109.89.1
Domain-Name Option 15, length 3: "lxd"
Hostname Option 12, length 2: "c1"
09:30:04.116799 IP (tos 0xc0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 314)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:16:3e:d1:3b:30, length 286, xid 0xa0e6bef2, secs 1, Flags [none]
Client-Ethernet-Address 00:16:3e:d1:3b:30
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Request
Client-ID Option 61, length 7: ether 00:16:3e:d1:3b:30
Parameter-Request Option 55, length 11:
Subnet-Mask, Default-Gateway, Hostname, Domain-Name
Domain-Name-Server, MTU, Static-Route, Classless-Static-Route
Option 119, NTP, Option 120
MSZ Option 57, length 2: 576
Server-ID Option 54, length 4: 10.109.89.1
Requested-IP Option 50, length 4: 10.109.89.111
Hostname Option 12, length 2: "c1"
09:30:04.120258 IP (tos 0xc0, ttl 64, id 19836, offset 0, flags [none], proto UDP (17), length 329)
10.109.89.1.67 > 10.109.89.111.68: BOOTP/DHCP, Reply, length 301, xid 0xa0e6bef2, secs 1, Flags [none]
Your-IP 10.109.89.111
Server-IP 10.109.89.1
Client-Ethernet-Address 00:16:3e:d1:3b:30
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: ACK
Server-ID Option 54, length 4: 10.109.89.1
Lease-Time Option 51, length 4: 3600
RN Option 58, length 4: 1800
RB Option 59, length 4: 3150
Subnet-Mask Option 1, length 4: 255.255.255.0
BR Option 28, length 4: 10.109.89.255
Default-Gateway Option 3, length 4: 10.109.89.1
Domain-Name-Server Option 6, length 4: 10.109.89.1
Domain-Name Option 15, length 3: "lxd"
Hostname Option 12, length 2: "c1"
So its only sending the option 50, requested IP, after the initial discover.
I’ve also recorded the desired behaviour you describe when using a Xenial image instead.
In netplan based containers, you can see the networkd config file generated by netplan by looking at:
/run/systemd/network/10-netplan-eth0.network
[Match]
Name=eth0
[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6
[DHCP]
ClientIdentifier=mac
RouteMetric=100
UseMTU=true
But there is nothing obvious there that is setting this behaviour. And Anonymize
is defaulting to false, so unlikely to be caused by that.
I’ve also observed what you said about physical Focal machines using networkd sending the Option 50 on initial Discover. Although in my case, there was no networkd config file in /run/systemd/network/ and instead it was being controlled by NetworkManager (as this was a desktop machine).
In your observations with a physical machine, was this using networkd with a config file or NetworkManager?