Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Bring USB net0 back up after power outage
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
grant123
Veteran
Veteran


Joined: 23 Mar 2005
Posts: 1106

PostPosted: Mon May 05, 2025 6:12 pm    Post subject: Bring USB net0 back up after power outage Reply with quote

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
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3637

PostPosted: Mon May 05, 2025 7:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
grant123
Veteran
Veteran


Joined: 23 Mar 2005
Posts: 1106

PostPosted: Mon May 05, 2025 7:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3637

PostPosted: Mon May 05, 2025 10:53 pm    Post subject: Reply with quote

Nobody said there isn't.
_________________
Make Computing Fun Again
Back to top
View user's profile Send private message
grant123
Veteran
Veteran


Joined: 23 Mar 2005
Posts: 1106

PostPosted: Wed May 07, 2025 4:24 pm    Post subject: Reply with quote

When power returns the net0 USB interface is down but /etc/init.d/net.net0 restart brings everything back online.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3637

PostPosted: Wed May 07, 2025 5:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
grant123
Veteran
Veteran


Joined: 23 Mar 2005
Posts: 1106

PostPosted: Thu May 08, 2025 5:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3637

PostPosted: Thu May 08, 2025 6:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
grant123
Veteran
Veteran


Joined: 23 Mar 2005
Posts: 1106

PostPosted: Fri May 09, 2025 6:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 55227
Location: 56N 3W

PostPosted: Fri May 09, 2025 6:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
grant123
Veteran
Veteran


Joined: 23 Mar 2005
Posts: 1106

PostPosted: Fri May 09, 2025 7:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 55227
Location: 56N 3W

PostPosted: Fri May 09, 2025 7:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum