# auto reconnect on wireless

## Tomsen

Hi

I've just changed our wired network with wireless in the entire house. I have no problem with connecting to the AP, but because i have a cheepass router that has to restart everytime I change in the NAT settings.

This results in my server loosing the connection to the AP and i have to connect a screen and keyboard to restart the wireless interface.

How do i make it recoonect by itself?

----------

## DavidJN

Might an easier solution be to use SSH to restart it?

----------

## Tomsen

I can't ssh to the machine, it has lost its network connection. That is why I have to connect a screen and keyboard

----------

## ManReal

Can you not have a script running in the background on the server which pings google.com and if the ping fails then you reconnect the connection?

----------

## Tomsen

Well I could, but isn't it possible to make gentoo reconnect if it looses the connection?

----------

## qdii

Sorry to reopen that thread, but it corresponds to a problem I am having.

To keep my 2nd computer connected to a Wifi network, I've crafted that little script :

 *Quote:*   

> 
> 
> #/bin/sh
> 
> if ping -q -c 1 www.google.com &> /dev/null
> ...

 

When I run it from a standard bash shell, it works fine.

bringing wlan0 down and up does - I imagine - reset it and DHCP finishes the work.

but when I schedule it to be executed every 3 minutes with vixie-cron, the connection remains down, even though /var/log/autoreconnect contains a line stating that it was DOWN a minute ago.

Any idea ?

----------

## cach0rr0

could you not just restart the net.wlan0 init script?

----------

## Yamakuzure

Maybe you could give net-misc/wicd a try? It allows for running custom scripts before/after shutting down/starting up a connection. And on my laptop if I re-enable wireless via rf-kill switch, connects in an instant. (Quite useful for a laptop that keeps travelling and switching between different wired and wireless networks.)

----------

## d2_racing

I use the auto-reconnect option inside WICD and it's working pretty good.

----------

## qdii

cachorro : I've tried to use /etc/init.d/net.wlan0 restart, but it gets an error from something in /proc/.../carrier and won't reconnect the wifi until I stop and start the interface.

for what concerns WICD, I'll give it a try tomorrow  :Smile:  thanks for the tip

----------

## d2_racing

No problem, and if you need help, just post  :Razz: 

----------

