Notes From James
Home | About | Find Stuff | Download
Ubuntu: Automatically reconnecting a wireless connection   

I have an old cordless phone. A phone that, once it rings, causes my local wireless network to go down. Windows seems to repair itself, but Ubuntu just hangs there dead until I manually reconnect it. Here is a solution that checks the network every minute. If there is a failure (30 seconds or so after checking), the network is restarted.

First, make a file called check_network in the /root directory by using 'sudo vi /root/check_network'. In it, put the following code:


wget -q -O /dev/null "http://www.google.com" || ( /etc/init.d/networking restart )

This checks the connection (in this case, against Google). If it doesn't, it causes the network to restart. Now, add this to the root user's crontab file by running 'sudo crontab -e'. The crontab file should look like:


# m h  dom mon dow   command
* * * * * /root/check_network

This means, every minute, run the check_network script. I wish there was a better way of doing this. Actually, if there could be a tie-in to the icon that shows the connectivity in the toolbar, that would be an even better solution.



[Asbury Elementary School Information]  [Them! Re-imagining]