Re: network manager post-up hook

2026-01-09 Thread Michael P. Soulier

On 2026-01-09 13:04, Greg Wooledge wrote:

I interpreted Michael's text to mean "I want all of my Linux
distributions, of which I use a wide variety, to be configured using
the same tools".

He's rejecting ifupdown solutions because he wants everything to look
like a Red Hat system.


No, I despise NM actually, but most of the systems I work on use it and 
I have little choice in the matter. So I need to know it. Kinda like 
systemd.


Actually I was impressed with iwd on Arch, although there was no desktop 
integration.


I've been using *nix for roughly 30 years. I'm perfectly happy using 
shell scripting and a bunch of symlinks for different profiles, and I 
did do that for some time on a Debian laptop a few years ago.


May I go on the record as saying that systemd is also hideously 
over-engineered, but then, I worked for years on a distro using 
daemontools and then runit to manage services, which I find simpler. No 
user-level services that way, but do we really need all this?


$ systemctl --user list-unit-files | wc -l
255

Ah well. Simpler times maybe.

Fact is, I love the simplicity and expressiveness of 
/etc/network/interfaces. On my servers it's a no-brainer, although 
integration with ipv6 seems lacking compared with *sigh* 
systemd-networkd if you're a gateway trying to provide an ipv6 block for 
your lan dynamically via prefix delegation ala 
https://wiki.debian.org/IPv6PrefixDelegation.


I set up virt-manager on a kick-ass server in my basement for dev work, 
and I love how simple it was to set up a bridged interface that way, 
although it oddly goes down at times and it's hard to capture why.


# Create bridge device to handle all public traffic
auto br0
iface br0 inet static
   # MAC tied to enp0s31f6
   hwaddress ether 30:d0:42:e8:b9:b8
   address 192.168.0.7
   netmask 255.255.255.0
   gateway 192.168.0.1

   bridge_ports enp0s31f6
   # don't need spanning tree
   bridge_stp off
   # if stp is off, set to 0. if stp is on, set to >= 2
   bridge_fd 0

very readable. Very simple to back-up and restore. Love it.

Anyway, I ramble.

Mike



Re: network manager post-up hook

2026-01-09 Thread Greg Wooledge
On Fri, Jan 09, 2026 at 17:51:37 +, Andy Smith wrote:
> On Thu, Jan 08, 2026 at 05:19:27PM -0500, Michael P. Soulier wrote:
> > 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 [...]

I interpreted Michael's text to mean "I want all of my Linux
distributions, of which I use a wide variety, to be configured using
the same tools".

He's rejecting ifupdown solutions because he wants everything to look
like a Red Hat system.



Re: network manager post-up hook

2026-01-09 Thread Andy Smith
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 [email protected]
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



Re: network manager post-up hook

2026-01-09 Thread Michael P. Soulier
On 09/01/26 Max Nikulin said:

> I am unsure if you really need a hook. Have you had a look into
> nm-settings(5)?
> 
> In addition I would evaluate if it can be done by setting driver parameters
> or by a udev rule.

Thanks, I'll have a look.

Mike



Re: network manager post-up hook

2026-01-09 Thread Greg Wooledge
On Thu, Jan 08, 2026 at 17:19:27 -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.

That's so absurdly untrue that I don't even know how to respond to it.

> And since it's a laptop it makes sense to have a dynamic
> configuration that I can control from once place, instead of part of my config
> in NM and part in interfaces, in a file format that only Debian-based distros
> care about. Since on any given day I could be on a variety of systems.

A personal decision, then.  OK, it looks like the dispatcher.d/ directory
is what you want.  Let us know if you have any more problems.



Re: network manager post-up hook

2026-01-08 Thread Michael P. Soulier
On 08/01/26 Marco Moock said:

> Is that a problem with this driver, so does autonegotiation work in
> other operating systems?

Given that it's a Dell docking station provided by work, and that it comes with
windows software that Dell expects you to be running, I'm happy that it works at
all, and don't mind working around minor problems.

Still, this conversation reminds me of just about every conversation I've had on
a forum like this one.

