1

I have Embedded Linux devices connected to a local network via Ethernet cable connection. I access each device via their local IP addresses on subnet 192.168.34.0/24. For example, one device has 192.168.34.240.

When I run ifconfig on the terminal inside the device, I get different IP addresses beginning with 169 as below. I am confused. Why is this?

eth0 Link encap:Ethernet HWaddr 00:D0:91:4B:45:C9 inet addr:169.254.253.217 Bcast:169.254.255.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:634513 errors:0 dropped:3 overruns:0 frame:0 TX packets:1318475 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:78343668 (74.7 MiB) TX bytes:399586128 (381.0 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:24085508 errors:0 dropped:0 overruns:0 frame:0 TX packets:24085508 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:11614050334 (10.8 GiB) TX bytes:11614050334 (10.8 GiB) 
1
  • 2
    Search for "link-local address". That tells you what it is, but it doesn't answer your question of why. Commented Oct 6, 2021 at 11:15

1 Answer 1

6

Because on Linux ifconfig uses an obsolete kernel API (ioctl-based) which has been superseded more than 20 years ago (and improved over time) by an other kernel API based on netlink socket messages. Among other limitations of the older API:

  • can handle only one IPv4 address (though it can handle multiple IPv6 addresses). Even removing this address is done by a kludge: setting the address as 0.0.0.0
  • will not provide at the same time the netmask of the address when setting it. So assigning an address usually requires two system calls: one for the (host part of) the address, one to fix its netmask
  • handling of more than one IPv4 address is also done with a kludge: so-called alias interfaces (really implemented with a label on an address and not as a separate interface), which are seen like this only by ifconfig, not by other parts (route, firewall...).
  • as OP shows, additional IP addresses without a label (so configured with the newer API) won't be seen at all by ifconfig.

Obviously if there is no address label (which if named correctly would then be displayed as alias interface by ifconfig), your network was configured using the newer netlink-based API. So you might even spare embedded space by sticking to newer tools and removing ifconfig completely.

ip address 

will display all addresses assigned on all interfaces, including multiple IPv4 addresses if more than one on it.

It's possible to reimplement ifconfig using the newer API (there's at least a regular user of UL SE here that did this), but it looks like that upgrading this command (eg: for compatibility with other *NIX) instead of (slowly) replacing it with newer tools wasn't something that interested most Linux developers or distribution maintainers.

So on Linux you should consider using ip link and ip address instead of ifconfig. Likewise, ip route to replace route, bridge (in addition to ip link) to replace brctl and then other subcommands of ip to replace various other commands (for VLANs, tunnels, bond interfaces...).

Now about why there is more than one address. The likely reason is that the device makes use of Avahi/Zeroconf (equivalent to Apple's Bonjour implementation) to communicate in the LAN and announce features. At the same time it's probably configured with DHCP for standard communication (including to Internet). Zeroconf uses a (non-routable) IPv4LL address separate from the usual address brought by using DHCP.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.