How to remove the secondary ip dynamic through netplan itself? or even by command permanently? Even after reboot

For a clean installation for Ubuntu Server 24.04 through VirtualBox and to define a static ip was created and edited the /etc/netplan/01-netcfg.yaml file as follows

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: no
      addresses: [192.168.1.41/24]
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses: [<DNS1>, <DNS2>]

When the following commands are executed

  • sudo netplan generate
  • sudo netplan apply

All works fine and when the ip a command is executed appears something as follows:

inet 192.168.1.41/24 ... scope global enp0sN
inet 192.168.1.34/24 ... scope global secondary dynamic enp0s3

The first ip is the desired static ip already configured but observe that appears a secondary ip and even being dynamic. It is not desired to avoid collisions of ips within the same LAN

Question I

  • How to remove the secondary ip dynamic through netplan itself? Is possible?

By command the following works:

  • sudo ip addr del 192.168.1.34/24 dev enp0s3

It confirmed again with the ip a command but if the server is restarted appears again the same secondary dynamic ip

Question II

  • How to make the ip addr del ... command settings permanently? Even after reboot

Why did netplan create it. It is no in your yaml file?
You may need to use Vbox settings to remove it.
A messy fix would be to put your sudo ip command in rc.local

1 Like

I have the same issue with Ubuntu24.04 LTS. Although it works to set up static IP with netplan, I cannot stop the machine getting DHCP4 and DHCP6 no matter how it setup in netplan. No matter I set dhcp to no/ false, purge the dhcpcd, delete the DHCP manually and so. Hope anyone can help…

1 Like

Dunno man - I always kinda liked netplan (vs other options)…

Have you tried changing “renderer” from “networkd” to “NetworkManager” (I still kinda hate NetworkManager - netplan and yaml seems more “elegant”…

1 Like