netplan does not support ifmetric

Bug #1771834 reported by Stanislav Makar
34
This bug affects 5 people
Affects Status Importance Assigned to Milestone
netplan
Confirmed
Undecided
Unassigned

Bug Description

Is very useful feature in cases when you have two interfaces receiving default routes via dhcp

It was supported by ifupdown once ifmetric package was installed

http://manpages.ubuntu.com/manpages/bionic/man8/ifmetric.8.html

root@test:~# dpkg -L ifmetric
/.
/etc
/etc/network
/etc/network/if-up.d
/etc/network/if-up.d/ifmetric
/usr
/usr/sbin
/usr/sbin/ifmetric
/usr/share
/usr/share/doc
/usr/share/doc/ifmetric
/usr/share/doc/ifmetric/README.gz
/usr/share/doc/ifmetric/changelog.Debian.gz
/usr/share/doc/ifmetric/copyright
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/ifmetric.8.gz
root@test:~# cat /etc/network/if-up.d/ifmetric
#!/bin/sh
if [ -x /usr/sbin/ifmetric -a "${IF_METRIC}" ]; then
    /usr/sbin/ifmetric "${IFACE}" "${IF_METRIC}"
fi

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

Yes, I believe we want to allow users to specify the RouteMetric value.
Netplan auto generates this value, but keeps it the same for any interface, except wifi which is set higher.

I believe if we allowed setting something like:

network:
    version: 2
        ethernets:
            eth0:
               dhcp4: y
               metric: 101
            eth1:
               dhcp4: y
               metric: 201

Which would render a networkd config like:

[Match]
Name=eth0

[Network]
DHCP=ipv4

[DHCP]
UseMTU=true
RouteMetric=101

[Match]
Name=eth1

[Network]
DHCP=ipv4

[DHCP]
UseMTU=true
RouteMetric=201

Changed in netplan:
status: New → Confirmed
Revision history for this message
Stanislav Makar (smakar) wrote :

yes, it is how it worked before on ifupdown

Revision history for this message
Daniel Axtens (daxtens) wrote :

I have opened https://github.com/CanonicalLtd/netplan/pull/39 to support a 'metric' key as described by Ryan.

Changed in netplan:
status: Confirmed → In Progress
assignee: nobody → Daniel Axtens (daxtens)
Daniel Axtens (daxtens)
Changed in netplan:
assignee: Daniel Axtens (daxtens) → nobody
status: In Progress → Confirmed
Revision history for this message
Edo (etirta-a) wrote :

I scratch my head over and over again. This netplan is half-baked solution, lots of missing feature from ifupdown. The bugs has been 2 years, yet not fixed.

I saw the later version can handle 'route-metric', but that only for DHCP injected route. What we need is interface metric for subnet route. When a host has multiple NIC on the same subnet, very much likely we want to be able to control the priority within this NICs.

Revision history for this message
Volodymyr Litovka (doka.ua) wrote :

According to https://netplan.io/examples, netplan supports route-metric keyword and I use it:

"network":
  "ethernets":
    "lan":
      dhcp4: true
      dhcp4-overrides:
              route-metric: 10
      "match":
        "name": "e*"
  "renderer": "networkd"
  "version": 2

This works with netplan.io v0.98-0ubuntu1. Don't know, whether this or newer version is available from standard repositories, but you can add 'proposed'repo and will be able to get it.

tags: added: id-5f490c94eee2ba35d0a22a2e
Revision history for this message
Wladimir Mutel (mwg) wrote :

you may very easily migrate away off netplan and forget it forever.
that's for default "renderer" value which is "networkd".
for NetworkManager you usually don't need netplan at all, initially.
remove it, and NetworkManager would not ever notice that nor complain about something missing.
that should go for end-user Ubuntu versions like Lubuntu, Xubuntu and GNOME3 Ubuntu itself.
in networkd case, just copy netplan-generated files from /run/systemd/network/ into /etc/systemd/network/ , do a "systemctl enable systemd-networkd" , remove everything resembling netplan from your dpkg paackage list, and restart your system. keep your local console connected to the system for the first 1 or 2 system restarts, as you might need to adjust your .network/.netdev config file names priority.
after next 2..3 successful reboots, no thought about installing netplan should visit your head ever.

Revision history for this message
Wladimir Mutel (mwg) wrote :

ideally, you should be able to run any gui/desktop Ubuntu variation with only systemd-networkd, without any NetworkManager, connman or, God forbid, netplan.
I use excellent ArchLnux wiki pages for my inspiration, like https://wiki.archlinux.org/index.php/Systemd-networkd
As well as its documentation on freedesktop.org wiki

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.