# A way to keep the wifi retrying.



## kpedersen (Aug 11, 2010)

Hello,

Problem:
If I connect to my wifi at home with


```
# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
```


```
# dhclient wlan0
```

And then pick my laptop up and take it for a stroll around town, when I get back home and leave it on my desk for an unlimited amount of time, it never seems to reconnect.
Is the wpa_supplicant daemon and dhclient not meant to keep retrying and reconnecting?

Does anyone have a solution to this?

Would I have to make a script that keeps looping these two applications?

Best Regards,


----------



## jb_fvwm2 (Aug 12, 2010)

If you put the first line into rc.conf 
(see posts for syntax).
when it disconnects you can shorten the
second (the reconnect) to an alias.

```
alias dw='dhclient wlan0'
```
 if
that would work in your .chsrc or whatever.
...
if the reconnect does not work

```
sh /etc/rc.d/netif restart
```
might work if the wlan0 is already in 
rc.conf ...  (A pair of lines...)
(VARIES depending upon v7 or v8).
...
DISCLAIMER. I've not double checked any
of these syntaxes.  Typos or inaccuracies...


----------



## fronclynne (Aug 12, 2010)

Humm, I don't wander much with my FreeBSD laptop(s) & I shut them down mostly, so I don't get much moving from network to network (you'll excuse the diversion, as this is merely to exposit on the general theory that I haven't much real-world experience in this) but I would probably just do a `# /etc/rc.d/netif restart`
and pray.


----------



## kpedersen (Aug 13, 2010)

Hiya thanks guys.

Though both your solutions involve *me* retrying the wifi.

Ideally I would like to find a way for FreeBSD to do it.

For example the wireless manager in Windows XP was very reliable in the way that it would generally reconnect as soon as a network was in range.

I may have to do is write some scripts to do this. Until then, any more suggestions are appreciated


----------



## fronclynne (Aug 18, 2010)

Ah, I find it annoying myself when the linux laptops automatically connect to random stuff like poorly configured HP print servers or known bad networks.

It looks like someone was trying to port guh-nomes nm-applet back in 2009.  No idea how that's gone or going.

_edit_: additionally, there is wicd for linux.  Again, no idea how horrible this may be to port over.


----------



## wblock@ (Aug 18, 2010)

kpedersen said:
			
		

> Though both your solutions involve *me* retrying the wifi.
> 
> Ideally I would like to find a way for FreeBSD to do it.



When testing Broadcom cards, I see wpa_supplicant reassociate automatically after a disconnect.  dhclient doesn't restart on its own, though.

Maybe one of those "check-and-restart-daemon" scripts that the Linux guys seem to like?


----------



## kpedersen (Aug 18, 2010)

Oh boy you lot are in for a treat!!

/sbin/wpa_loop

```
#!/bin/sh

while true
do
  wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
  sleep 5
done
```

/etc/dhclient_loop

```
#!/bin/sh

while true
do
  dhclient -d wlan0
  sleep 5
done
```

/etc/rc.d/connect

```
wpa_loop &
dhclient_loop &
```

Skriptzzz!


----------

