Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
network needs to be restarted manually after suspend
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
HyperQuantum
Tux's lil' helper
Tux's lil' helper


Joined: 27 Sep 2005
Posts: 88

PostPosted: Sat Dec 11, 2010 3:38 pm    Post subject: network needs to be restarted manually after suspend Reply with quote

When my laptop goes into suspend (to RAM), and it remains in that state for a couple of hours, then I don't have an internet connection anymore when I reactivate it. I have to restart the network connection manually before I can use my webbrowser again:
Code:
# /etc/init.d/net.wlan0 restart

I suspect that the connection stops working because the DHCP lease expires (or something), but why isn't it automatically renewed when the laptop comes back on?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 15999

PostPosted: Sat Dec 11, 2010 5:02 pm    Post subject: Re: network needs to be restarted manually after suspend Reply with quote

HyperQuantum wrote:
I suspect that the connection stops working because the DHCP lease expires (or something), but why isn't it automatically renewed when the laptop comes back on?
Reactivating the network might be the wrong thing to do if you come back up on battery in a wireless-free zone, or you do not want to expose yourself to the local network (perhaps you just wanted to read local files), or various other reasons. If you always want to enable the wireless card on resume, you should tell your suspend script to bring the interface down on suspend and bring it up on resume.
Back to top
View user's profile Send private message
Joseph K.
Guru
Guru


Joined: 07 Jun 2006
Posts: 421
Location: Melbourne, Australia

PostPosted: Tue Mar 01, 2011 4:53 am    Post subject: Reply with quote

I have the exact same question, because my old laptop would automatically connect to a network that was configured in wpa_supplicant.conf, but my new laptop does not. At first I suspected that it was because I had disabled wireless extensions on the new laptop, but even after enabling it the behaviour is the same. Any ideas on why that might be?

In order to effect the reconnect behaviour I had a look at the commands available to wpa_cli, but I think it's not suitable for stopping and starting the network, so it's a choice between ifconfig up/down and net.wlan0 stop/start. I'm going to go for ifconfig up/down because it seems like the simplest command to achieve the desired effect.
Back to top
View user's profile Send private message
RNHavens
n00b
n00b


Joined: 22 May 2007
Posts: 8

PostPosted: Fri Mar 04, 2011 4:37 am    Post subject: Reply with quote

robert@foomanchu ~ $ grep net.wlan0 -C3 /etc/hibernate/common.conf

### services
RestartServices alsasound
RestartServices net.wlan0
# StopServices alsasound
# StartServices aumix
Back to top
View user's profile Send private message
Joseph K.
Guru
Guru


Joined: 07 Jun 2006
Posts: 421
Location: Melbourne, Australia

PostPosted: Fri Mar 04, 2011 6:04 am    Post subject: Reply with quote

Hmmm, I guess you must be using a different power management package, RNHavens, because I don't have that /etc/hibernate directory.

After a bit of experimenting, I found that enabling WE support in the kernel was causing wpa_supplicant to crash on resume. Now that I have disabled it again, wpa_supplicant does assume that it is still connected to the same wireless network when I resume, which is a security risk, but not a serious one. Anyway, since I use the laptop at many locations, I found it was better to stop the network script on suspend and start it again on resume anyway, because it would not automatically realize that it was in a new location. ifconfig up/down didn't quite cut it.

However, I am still curious as to why it is not stopping/starting automagically like my old laptop did. Cheers.
Back to top
View user's profile Send private message
mr.sande
Tux's lil' helper
Tux's lil' helper


Joined: 26 Apr 2010
Posts: 82
Location: Norway

PostPosted: Sun Mar 06, 2011 4:22 pm    Post subject: Reply with quote

I'v had this happen too.

I solved it by adding a little script to /etc/pm/sleep.d/. You have to make it executable in order to make it work.
There should also be a /hibernate.d/ in /etc/pm/ if you want your system to do the same when hibernating.
Code:
quark sleep.d # cat 50wifi
#!/bin/bash
case $1 in
   suspend)
      echo "Stopping wifi"
      /etc/init.d/net.wlan0 stop > /dev/null
      ;;
   resume)
      echo "Starting wifi"
      /etc/init.d/net.wlan0 start > /dev/null
      ;;
esac


I guess it depends on how your setup suspends, I'm using pm-utils in Gnome.
Back to top
View user's profile Send private message
Dagger
Retired Dev
Retired Dev


Joined: 11 Jun 2003
Posts: 765
Location: UK

PostPosted: Thu Mar 10, 2011 9:37 am    Post subject: Reply with quote

Alternatively you can use NetworkManager. It will handle everything for you. It understands Gentoo configuration files, so switch should be really easy.
If you don't like ppp dependency, you can test 0.9beta1 from my overlay - it should be merged to portage once 0.9.0 is released.
_________________
95% of all computer errors occur between chair and keyboard (TM)
Join the FSF as an Associate Member!
Post under CC license.
Back to top
View user's profile Send private message
Rion
Guru
Guru


Joined: 12 Oct 2006
Posts: 380
Location: Minsk, Belarus

PostPosted: Fri Oct 07, 2011 4:12 am    Post subject: Reply with quote

NetworkManager doesn't work in the same way (I have to restart NetworkManager each time after resume).
and even hack with sleep.d (restarting Networkmanager there) doesn't work.
I didn't try nm-0.9 though.

I have switched from nm to manually configured wpa_supplicant and net.wlan0 with sleep.d hack.
_________________
rion-overlay
Back to top
View user's profile Send private message
eugen_mihailescu
n00b
n00b


Joined: 27 Sep 2011
Posts: 23

PostPosted: Wed Jan 18, 2012 4:21 am    Post subject: Reply with quote

mr.sande wrote:
I'v had this happen too.

I solved it by adding a little script to /etc/pm/sleep.d/. You have to make it executable in order to make it work.
There should also be a /hibernate.d/ in /etc/pm/ if you want your system to do the same when hibernating.
Code:
quark sleep.d # cat 50wifi
#!/bin/bash
case $1 in
   suspend)
      echo "Stopping wifi"
      /etc/init.d/net.wlan0 stop > /dev/null
      ;;
   resume)
      echo "Starting wifi"
      /etc/init.d/net.wlan0 start > /dev/null
      ;;
esac


I guess it depends on how your setup suspends, I'm using pm-utils in Gnome.



It works for me too. Thank you!
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7585
Location: almost Mile High in the USA

PostPosted: Wed Jan 18, 2012 8:13 pm    Post subject: Reply with quote

I've been a NetworkManager-0.8 user with Gnome, and it handles suspend/resume fine. I do have to make sure that I mark in nm-applet which networks it should auto-reconnect to, naturally I don't want it automatically connecting to any network it's near - just my home network.

Granted, if it was on a particular access point on sleep/hibernate and it's still near that access point on resume, it will not reconnect to that access point unless I specify auto-reconnect in that profile...
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
kimmie
Guru
Guru


Joined: 08 Sep 2004
Posts: 531
Location: Australia

PostPosted: Wed Jan 18, 2012 9:04 pm    Post subject: Reply with quote

Could be a kernel problem... there have been issues with some wireless drivers in recentish kernels. This was happening on my laptop (iwlagn) until 3.0.6 (I think, might have been 2.6.39, memory fades). Anyway 3.0.6 reconnects properly for me after resume. My router hands out leases for a few days, so it's very unlikely a lease would be need renewing after a resume.

Vaguely related: on 3.1.6 iwlagn doesn't work for me at all... apparently iwlagn and iwlwifi are getting merged and it should be sorted in 3.2.
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