# no network after suspend/resume

## josephg

netifrc works fine at boot. i have network and all is well. 

after a suspend/resume, i have no network. i am reconnected to the wifi network. dmesg shows wlan0 associated. "/usr/sbin/iw wlan0" link shows connected too. i have the same ip from before suspend, but i think udhcpc didn't trigger after wifi reconnected.

i can manually "busybox udhcpc -i wlan0", and all is well again. what am i missing?

----------

## chiefbag

Would "sys-apps/netplug" be useful here?

----------

## josephg

 *chiefbag wrote:*   

> Would "sys-apps/netplug" be useful here?

 

thank yes  :Smile:  it does trigger wpa_cli and reconnects wifi. but i think it doesn't trigger udhcpc. i can run udhcpc to get an ip, and all is well afters. do you use wifi with netplug?

----------

## chiefbag

No I have never tried it with WiFi but use it for wired, just did a quick Google and it appears it supports wired and WiFi.

----------

## chiefbag

Perhaps it only supports dhcpcd and not udhcpc triggering.

You could always modify the /etc/netplug.d/netplug script

http://www.red-bean.com/~bos/netplug/netplugd.8.html

----------

## josephg

 *chiefbag wrote:*   

> No I have never tried it with WiFi but use it for wired, just did a quick Google and it appears it supports wired and WiFi.

 

i ran netplugd in the foreground and could see it picking up the events as i turned my wifi device on and off. wpa_cli was being triggered from somewhere.. and wifi network was reconnecting. but it seemed to stop there, rather than go further and dhcp. i'm going to look a bit deeper into the code, if i can get my head around where this is happening.

 *chiefbag wrote:*   

> Perhaps it only supports dhcpcd and not udhcpc triggering.
> 
> You could always modify the /etc/netplug.d/netplug script

 

perhaps.. atmo i'm more keen on udhcpc than dhcpcd. if i go that way, i might as get rid of the whole netifrc stack.

that netplug script is triggering /etc/init.d/net.${IFACE}. when i run it manually, i get dhcp ip correctly. but it doesn't seem to happen automagically. bit stumped.Last edited by josephg on Wed Jun 28, 2017 5:21 pm; edited 1 time in total

----------

## josephg

i removed netplug by "emerge -c netplug". so my interface shouldn't hotplug, right? wrong! it still does so.. syslog shows wpa_cli as DISCONNECTED and CONNECTED after suspend and resume.

```
Jun 28 18:15:18 localhost user.notice wpa_cli: interface wlan0 DISCONNECTED

Jun 28 18:15:18 localhost user.notice wpa_cli: executing 'false /etc/init.d/net.wlan0 --quiet stop' failed

Jun 28 18:15:19 localhost user.notice wpa_cli: interface wlan0 CONNECTED

Jun 28 18:15:19 localhost user.notice wpa_cli: executing '/etc/init.d/net.wlan0 --quiet start' failed
```

i wonder what's calling wpa_cli during suspend/resume.. would it be s2ram?

----------

## josephg

i wanted to remain with the gentoo netifrc stack, as i had a lot configured just the way i like it. everyone on #gentoo kept telling me to use dhcpcd instead. getting involved in the openrc-init vs sysvinit debate opened me up to thinking again. perhaps i shouldn't use the same package for init and networking. reluctantly, i have removed and replaced the entire netifrc stack with dhcpcd. suspend/resume automatically brings up the network and i haven't specified so anywhere. dhcpcd runs all the time and does everything automatically, whether i want it or not. for example, i don't want my laptop to be automatically connected to the network, if a cable is inserted. since i don't know how to stop that happening, i have to blacklist my ethernet module.

----------

## josephg

i figured out how to dhcpcd listen only for specific interfaces

```
allowinterfaces wlan0
```

----------

## szatox

I had a similar issue with a wifi in master mode. What I did was creating a simple script.

sys-power/pm-utils invokes this script every time my pc wakes up after suspend. I'm pretty sure you could tune it to your needs if you feel like you needed it.

```
 # cat /etc/pm/sleep.d/hostapd 

#! /bin/bash

if /etc/init.d/hostapd status

then /etc/init.d/hostapd restart

fi

```

----------

