[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: network manager post-up hook



Hi Michael,

On Thu, Jan 08, 2026 at 05:19:27PM -0500, Michael P. Soulier wrote:
> On 08/01/26 Greg Wooledge said:
> > However, I do have to wonder: why is the OP using network manager
> > for this interface, if they already know how to solve the problem
> > using ifupdown?  Why not simply configure this interface in
> > /etc/network/interfaces and be done with it?
> 
> Perhaps because NetworkManager is used on multiple distributions and is now the
> de facto standard.

NetworkManager is the default when you have a desktop environment
installed, but it still doesn't have to be used in isolation. It is
meant to be able to work together with other stacks like ifupdown or
systemd-networkd. N-M knows enough about /etc/network/interfaces, for
example, to ignore (not manage) interfaces that are configured there.

It is a common setup to use N-M for wifi connections, especially to
access points that are not known in advance, but to use /e/n/i for
static, known networks like your docking station's Ethernet.

That said it's also completely reasonable to use N-M for everything if
you have it installed at all.

I think the answer you got from Claude should work. Also I agree with
you that the weird autoneg issue you have with the docking station is
probably some driver issue and not worth cable swapping, messing with
your switch and so on. Your use of ethtool to bodge it is probably the
best you can do.

> on any given day I could be on a variety of systems.

The thing is, when you attach to your docking station that is kind of
"one place" no matter where you are at the time. I'm guessing it makes
an Ethernet device appear which will get assigned an arbitrary but
predictable name based on the PCIe slot number that the docking port
uses, so that'll be the same name and MAC address every time.

That might end up being useful in your N-M dispatch hook as you'll know
to only do it for that specific interface name, e.g.:

#!/bin/sh

INTERFACE="$1"
STATUS="$2"

if [ "$INTERFACE" = "en…" ] && [ "$STATUS" = "up" ]; then
    …
fi

I think a udev rule could work instead, something like:

# /etc/udev/rules.d/99-interface-trigger.rules
ACTION=="add", SUBSYSTEM=="net", KERNEL=="en…", TAG+="systemd", ENV{SYSTEMD_WANTS}="bodge-autoneg@$name.service"

(replacing en… with whatever your docking station's Ethernet device ends
up as.)

This would trigger the templated systemd service bodge-autoneg@.service
for the specific interface device name.

I haven't tested whether this will correctly trigger when the link goes
down and comes back again (device is still there, but set down) rather
than being unplugged and pligged again (actual device goes away and
comes back). I'm also not sure here if the KERNEL name is actually the
name before or after udev renames it. If before then it should be
KERNEL="eth*".

Either N-M dispatch or ifupdown hook seem easier.

Thanks,
Andy

-- 
https://bitfolk.com/ -- No-nonsense VPS hosting


Reply to: