I am trying to set the network interface priority on a device with Ubuntu Core 20 so that in case multiple network interfaces are available the device first connects via Ethernet , then via WiFi and after that via 4G. On Ubuntu I can use the ifmetric command to change the metric of an interface to accomplish this, but that is not available on Ubuntu-core.
I looked into nmcli, but could not find a command to set the metric for a particular interface. I was only able to set metrics for particular connections. I managed to write a script that selected all the connections available on a particular interface and set metric for them individually, but that setting gets reset after boot and I cannot find a way to trigger a script on boot in Ubuntu core.
I also tried adding the script to /etc/NetworkManager/dispatcher.d, but I got an error that it is a read-only directory.
How can I set network interface priorities on Ubuntu core so that they are persistent even after a reboot?