Ubuntu – ip addr show is showing me two IP address on one interface


I am seeing two IP address on a single interface in a weird way.
This is my output of ifconfig -a

eth0      Link encap:Ethernet  HWaddr b8:27:eb:26:b1:c8  
          inet addr:  Bcast:  Mask:
          RX packets:456 errors:0 dropped:0 overruns:0 frame:0
          TX packets:519 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:63643 (62.1 KiB)  TX bytes:111910 (109.2 KiB)

This is my /etc/network/interfaces file output

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static

auto eth1
allow-hotplug eth1
iface eth1 inet static
#       address 0
#       subnet
#       gateway

And this is my output for sudo ip addr show

1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether b8:27:eb:26:b1:c8 brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
       valid_lft forever preferred_lft forever
    inet brd scope global eth0
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
    link/ether 00:00:00:00:6c:f8 brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth1
       valid_lft forever preferred_lft forever

As we can see here eth0 has two ip address and is only shown by ip command and not by ifconfig or /etc/network/interfaces file. I am unable to understand from where this is coming or how to disable the 2nd IP permanently. I would like to get rid of the 2nd IP address permanently.

I have also noticed that this IP comes after a second or so when the system is booted. When I do dmesg I see these are the last few lines-

[   15.270464] device eth1 entered promiscuous mode
[   15.576206] asix 1-1.4:1.0 eth1: link up, 100Mbps, full-duplex, lpa 0xCDE1

Best Answer

I had the same issue.

Finally found that in my distro (debian jessie) the static ip is set in the file /etc/dhcpcd.conf and looked like:

 39 # A hook script is provided to lookup the hostname if not set by the DHCP
 40 # server, but it should not be run by default.
 41 nohook lookup-hostname
 42 ## interface eth0
 43   static ip_address=
 44   static routers=
 45   static domain_name_servers=
 46 ## interface eth0
 47   static ip_address=
 48   static routers=
 49   static domain_name_servers=

So I've removed that additional record from that file and it fixed that issue permanently.

Hope it will help someone...

Related Question