# automatic reconnect wireless when dropped..?

## jettjunker

My media PC in the living room gets a fairly weak wireless connection and gets dropped on average about once a day (sometimes several times a day, sometimes only every few days).  Obviously that gets annoying fast, since I can't exactly ssh in to manually restart it  :Smile: 

I use NetworkManager right now (and nm-applet), but it only tries to reconnect once before giving up.  I've searched a bit and, unless it's recently changed, it can't be configured to try reconnecting indefinitely.  Anyone know of a good option that would?

Or, anyone have an idea for a cron script that I could have run every 5 minutes or so, testing the connection and manually reconnecting to my network if it isn't already?  Here's what I have (and setting NOPASSWD for those sudo commands in /etc/sudoers), but I imagine there's a more elegant solution...  

```
#! /bin/sh

sudo /sbin/ifconfig ath0 > temp.txt &

grep 192.168.1.10 temp.txt > temp2.txt &  

if [ -s /home/user/temp2.txt ]

        then

                wait &

        else

                sudo /etc/init.d/NetworkManager restart &

fi

```

[What it does: print the ifconfig info for my wireless device to temp.txt, then greps that for the particular computer's IP and prints that info to temp2.txt.  If that IP isn't found, temp2.txt is a blank 0 kb file.  The 'if' portion script then checks the size of that file: If it is >0kb, then it waits, but if it's 0kb then restarts NetworkManager]

----------

## baeksu

ifplugd might work for you.

----------

## its1louder

for the sake of posterity, I'll link to this ubuntu discussion:

http://ubuntuforums.org/showthread.php?t=320282

----------

