Netplan apply doesn't remove non specified VLAN's
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
netplan |
New
|
Undecided
|
Unassigned |
Bug Description
[FACTS]
When Netplan applies a configuration with some VLANs defined but previously there are some other VLANs, the old VLANs aren't deleted.
You need to put down and up the linked interface to purge the non configured old VLANs.
A restart of systemd-networkd doesn't works.
[EXAMPLE]
1) Define some VLANs in "/etc/netplan/
network:
ethernets:
enp0s3:
addresses:
- 192.168.57.10/26
gateway4: 192.168.57.3
enp0s8:
addresses:
- 192.168.58.9/24
renderer: networkd
version: 2
vlans:
vlan20:
addresses:
- 192.168.0.9/22
id: 20
link: enp0s8
vlan70:
addresses:
- 192.168.48.9/24
id: 70
link: enp0s8
vlan71:
addresses:
- 192.168.16.9/22
id: 71
link: enp0s8
2) Execute "netplan apply" to take the changes affect. You can see configured with "ip a" command the new VLANs (Vlan20, vlan70 and vlan71).
3) Now, remove from "/etc/netplan/
network:
ethernets:
enp0s3:
addresses:
- 192.168.57.10/26
gateway4: 192.168.57.3
enp0s8:
addresses:
- 192.168.58.9/24
renderer: networkd
version: 2
vlans:
vlan20:
addresses:
- 192.168.0.9/22
id: 20
link: enp0s8
4) Execute "netplan apply" to take the changes affect.
5) Observe with "ip a" command that there are still the VLANs 70 and 71 defined
6) If you restart systemd network service with command "service systemd-networkd restart" they're are still defined.
[WORKAROUND]
You can execute the following commands to take effect the changes:
1) "ip link set dev enp0s8 down"
2) "netplan apply"
3) wait a few seconds (I don't know why but it's important!)
4) "ip link set dev enp0s8 up"
tags: | added: seg |
This is not related just to vlans, it's general configuration that doesn't get applied.
This is my netplan configuration, inside a LXD container:
network:
version: 2
ethernets:
eth0:
dhcp4: false
addresses:
- "10.4.10.110/16"
gateway4: 10.4.0.1
And this is the output of "ip a": netplan: /etc/netplan# ip -c a UP,LOWER_ UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 MULTICAST, UP,LOWER_ UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 3eff:fe9d: 5968/64 scope link
root@bio-
1: lo: <LOOPBACK,
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
31: eth0@if32: <BROADCAST,
link/ether 00:16:3e:9d:59:68 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.4.10.110/16 brd 10.4.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::216:
valid_lft forever preferred_lft forever
Now I want to change the ip from 10.4.10.110 to 10.4.10.220:
# sed -i "s/10.4. 10.110/ 10.4.10. 220/" 51-cloud-init.yaml
Now I run 'netplan apply'. That yields nothing (no error). But when I check my eth0 configuration I see that there are two IPs configured:
root@bio- netplan: /etc/netplan# ip -c a UP,LOWER_ UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 MULTICAST, UP,LOWER_ UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 3eff:fe9d: 5968/64 scope link netplan: /etc/netplan#
1: lo: <LOOPBACK,
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
31: eth0@if32: <BROADCAST,
link/ether 00:16:3e:9d:59:68 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.4.10.110/16 brd 10.4.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet 10.4.10.220/16 brd 10.4.255.255 scope global secondary eth0
valid_lft forever preferred_lft forever
inet6 fe80::216:
valid_lft forever preferred_lft forever
root@bio-
Doing the workaround by original poster 'fixes' the configuration:
root@bio- netplan: /etc/netplan# ip link set dev eth0 down netplan: /etc/netplan# ip link set dev eth0 up netplan: /etc/netplan# ip -c a UP,LOWER_ UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 MULTICAST, UP,LOWER_ UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 3eff:fe9d: 5968/64 scope link tentative netplan: /etc/netplan#
root@bio-
root@bio-
1: lo: <LOOPBACK,
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
31: eth0@if32: <BROADCAST,
link/ether 00:16:3e:9d:59:68 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.4.10.220/16 brd 10.4.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::216:
valid_lft forever preferred_lft forever
root@bio-
I did not have to wait few seconds between down/up though.