Ubuntu – Cannot Remove Secondary Dynamic IP

Ubuntuubuntu-20.04

I'm running Ubuntu Server 20.04. The system was setup initially with DHCP. I went into /etc/netplan and changed the file to use a static IP, as shown below.

network:
  ethernets:
    enp0s4:
      addresses: [10.0.1.9/24]
      dhcp4: false
      gateway4: 10.0.1.1
      nameservers:
        addresses: [8.8.8.8, 4.2.2.2]

  version: 2

1

The plan has been applied and rebooted multiple times. The new IP works and is valid, but the old DHCP address is still present. I disabled DHCPCD with no luck. When I enter ip a it shows both the static and dynamic IP. I'm trying to get rid of the secondary dynamic address, but everthing I've tried doesn't seem to work.

2: enp0s4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:a0:98:12:22:95 brd ff:ff:ff:ff:ff:ff
    inet 10.0.1.9/24 brd 10.0.1.255 scope global enp0s4
       valid_lft forever preferred_lft forever
    inet 10.0.1.242/24 brd 10.0.1.255 scope global secondary dynamic enp0s4
       valid_lft 81243sec preferred_lft 81243sec

2

Best Answer

I had the same problem and running the following help me determine my problem:

netplan --debug generate

I'd backed up my 50-cloud-init.yaml to _50-cloud-init.yaml which was still be read as a valid yaml file; doh! Renamed it to 50-cloud-init.yaml.bak, rebooted; problem solved.