Second IP via DHCP. Why?

5,457

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

...then reboot.

sudo shutdown -r

This kills the secondary IP.

Share:
5,457

Related videos on Youtube

Conti
Author by

Conti

Updated on September 18, 2022

Comments

  • Conti
    Conti over 1 year

    I have a secondary IP on my ens160 interface and I don't know why :) System is Ubuntu 17.10. Any hints where to dig here?

    1: lo: <LOOPBACK,UP,LOWER_UP> 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: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether 00:0c:29:07:bd:e3 brd ff:ff:ff:ff:ff:ff
        inet 192.168.0.5/24 brd 192.168.0.255 scope global ens160
           valid_lft forever preferred_lft forever
        inet 192.168.0.165/24 brd 192.168.0.255 scope global secondary ens160
           valid_lft forever preferred_lft forever
        inet6 fe80::20c:29ff:fe07:bde3/64 scope link
           valid_lft forever preferred_lft forever
    

    192.168.0.5 is my static ip, configured via netplan:

    network:
      version: 2
      renderer: networkd
      ethernets:
        ens160:
          dhcp4: no
          dhcp6: no
          addresses: [192.168.0.5/24]
          gateway4: 192.168.0.254
          nameservers:
            addresses: [8.8.8.8,1.1.1.1]
    
    • Admin
      Admin about 6 years
      I think the secondary address is configured statically somewhere. A DHCP assigned address seem to contain the keyword dynamic (ie. inet 192.168.0.165/24 brd 192.168.0.255 scope global dynamic secondary ens160). Your output of the command ip addr doesn't.
    • Admin
      Admin about 6 years
      Check out these locations for configurations files that might cause your problem: /run/netplan/*.yaml, /etc/netplan/*.yaml and /lib/netplan/*.yaml.
    • Conti
      Conti about 6 years
      I will check these files. But its clearly DHCP, because I see the lease in my DHCP server. And, maybe thats the trick, I added a denyinterfaces ens160 to the /etc/dhcpcd.conf file. But why is this file triggered and where?
    • Admin
      Admin about 6 years
      Can you see in the DHCP log that 192.168.0.165 is leased to the MAC address 00:0c:29:07:bd:e3?
    • Conti
      Conti about 6 years
      May 02 10:39:15 pihole systemd[1]: Starting LSB: IPv4 DHCP client with IPv4LL support... May 02 10:39:16 pihole dhcpcd[1310]: ens160: soliciting a DHCP lease May 02 10:39:17 pihole dhcpcd[1310]: ens160: offered 192.168.0.165 from 192.168.0.254 May 02 10:39:17 pihole dhcpcd[1310]: ens160: probing address 192.168.0.165/24 May 02 10:39:23 pihole dhcpcd[1310]: ens160: leased 192.168.0.165 for 3600 seconds May 02 10:39:23 pihole dhcpcd[1310]: ens160: adding route to 192.168.0.0/24