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

ipnetworking

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:10.0.0.22  Bcast:10.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          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
        address 10.0.0.22
        subnet  255.255.255.0
        gateway 10.0.0.1

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

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 10.0.0.22/8 brd 10.255.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 10.0.0.100/24 brd 10.0.0.255 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 169.254.78.64/16 brd 169.254.255.255 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=192.168.1.2/24
 44   static routers=192.168.1.254
 45   static domain_name_servers=192.168.1.254
 46 ## interface eth0
 47   static ip_address=192.168.0.3/24
 48   static routers=192.168.0.1
 49   static domain_name_servers=192.168.0.1

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

Hope it will help someone...

Related Question