View Full Version : [ubuntu] Wireless Access Point resume from suspend

October 6th, 2011, 08:05 PM

I finally have my USB dongle acting as a wireless access point which can successfully share the internet with clients.

I used the following rc.local to make this happen:

/sbin/ifconfig wlan0 inet netmask
/sbin/iptables-restore < /etc/iptables.rules
/usr/local/bin/hostapd -B /etc/hostapd/hostapd.conf
service dhcp3-server startThis works great on boot; and it's pretty evident that the order of execution for each of the statements is important. But when resuming from suspend, my WAP doesn't work anymore.

After resuming, this is what I have:

the kernel module (driver) remains loaded
the hostapd program is still running
the dhcp3-server process is still running
the iptables rules are still in effect
the wlan0 interface is defined, but no IP address is assigned

I attempted to resolve the last point by adding a script to /etc/pm/sleep.d that assigns the IP address to the wlan0 interface. And while this executes successfully, it seems pretty irrelevant because this assignment has to occur before hostapd is running.

So I'm asking for some advice on how people are reconfiguring their WAPs after resuming from suspend?

It seems that the crux of the problem here is that the hostapd program isn't a service, so it can't be "restarted". Do I have to track down the PID, kill it, start it again and then restart dhcp3-server? Or is there a better way?

I appreciate any help.

October 10th, 2011, 10:02 PM
Despite everyone's rush to help me, I decided to just make a script in /etc/pm/sleep.d/ that kills hostapd on suspend and relaunches it on resume. Not particularly elegant, but it works.


case "$1" in
/usr/bin/killall hostapd
/sbin/ifconfig wlan0 inet netmask
/usr/local/bin/hostapd -B /etc/hostapd/hostapd.conf