3

I booted pretty old PC (HP d530) with latest (2015.06) Gentoo linux minimal cd. The next step I wanted to perform was to enable SSH server on this machine.

I ran ifconfig to see the ip address of my machine. For the interface enp5s2 (only availible except of "lo") the ip address is 169.254.xxx.xxx

I started dhcp client to obtain ip address from router. It exited successfully, ping started to work, but in ifconfig there is still the same old ip address.

My router assigned 192.168.0.xxx, the PC is accessible through this address, but I'am not able to see it in ifconfig.

Nothing unusual in dmesg.

Why ifconfig is showing fake ip address?

peku33
  • 173

2 Answers2

2

Ok, I found solution.

This was an ipv4ll address created because of failure of ipv6 address assignment from dhcp.

Correct ipv4 address was visible in ip a

After adding

noipv6
noipv4ll

to dhcpcd.conf everything works great.

peku33
  • 173
1

This has been a known deficiency of both the GNU inetutils ifconfig and the NET-3 net-tools ifconfig for a long time. If your interface has multiple IP version 4 addresses, as will be the case if it has both a DHCP-assigned one and a link-local one, those two ifconfigs will only show you one of the addresses, in this case the link-local one. The GNU inetutils ifconfig moreover will not show you any IP version 6 addresses for the interface at all.

This has not been addressed in well over a decade in those tools. People did make patches for this, including one back in 2009 for the NET-3 net-tools one. It reached Bernd Eckenfels 4 years later, who never accepted it.

Having a second link-local IP version 4 address in 169.254.0.0/16 in addition to the "routable" one in 192.168.0.0/16 is not actually a problem for your network interface itself, and you could leave your system configured this way, with (as you observed) little to no ill-effect whatsoever, as long as no more than one network interface does this. Aside from the surprise to you that your system has this address, and that it has a concomitant route and will bind local sockets to this address when trying to connect to other link-local addresses, it is really only a significant problem for those two ifconfig tools.

As you note, ip will show you all of the IPv4 addresses.

So too will my ifconfig.

Further reading

JdeBP
  • 68,745