I ask, "I would like to do foo"

response, without fully understanding my situation: "No you don't"

Too funny. 

So, I asked Claude.AI and it agrees with an earlier response.

"Yes! NetworkManager supports running scripts when interfaces come up (or down)
through dispatcher scripts.  How it works NetworkManager calls scripts in
/etc/NetworkManager/dispatcher.d/ when network events occur."

It could be wrong of course, so I will go off and confirm.

And, I don't mind replacing the cable to the switch, but given that it's Dell, I
suspect the problem lies there. Dell is the only company I've ever found to
break something as simple as the interface to a mouse. Seriously, the mouse
worked on windows and not linux. But that was like, 20 years ago. 

But I digress.

Cheers,
Mike



Re: network manager post-up hook

2026-01-08 Thread Michael P. Soulier
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. And since it's a laptop it makes sense to have a dynamic
configuration that I can control from once place, instead of part of my config
in NM and part in interfaces, in a file format that only Debian-based distros
care about. Since on any given day I could be on a variety of systems.

Hope that helps.

Mike


signature.asc
Description: PGP signature


Re: network manager post-up hook

2026-01-08 Thread Michel Verdier
On 2026-01-08, Marco Moock wrote:

> Is that a problem with this driver, so does autonegotiation work in
> other operating systems?

No other OS for a long time :)



Re: network manager post-up hook

2026-01-08 Thread Max Nikulin

On 08/01/2026 7:44 pm, Michael P. Soulier wrote:


Is there a way to run a script when an interface comes up when using
NetworkManager? The post-up hook in interfaces is great, but I'm trying to run
an ethtool command when I plug into my docking station and suddenly it's
ethernet interface is available.


I am unsure if you really need a hook. Have you had a look into 
nm-settings(5)?


In addition I would evaluate if it can be done by setting driver 
parameters or by a udev rule.




Re: network manager post-up hook

2026-01-08 Thread Marco Moock
On 08.01.2026 17:30 Uhr Michel Verdier wrote:

> I have the same problem with a RTL8411b. I use the right driver and I
> don't find another driver to set this device up. It start with
> 10Mbps. I solved this with

Is that a problem with this driver, so does autonegotiation work in
other operating systems?

-- 
kind regards
Marco

Send spam to [email protected]



Re: network manager post-up hook

2026-01-08 Thread Stefan Monnier
> another ethernet port on the machine.  You may need to add an ethernet
> card to replace the port.

When was the last time you saw a machine with several ethernet ports
that can "plug into my docking station"?
Not all machines live in big racks 🙂

> Forcing the port to 1 Gbps or 10 Gbps using software is one of the
> last things I would try.  The problem lies elsewhere.

But it's a very cheap solution.  When dealing with hardware problems,
working around them in software can be the best solution.


Stefan



Re: network manager post-up hook

2026-01-08 Thread Jeffrey Walton
On Thu, Jan 8, 2026 at 9:10 AM Michael P. Soulier
 wrote:
>
> On 08/01/26 Marco Moock said:
>
> > What is the reason in your case?
> >
> > Maybe NM can handle that with a setting.
>
> The interface is screwing up autonegotiation and falling back to 10mbits. 
> It's a
> Gigabit interface. So I force it to Gigabit using ethtool.

This is the problem you should be troubleshooting.

Based on my experience with managing servers, the first thing to do is
use the latest software.  That includes the latest UEFI and drivers.

Second step is, replace the ethernet cable.  Faulty cables are more
common than expected.  It is one of the easiest troubleshooting steps.
Thirs, try moving the cable to a different ethernet port on the
switch/hub/router. Fourth, disable the problem ethernet port and use
another ethernet port on the machine.  You may need to add an ethernet
card to replace the port.

Forcing the port to 1 Gbps or 10 Gbps using software is one of the
last things I would try.  The problem lies elsewhere.

Jeff



Re: network manager post-up hook

