View previous topic :: View next topic |
Author |
Message |
grant123 Veteran

Joined: 23 Mar 2005 Posts: 1106
|
Posted: Mon May 05, 2025 6:12 pm Post subject: Bring USB net0 back up after power outage |
|
|
net0 is plugged into a powered USB hub and after the power goes out I have to manually restart the interface to reconnect. Is there a way to handle this automatically? |
|
Back to top |
|
 |
szatox Advocate

Joined: 27 Aug 2013 Posts: 3637
|
Posted: Mon May 05, 2025 7:23 pm Post subject: |
|
|
There are ways to do that, some more hackinsh than others. How is your network configured, and in what state is it after power returns? _________________ Make Computing Fun Again |
|
Back to top |
|
 |
grant123 Veteran

Joined: 23 Mar 2005 Posts: 1106
|
Posted: Mon May 05, 2025 7:26 pm Post subject: |
|
|
Ok nevermind in that case. I was hoping there was something slick for this like a directive in net.conf or a udev rule. |
|
Back to top |
|
 |
szatox Advocate

Joined: 27 Aug 2013 Posts: 3637
|
Posted: Mon May 05, 2025 10:53 pm Post subject: |
|
|
Nobody said there isn't. _________________ Make Computing Fun Again |
|
Back to top |
|
 |
grant123 Veteran

Joined: 23 Mar 2005 Posts: 1106
|
Posted: Wed May 07, 2025 4:24 pm Post subject: |
|
|
When power returns the net0 USB interface is down but /etc/init.d/net.net0 restart brings everything back online. |
|
Back to top |
|
 |
szatox Advocate

Joined: 27 Aug 2013 Posts: 3637
|
Posted: Wed May 07, 2025 5:10 pm Post subject: |
|
|
Ok, so you're using netifrc.
It's been a while since I played with this, and honestly don't remember how it worked exactly, but there is rc_hotplug variable in /etc/rc.conf. Give it a shot. _________________ Make Computing Fun Again |
|
Back to top |
|
 |
grant123 Veteran

Joined: 23 Mar 2005 Posts: 1106
|
Posted: Thu May 08, 2025 5:52 pm Post subject: |
|
|
hotplug doesn't seem to work in this case and it must be because if the USB hub loses and regains power, net0 disappears from ifconfig but '/etc/init.d/net.net0 status' still reports 'started'.
'/etc/init.d/net.net0 restart' makes it work again. Maybe hotplug is designed to work only in the case of 'stopped' and wouldn't work in my scenario? |
|
Back to top |
|
 |
szatox Advocate

Joined: 27 Aug 2013 Posts: 3637
|
Posted: Thu May 08, 2025 6:46 pm Post subject: |
|
|
I think your net.net0 should not be explicitly enabled for hotplug to work. AFAIR it is an alternative reason to activate a device, alongside with "needed" and "manual", and if it's explicitly enabled, it won't be able to deactivate.
Probably. It is still possible that it only responds to NO-CARRIER flag or LOWER_UP/LOWER_DOWN or whatever indicates wire's status.
As an alternative: depending on the complexity of your setup, you might be able to replace it with dhclient or dhcpcd. At least one of them has morphed into a simple connectivity manager. There is NetworkManager too, it can handle devices appearing and going away.
Netifrc is still the best when it comes to the more tricky setups though. _________________ Make Computing Fun Again |
|
Back to top |
|
 |
grant123 Veteran

Joined: 23 Mar 2005 Posts: 1106
|
Posted: Fri May 09, 2025 6:08 pm Post subject: |
|
|
I tried removing net.net0 from the default runlevel and enabling it in rc_hotplug but unplugging/replugging the device causes it to disappear from ifconfig and /etc/init.d/net.net0 still reports "started". Am I doing this right? |
|
Back to top |
|
 |
NeddySeagoon Administrator


Joined: 05 Jul 2003 Posts: 55227 Location: 56N 3W
|
Posted: Fri May 09, 2025 6:32 pm Post subject: |
|
|
grant123,
Is plugdev any use?
It brings the interface up/down depending on the state of the wire. I don't know how well it plays with USB though.
Really hacky is to restart eth.net0 in local. I assume the system reboots and not hibernates for a power outage? _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
 |
grant123 Veteran

Joined: 23 Mar 2005 Posts: 1106
|
Posted: Fri May 09, 2025 7:18 pm Post subject: |
|
|
I can't find much about plugdev except that there's a group with that name. Can you point me in the right direction? |
|
Back to top |
|
 |
NeddySeagoon Administrator


Joined: 05 Jul 2003 Posts: 55227 Location: 56N 3W
|
Posted: Fri May 09, 2025 7:36 pm Post subject: |
|
|
grant123,
I think I had another senior moment. I was thinking of one of the following ... probably ifplugd as I get the plug bit right :)
Code: | * sys-apps/ifplugd
Available versions: 0.28-r11 0.28-r12 {doc selinux}
Homepage: http://0pointer.de/lennart/projects/ifplugd/
Description: Brings up/down ethernet ports automatically with cable detection
* sys-apps/netplug
Available versions: 1.2.9.2-r3 {debug doc}
Homepage: https://www.red-bean.com/~bos/
Description: Brings up/down ethernet ports automatically with cable detection
|
_________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
 |
|