After assigning public IP address using DHCP, whatsmyip shows expected 193.x.x.x but ifconfig shows 169.254.x.x link-local address

3

1

The computer in question has a Linux SO and is connected to a local network that has DHCP service active. I configured a public ip address to be given to that computer by the DHCP and I can ssh into it using this ip address. Now comes the weird part.

ifconfig returns a 169.254.x.x address. I have read that 169.254.x.x is given to a computer when DHCP fails to give it a proper address. But it did give a proper address, I can ssh to it (using the public IP address) and sites as http://www.whatsmyip.org/ tell me the computer has the public ip address I configured on the DHCP.

How can this be possible and what details should I include in this post?

When I asked my colleague to restart his network

/etc/init.d/net.eth0 restart

this was his output:

 * Caching service dependencies  ...                [ ok ]
 * Unmounting network filesystems ...               [ ok ]
 * Bringing down interface eth0
 *   Stopping dhcpcd on eth0 ...                    [ ok ]
 * Bringing up interface eth0
 *   dhcp ...
 *     Running dhcpcd ...
control_open: Connection refused
eth0: adding address fe80::f85f:1ef7:db63:7475
eth0: waiting for carrier
eth0: carrier acquired
DUID 00:01:00:01:1b:ef:52:ea:dc:85:de:20:38:fa
eth0: IAID a9:04:2c:82
eth0: soliciting an IPv6 router
eth0: rebinding lease of 193.136.136.136
eth0: probing for an IPv4LL address
eth0: DHCP lease expired
eth0: soliciting a DHCP lease
eth0: using IPv4LL address 169.254.78.15
eth0: adding route to 169.254.0.0/16
forked to background, child pid 6332                [ ok ]
 *     received address 169.254.78.15/16            [ ok ]
* Mounting network filesystems ...

