netplan apply does not remove ips

Bug #1781459 reported by Curtis OReilly
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Netplan
Confirmed
Undecided
Unassigned

Bug Description

This is inside an LXC Ubuntu 18.04 container (running under an Ubuntu 18.04 host), if that makes a difference. I can add new IP aliases just fine by adding them in the /etc/netplan/50-cloud-init.yaml file like so:

network:
        version: 2
        ethernets:
                eth0:
                        dhcp4: false
                        addresses: [192.168.0.3/24, 192.168.0.4/24]
                        gateway4: 192.168.0.1
                        nameservers:
                                addresses: [8.8.8.8,8.8.4.4]

...and then run "netplan apply" to activate these static IPs. (Note: My real yaml file is using public IPs, I switched them to private for this example, but everything else is the same.) The problem comes when I try to deactivate an IP. So, let's say I drop the second IP (.4):

network:
        version: 2
        ethernets:
                eth0:
                        dhcp4: false
                        addresses: [192.168.0.3/24]
                        gateway4: 192.168.0.1
                        nameservers:
                                addresses: [8.8.8.8,8.8.4.4]

Even after running "netplan apply" again, the IP is still pingable and I can even ssh to the box using the dropped IP. "ip addr show" also reveals that the IP is still there.

I've even tried "ifdown -a;ifup -a" and "service networking restart", neither of which produce any errors, but the IP does not deactivate. Restarting the entire LXC container works, but that's obviously less desirable.

Update- I've found that this works:

ip addr del 192.168.0.4/24 dev eth0

The script that is generating the yaml file does not know which IPs have been dropped because it's just grabbing the current IP list from a database, so the above method of dropping IPs isn't possible.

description: updated
description: updated
description: updated
description: updated
description: updated
Revision history for this message
Ryan Harper (raharper) wrote :

I can confirm this behavior. Netplan apply does the following:

Generate a new config for the backend and restart the backend.
The systemd-networkd backend does not clear existing configuration from the devices which results in previous configurations being present.

One currently needs to manually clear the interfaces, something like:

ip addr flush dev eth0

Will clear the config and then a netplan apply will bring that up.

Need some comments from netplan on expected behavior and whether the 'apply' verb should also include a clear and what the scope of the clear should be (ie, only for interfaces which will be configured with the current configuration that was generated).

Changed in netplan:
status: New → Confirmed
Revision history for this message
Daniel Axtens (daxtens) wrote :

`netplan apply` also won't change bridge/bond parameters: LP: #1746419, we should document that too.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.