/srv/irclogs.ubuntu.com/2020/11/26/#netplan.txt

=== akp55_ is now known as akp55__
slyonLucas8037: Is this for `netplan apply`? Does it work after a reboot?07:15
Jay50Hi Netplan :)  I'm trying to add a second IP address to an interface09:52
Jay50When I use ip addr add <ip> dev eth0 , it adds it in the expected order (second)... when I use a netplan drop-in, then netplan apply, it adds it first... (I think this is because the primary IP has a limited lft, while my second IP has an lft of forever). Anyway to explicitly set priority for the addresses?09:54
slyonJay50: can you show your YAML config? usually the first IP of the list is set as the primary. Maybe it changes the order if you define lifetime for one of them but not the other?10:01
slyonin this case a workaround might be to add some additional parameters to the other one as well (e.g. a random label)10:02
Jay50# cat /etc/netplan/50-cloud-init.yaml# This file is generated from information provided by the datasource...network:    ethernets:        eth0:            dhcp4: true            dhcp6: false            match:                macaddress: <....>            set-name: eth0    version: 210:06
Jay50```# cat /etc/netplan/80-public.yaml network:  version: 2  ethernets:    eth0:      addresses:      - <...>/32```10:07
Jay50Apologies apparently I'm terrible at formatting things10:07
slyonthats fine10:07
slyonbut here only one IP address is defined in 80-public.yaml, right?10:08
slyon80-public.yaml (eth0) will overwrite 50-cloud-init.yaml (eth0)10:08
slyonso if you want to have a DHCP4 address and your manual address, you'd need to add `dhcp4: true` to 80-public.yaml as well10:09
Jay50I thought it might too, but in fact it does not, both the DHCP and static IP are present on the interface after `netplan apply`10:09
Jay50Only the order is unexpected10:10
Jay50On a machine where the address in 50-cloud-init has a lifetime of forever, applying 80-public correctly appends the address to the interface10:11
slyonis this after a clean reboot or some intermediate state, where the DHCP address might have been there before defining the manual IP?10:11
Jay50When the address in 50-cloud-init has a limited lifetime, the address in 80-public supersedes the address in 50-cloud-init10:11
slyonand you define that limited lifetime on the DHCP server?10:12
Jay50Unfortunately not, my cloud service provider defines that10:13
Jay50I'm currently working around it by simply using `ip addr add ...` since that maintains the correct order10:13
slyonOkay.. so the IP from DHCP is supposed to be the primary and your 80-public IP is supposed to be the secondary, correct?10:14
Jay50Yes exactly10:15
slyonAlright, I think I know what's going on then:10:15
slyonUsually the first IP address assigned is set to be the primary.10:15
slyonSo if netplan knows about a manual address, it will assign it right away, while the DHCP request/response takes some time and is thus assigned afterwards, becoming the secondary.10:16
Jay50Makes sense10:16
slyonIf you do it manually, you do it after DHCP is finished, thus having the expected order.10:17
slyonUnfortunately, I think there is now way to fix this in netplan config. But you could add your "ip addr add ..." command to the "routable.d" hook in networkd-dispatcher, to make it run after the interface is UP (i.e. configured via DHCP): https://netplan.io/faq/#use-pre-up%2C-post-up%2C-etc.-hook-scripts10:19
Jay50Alright, thats sounds like my best option10:20
Jay50Thanks a million for your help10:20
slyonyw10:20
Jay50Have a great day10:20
slyonthank, same to you!10:20
=== akp55__ is now known as akp55

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!