The output of ifconfig is as follows:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 169.254.78.15  netmask 255.255.0.0  broadcast 169.254.255.255
        inet6 fe80::f85f:1ef7:db63:7475  prefixlen 64  scopeid 0x20<link>
        ether 48:85:a3:04:2d:81  txqueuelen 1000  (Ethernet)
        RX packets 113090  bytes 80195148 (76.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 39425  bytes 7462270 (7.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 2259  bytes 217008 (211.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2259  bytes 217008 (211.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether df:83:de:11:37:fb  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ip addr shows both IPs, 169.x.x.x and 193.x.x.x. Still haven't discover why 169.x.x.x is given by DHCP server.

rmarques

Posted 2015-08-11T09:00:55.540

Reputation: 41

How do you mean you configured a public IP address to be given by the DHCP? As you're running Linux, are you using a network manager or are you using the /etc/network/interfaces file to manage your connections? – Kinnectus – 2015-08-11T09:11:01.383

I did not configure the IP in the computer, I did it in the DHCP server. – rmarques – 2015-08-11T09:32:28.840

Because I can ssh to that computer using 193.136.136.136, the address that I wanted. – rmarques – 2015-08-11T09:54:23.130

What is the output of ifconfig? – Niall – 2015-08-11T10:13:56.520

And: what does ifconfig return when used on the other computers? – Arjan – 2015-08-11T11:13:11.930

@Arjan not sure re ifconfig, but the linux commands that show default gateway, like(or something like) ip route show and route -n and traceroute show a different default gateway on different computers. Some show 192.x.x.x some show 10.x.x.x some show 193.x.x.x And the behemonth behind all this is a Cisco VLAN Switch – barlop – 2015-08-11T11:31:04.533

@Arjan and you would see that if you went into the chat and read what was said and spoke to him! (as you know, the admins here aren't fans of numerous comments) – barlop – 2015-08-11T11:36:38.763

output of ifconfig added – rmarques – 2015-08-11T11:43:38.673

"Still haven't discover why 169.x.x.x is given by DHCP server" -- why do you think it was assigned by the DHCP server? I agree that your DHCP is assigning the 193.x.x.x address. Good. (I don't know if DHCP should then also assign an address from the local network.) But I always thought that 169.254.x.x addresses were assigned by a computer to itself when it did not get an address assigned by the DHCP server (after trying to ensure no other computer on the network is already using it). – Arjan – 2015-08-13T08:42:13.943

Well I assumed it was the DHCP, maybe it was the computer that assigned itself that IP, but why has it done that if the DHCP gave it the address I asked for? – rmarques – 2015-08-14T18:30:50.950

Can you edit your question to make clear if your colleague is seeing the same problem? (Why did you ask them to restart their network rather than restarting your own?) Some Googling shows that some others get an offered ... from ... as the result of rebinding lease of ..., which made me wonder if your DHCP server is really extending the lease? But even for them, it it is still followed by probing for an IPv4LL address, even before awaiting the rebind result... So maybe seeing both is just not an issue...?

– Arjan – 2015-08-15T14:53:29.123

Answers

3

IP's from the range 169.254.x.x are an indication that an address has not been obtained from the DHCP.

From Wikipedia on the 169.254.x.x range;

In IPv4, link-local addresses are codified in RFC 6890 and RFC 3927. Their utility is in self-autoconfiguration by network devices when Dynamic Host Configuration Protocol (DHCP) services are not available and manual configuration by a network administrator is not desirable.

The block 169.254.0.0/16 is reserved for this purpose, with the exception of the first and the last /24 subnets in the range. If a host on an IEEE 802 (ethernet) network cannot obtain a network address via DHCP, an address from 169.254.1.0 to 169.254.254.255 may be assigned pseudorandomly. The standard prescribes that address collisions must be handled gracefully.

Your IPs are listed by ifconfig and the public (visible externally) is being identified by http://www.whatsmyip.org/.

It is very typical that the internal or local network is on a different (and often private) IP address range to the external network. The external IP may be limited and NATing is used to route the external traffic to your internal device/PC.

Niall

Posted 2015-08-11T09:00:55.540

Reputation: 1 944

Comments are not for extended discussion; this conversation has been moved to chat.

– Sathyajith Bhat – 2015-08-11T13:52:12.930

@Arjan moving it to chat helps keep the question/answer clear while still retaining the comments in a nice place to talk to or reference later ;) also noticed you're back in action - good to have you again

– Sathyajith Bhat – 2015-08-13T11:21:22.350

3

You’re using the deprecated ifconfig command. It shows only one IPv4 address per interface even though one interface can have multiple addresses assigned.

Try the ip command instead:

user@host ~ $ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet x.x.x.x peer x.x.x.x/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet x.x.x.x/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2a01:xxxx:xxxx:xxxx::4/128 scope global
       valid_lft forever preferred_lft forever
    inet6 2a01:xxxx:xxxx:xxxx::3/128 scope global
       valid_lft forever preferred_lft forever
    inet6 2a01:xxxx:xxxx:xxxx::2/128 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::xxxx:xxxx:xxxx:xxxx/64 scope link
       valid_lft forever preferred_lft forever

You can also set dhcpcd to not set a IPv4LL address, see the man page.

Daniel B

Posted 2015-08-11T09:00:55.540

Reputation: 40 502

I would not call obsolete command , only that there is a better option on Linux, since in freebsd and other unix command continues being ifconfig – Francisco Tapia – 2015-08-11T13:05:27.870

@FranciscoTapia It’s just that Linux is not Unix. ;) It’s a completely different command on other operating systems, so it’s not really comparable. ifconfig on Linux is a relict of the past. Sure it’s easy to use, but that’s really all there is. – Daniel B – 2015-08-11T13:19:45.023

do not take my comment as a criticism, i've tested for my self all advantages of ip command, im just claiming respect for the oldies ;) PD: Man pages show the folowing note: " This program is obsolete! For replacement check ip addr and ip link. For statistics use ip -s link. " :o – Francisco Tapia – 2015-08-11T13:33:34.220