Ubuntu bridge does not receive an IP address
https://askubuntu.com/questions/1541684/ubuntu-bridge-does-not-receive-an-ip-address
I am working inside an Ubuntu 24.04.2 LTS VM having two physical NICs, enp1s0 and enp6s0. I want to create a bridge with netplan that includes only one of these interfaces. I am using this netplan:
DEV2=enp6s0
cat <<EOF | sudo tee /etc/netplan/bridge.yaml
network:
version: 2
renderer: networkd
ethernets:
${DEV2}:
dhcp4: false
bridges:
br0:
dhcp4: true
interfaces:
- ${DEV2}
EOF
sudo chmod og-r /etc/netplan/bridge.yaml
sudo netplan apply
However, the bridge never receives an IPv4 address from the DHCP server, as shown with ip a:
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 56:6f:94:0a:00:0f brd ff:ff:ff:ff:ff:ff
inet 172.20.28.115/24 metric 100 brd 172.20.28.255 scope global dynamic enp1s0
valid_lft 7198sec preferred_lft 7198sec
inet6 fe80::546f:94ff:fe0a:f/64 scope link
valid_lft forever preferred_lft forever
3: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
link/ether 56:6f:94:0a:00:00 brd ff:ff:ff:ff:ff:ff
4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 46:f8:7f:dc:43:0a brd ff:ff:ff:ff:ff:ff
inet6 fe80::44f8:7fff:fedc:430a/64 scope link
valid_lft forever preferred_lft forever
If I try to get the IP address manually with dhcpcd --debug br0, but I only get a link-local address (169.254.107.157/16):
dhcpcd-10.0.6 starting
chrooting as dhcpcd to /usr/lib/dhcpcd
sandbox: seccomp
spawned manager process on PID 1830
spawned privileged proxy on PID 1831
spawned network proxy on PID 1832
spawned controller proxy on PID 1833
br0: spawned DHCP6 proxy fe80::44f8:7fff:fedc:430a on PID 1834
br0: executing: /usr/lib/dhcpcd/dhcpcd-run-hooks PREINIT
br0: executing: /usr/lib/dhcpcd/dhcpcd-run-hooks CARRIER
DUID 00:01:00:01:2f:47:11:66:46:f8:7f:dc:43:0a
br0: IAID 7f:dc:43:0a
br0: delaying IPv6 router solicitation for 1.0 seconds
br0: delaying IPv4 for 0.2 seconds
br0: reading lease: /var/lib/dhcpcd/br0.lease
br0: soliciting a DHCP lease
br0: sending DISCOVER (xid 0x7ac5566c), next in 4.4 seconds
br0: spawned BPF BOOTP on PID 1838
br0: soliciting an IPv6 router
br0: sending Router Solicitation
br0: sending DISCOVER (xid 0x7ac5566c), next in 7.3 seconds
br0: process BPF BOOTP already started on pid 1838
br0: sending Router Solicitation
br0: probing for an IPv4LL address
br0: spawned BPF ARP 169.254.107.157 on PID 1839
br0: probing for 169.254.107.157
br0: ARP probing 169.254.107.157 (1 of 3), next in 1.4 seconds
br0: ARP probing 169.254.107.157 (2 of 3), next in 1.1 seconds
br0: ARP probing 169.254.107.157 (3 of 3), next in 2.0 seconds
br0: sending Router Solicitation
br0: using IPv4LL address 169.254.107.157
br0: adding IP address 169.254.107.157/16 broadcast 169.254.255.255
br0: adding route to 169.254.0.0/16
br0: adding default route
br0: ARP announcing 169.254.107.157 (1 of 2), next in 2.0 seconds
br0: executing: /usr/lib/dhcpcd/dhcpcd-run-hooks IPV4LL
Dropped protocol specifier '.ipv4ll' from 'br0.ipv4ll'. Using 'br0' (ifindex=4).
forked to background
This are the logs from journalctl:
systemd-networkd[895]: br0: netdev ready
systemd-networkd[895]: enp6s0: Reconfiguring with /run/systemd/network/10-netplan-enp6s0.network.
systemd-networkd[895]: enp1s0: Reconfiguring with /run/systemd/network/10-netplan-enp1s0.network.
kernel: br0: port 1(enp6s0) entered blocking state
kernel: br0: port 1(enp6s0) entered disabled state
kernel: virtio_net virtio5 enp6s0: entered allmulticast mode
kernel: virtio_net virtio5 enp6s0: entered promiscuous mode
systemd-networkd[895]: enp1s0: DHCP lease lost
systemd-networkd[895]: enp1s0: DHCPv6 lease lost
systemd-networkd[895]: br0: Configuring with /run/systemd/network/10-netplan-br0.network.
kernel: br0: port 1(enp6s0) entered blocking state
kernel: br0: port 1(enp6s0) entered forwarding state
systemd-networkd[895]: br0: Link UP
systemd-networkd[895]: br0: Gained carrier
systemd-networkd[895]: enp1s0: Configuring with /run/systemd/network/10-netplan-enp1s0.network.
systemd-networkd[895]: enp1s0: DHCPv6 lease lost
systemd-networkd[895]: br0: Configuring with /run/systemd/network/10-netplan-br0.network.
systemd-networkd[895]: br0: DHCPv6 lease lost
systemd-networkd[895]: enp6s0: Configuring with /run/systemd/network/10-netplan-enp6s0.network.
systemd[1]: Starting netplan-ovs-cleanup.service - OpenVSwitch configuration for cleanup...
systemd[1]: netplan-ovs-cleanup.service: Deactivated successfully.
systemd[1]: Finished netplan-ovs-cleanup.service - OpenVSwitch configuration for cleanup.
sudo[2276]: pam_unix(sudo:session): session closed for user root
systemd-networkd[895]: br0: Gained IPv6LL
systemd-networkd[895]: enp1s0: DHCPv4 address 172.20.28.115/24, gateway 172.20.28.1 acquired from 172.20.28.1
Using Openvswitch, by specifying openvswitch: {} option in the netplan, makes no difference. Why does not br0 get an IPv4 address? I explored different paths, like setting the same MAC address for both the bridge and the interface, but with no success (EDIT: turned out I may have misconfigured the netplan, see my answer). I have also enabled IP forwarding and ARP proxying, but they have not changed the situation:
sudo sysctl -w net.ipv4.ip_forward=1
sudo sysctl -w net.ipv4.conf.${DEV2}.proxy_arp=1
sudo sysctl -w net.ipv4.conf.${BRIDGE}.proxy_arp=1
Does the VM need additional configurations?