How to execute post-up scripts with netplan

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?


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


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

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/