Ubuntu 22.04 – Setting Ethtool Network Interface Parameters at Startup

ifconfigintellinux-networkingUbuntu

Following the question at:
https://askubuntu.com/questions/1406445/ubuntu-22-04-server-intel-x550-advertised-speed-not-correct
I need to run a command at startup so that the necessary changes are permanent. From the Intel drivers documentation (https://downloadmirror.intel.com/727507/readme.txt),
the command is:

pre-up ethtool -s <ethX> advertise 0x1800000001028 || true

I tried to write the command in various files, without success.

Where should I write it ?

Edit 1:
Following Anton Danilov's answer, I did not find how to set up a solution with sytemd.link, but I found a different way by creating a service in

/etc/systemd/system

as explained here:
https://bbs.archlinux.org/viewtopic.php?id=262075

It works, but is it the optimal way for Ubuntu 22.04 (the link above is a solution for archlinux and is from 2018) ?
If no, could someone please provide a complete working solution for Ubuntu Server 22.04 ?

Best Answer

Since you are using Ubuntu Server 22.04 I am going to guess you are using netplan with systemd-networkd as the "renderer".

You could try putting a script in /etc/networkd-dispatcher/configuring.d. E.g.

mkdir -p /etc/networkd-dispatcher/configuring.d/
install -m 0755 /dev/null /etc/networkd-dispatcher/configuring.d/x550
cat <<EOF > /etc/networkd-dispatcher/configuring.d/x550
#!/usr/bin/env bash

ethtool -s <ethX> advertise 0x1800000001028 || true
EOF

I chose configuring.d based on the Netplan hook table mapping. Another state might work better.

other links

Related Topic