Search code examples
linuxip-addressyoctoconnman

Yocto makes DHCP request when configured with static IP


I recently took over a project, where a linux image is built with yocto. I updated the layer references to the newest version in dunfell (they were stuck in november 2020) and implemented the necessary changes. Since then I have problems setting a static IP. When I reboot the device after executing the following command, I suddenly have 2 IP addresses associated with my interface:

connmanctl config eth_<mac_address>_cable --ipv4 manual 10.78.113.71 255.255.252.0 10.78.112.1
reboot
ip addr show eth0

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel qlen 1000
    link/ether 00:14:2d:a5:ce:26 brd ff:ff:ff:ff:ff:ff
    inet 10.78.113.57/22 brd 10.78.115.255 scope global dynamic eth0
       valid_lft 3516sec preferred_lft 3516sec
    inet 10.78.113.71/22 brd 10.78.115.255 scope global secondary eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::214:2dff:fea5:ce26/64 scope link
       valid_lft forever preferred_lft forever

Connman still shows the IP I set, but ifconfig shows 10.78.113.57 which is the address received by the DHCP server.

I do not know what causes the dhcp request. I have seen this question, but I do not have a /etc/network/interfaces file, and ip addr del 10.78.113.57 dev eth0 only helps until the next restart.


Solution

  • The offending DHCP configuration comes from /lib/systemd/network/80-wire.network which is installed by systemd (oe-core) here. Previously, the layer meta-toradex-bsp-common had a configuration to disable this setting.

    In this commit, they stopped these changes from always being applied. Our solution is to copy the configuration from Toradex and apply it ourselves.