Ubuntu – Ubuntu 18.04 minimal server has two IP addresses!

dhcpethernetnetworkingserver

I'm seeing two different IP addresses on my Odroid XU4. I only noticed after I set up a Unifi controller on the box, but then tried to ssh into both of the addresses with success. I only want 192.168.2.3, and no IPv6.

mike@odroid:~$ ip addr show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:1e:06:30:1e:f5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.3/24 brd 192.168.2.255 scope global dynamic noprefixroute eth0
       valid_lft 3069558340sec preferred_lft 3069558340sec
    inet 192.168.2.9/24 brd 192.168.2.255 scope global secondary eth0
       valid_lft forever preferred_lft forever

mike@odroid:~$ ifconfig
eth0: flags=4163  mtu 1500
        inet 192.168.2.3  netmask 255.255.255.0  broadcast 192.168.2.255
        ether 00:1e:06:30:1e:f5  txqueuelen 1000  (Ethernet)
        RX packets 12821  bytes 2393432 (2.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13336  bytes 9323830 (9.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 10593  bytes 4855090 (4.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10593  bytes 4855090 (4.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

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

mike@odroid:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

mike@odroid:~$ cat /etc/netplan/*.yaml
cat: '/etc/netplan/*.yaml': No such file or directory

Best Answer

  • I have struggled with this exact same problem and every search comes up with several others experiencing the same issue with no resolution.

    FINALLY, here is what solved it for me:

    ip addr flush dev <your_adapter_id>
    

    for me it was

    ip addr flush dev enp0s4
    

    This kills the secondary IP.

  • Related Question