2026-01-08 Thread Greg Wooledge
On Thu, Jan 08, 2026 at 09:11:08 -0500, Michael P. Soulier wrote:
> On 08/01/26 Michel Verdier said:
> 
> > You can put any command in post-up or if you prefer you can add a script
> > in /etc/network/if-up.d such this one:
> > 
> > $ cat /etc/network/if-up.d/postfix 
> > #! /bin/sh
> > # update postfix copy of resolv.conf (picked up automatically); only 
> > default instance is handled
> > [ lo != "$IFACE" ] && cp -pLu /etc/resolv.conf 
> > /var/spool/postfix/etc/resolv.conf 2>/dev/null || :
> 
> I didn't think that would run on a NetworkManager-managed interface.
> NetworkManager.conf says ifupdown support is disabled.

I did a web search for "network manager post up hook" and the first
result was


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?



Re: network manager post-up hook

2026-01-08 Thread Marco Moock
On 08.01.2026 15:20 Michael P. Soulier wrote:

> The interface is screwing up autonegotiation and falling back to
> 10mbits. It's a Gigabit interface. So I force it to Gigabit using
> ethtool.

You should then check the logs and also check the cabling etc. to
verify it is not a hardware issue.

The driver of one of the sides might also be faulty, which should be
excluded.



Re: network manager post-up hook

2026-01-08 Thread Michael P. Soulier
On 08/01/26 Michel Verdier said:

> You can put any command in post-up or if you prefer you can add a script
> in /etc/network/if-up.d such this one:
> 
> $ cat /etc/network/if-up.d/postfix 
> #! /bin/sh
> # update postfix copy of resolv.conf (picked up automatically); only default 
> instance is handled
> [ lo != "$IFACE" ] && cp -pLu /etc/resolv.conf 
> /var/spool/postfix/etc/resolv.conf 2>/dev/null || :

I didn't think that would run on a NetworkManager-managed interface.
NetworkManager.conf says ifupdown support is disabled.

Mike
> 


signature.asc
Description: PGP signature


Re: network manager post-up hook

2026-01-08 Thread Michael P. Soulier
On 08/01/26 Marco Moock said:

> What is the reason in your case?
> 
> Maybe NM can handle that with a setting.

The interface is screwing up autonegotiation and falling back to 10mbits. It's a
Gigabit interface. So I force it to Gigabit using ethtool.

Mike


signature.asc
Description: PGP signature


Re: network manager post-up hook

2026-01-08 Thread Marco Moock
On 08.01.2026 13:50 Michael P. Soulier wrote:

> Is there a way to run a script when an interface comes up when using
> NetworkManager? The post-up hook in interfaces is great, but I'm
> trying to run an ethtool command when I plug into my docking station
> and suddenly it's ethernet interface is available. 

What is the reason in your case?

Maybe NM can handle that with a setting.



Re: network manager post-up hook

2026-01-08 Thread didier gaumet

Le 08/01/2026 à 13:44, Michael P. Soulier a écrit :

Hello,

Is there a way to run a script when an interface comes up when using
NetworkManager? The post-up hook in interfaces is great, but I'm trying to run
an ethtool command when I plug into my docking station and suddenly it's
ethernet interface is available.

Mike


Hello,

I don't use it so I don't now if it can be what you need, but perhaps 
take a look at NetworkManager-dispatcher:

https://manpages.debian.org/trixie/network-manager/NetworkManager-dispatcher.8.en.html



Re: network manager post-up hook

2026-01-08 Thread Michel Verdier
On 2026-01-08, Michael P. Soulier wrote:

> Is there a way to run a script when an interface comes up when using
> NetworkManager? The post-up hook in interfaces is great, but I'm trying to run
> an ethtool command when I plug into my docking station and suddenly it's
> ethernet interface is available. 

You can put any command in post-up or if you prefer you can add a script
in /etc/network/if-up.d such this one:

$ cat /etc/network/if-up.d/postfix 
#! /bin/sh
# update postfix copy of resolv.conf (picked up automatically); only default 
instance is handled
[ lo != "$IFACE" ] && cp -pLu /etc/resolv.conf 
/var/spool/postfix/etc/resolv.conf 2>/dev/null || :