19

My nic crashes in high bandwidth scenarios unless TSO offloading is disabled.

It is a I217-LM (e1000e driver).

I used to do this in interfaces:

auto eno1
iface eno1 inet dhcp
post-up /sbin/ethtool -K eno1 tso off

How do I do this with netplan on Ubuntu 18.04?

Sigge
  • 201

3 Answers3

28

Currently not supported, of course. Now a habit for Linux devs to change something that was working well for no reason, and to provide an unfinished product.

https://netplan.io/faq/#use-pre-up%2C-post-up%2C-etc.-hook-scripts

Bibelo
  • 409
  • 2
    +1 for sympathy, -1 for not mentioning networkd-dispatcher, as in other answers. Although maybe that information wasn't there at the time the answer was written - the Archive doesn't go back that far. – mwfearnley Oct 23 '20 at 10:32
  • The information was not there 2 years for sure. See, I'm referencing the FAQ in my answer, which is also referenced by others with solutions (but 2 years after) – Bibelo Mar 02 '21 at 08:43
  • I think the reason, why they do not handle it very eagerly, is that netplan wants to enforce a lot of crap to us (software switches, ipv6, and a lot of wtf) and we would fix these with the post-up scripts. – peterh Apr 14 '24 at 22:29
10

It is already supported by netplan. I've followed the instructions available on: https://netplan.io/faq

I've created a small script /etc/networkd-dispatcher/routable.d/50-ifup-hooks

It runs on every reboot, after the network interfaces are up.

Example

My post-up hook is necessary to support source routing, since I have two NICs:

#!/bin/sh

/sbin/ip rule add from 62.48.171.211/29 tab 1 priority 500 /sbin/ip route add default via 62.48.171.209 dev eno2 tab 1 /sbin/ip route flush cache

estibordo
  • 1,439
  • 2
    Note that any created network-dispatcher script needs to be 1) executable & 2) Owned by root – Pierz Apr 16 '20 at 14:32
  • systemd-networkd.service & networkd-dispatcher.service should run on your machine when booting up. – Vencat Apr 04 '21 at 12:30
  • through trial and error I learned that the script must have permissions 755 or networkd-dispatcher will refuse to run the script quietly. – Michael Aug 06 '25 at 23:25
5

Not sure if that link changed since Bibelo posted, but as it states netplan does now support running scripts via hooks depending on your render.

If you are using the default render of networkd you'll need to add the networkd-dispatcher package. https://gitlab.com/craftyguy/networkd-dispatcher

Based on what you are trying to do I'd probably put the script in the carrier.d and/or routable.d directories This page had the best description of what the different state directories are for.

See this for an example of how I used networkd-dispatcher for a different purpose. https://fixingitpro.com/2018/12/28/displaying-ip-info-on-console-with-netplan/