Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

This question already has an answer here:

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

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?

share|improve this question

marked as duplicate by James Feb 25 '14 at 3:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 2 down vote accepted

ifup wlan0 should do all that for you automatically.

It reads the interfaces file and does everything that startup would do. You may have to run ifdown wlan0 first if ifup believes the interface is already up.

You could make a small script to try getting the file and then run ifup if it fails and cron it for every hour or two.

share|improve this answer

I found the following script at

  • Just create a new file vi /root/checkwanup:

    wlan=`/sbin/ifconfig wlan0 | grep inet\ addr | wc -l`
    if [ $wlan -eq 0 ]; then
    /sbin/ifdown wlan0 && /sbin/ifup wlan0
    echo interface is up
  • Then chmod 555 /root/checkwanup

  • Add it to your crontab

    crontab -e
    */15 * * * * /bin/bash /root/checkwanup
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.