Check connection and reconnect wifi

Posted by Ruud on Ask Ubuntu See other posts from Ask Ubuntu or by Ruud
Published on 2011-11-29T15:55:18Z Indexed on 2011/11/29 18:03 UTC
Read the original article Hit count: 355

Filed under:
|

I'm building a wireless photoframe. The one thing I haven't been able to figure out is how to get my wifi connection back up using a recommended method.

Right now I edited /etc/network/interfaces so wlan0 is started at boot:

auto wlan0
iface wlan0 inet dhcp
        wireless-essid ourssid

This method works fine for booting. But I found that if I do not check the connection for a long time (could be a week) it might be down. So I should reconnect.

What I do now to verify the connection is working is downloading a file from the server that can't be cached (http://server.ext/ping.php?randomize=123456) If I fail to retrieve the file I assume that the connection is no longer working and I run a shell script like

#!/bin/bash
ifconfig wlan0 up
iwconfig wlan0 essid "ourssid"
dhclient wlan0

And the connection comes back. But I can't find anything if this is in any way a good method.

Can this be improved upon, or is this already right?

© Ask Ubuntu or respective owner

Related posts about wireless

Related posts about bash