# wlan0 stops



## davidgurvich (Aug 20, 2010)

I created a connection using ifconfig wlandev and set it up to use DHCP.  The connection is made but then stops after a short while.  There doesn't seem to be any issues with the hardware.  Doing the following restores the connection.

`ifconfig wlan0 down`
`ifconfig wlan0 up`


----------



## kpedersen (Aug 20, 2010)

What wireless card you using?

It sounds like the awesomeness of the ipw2200 or ipw2100 lol.


----------



## davidgurvich (Aug 20, 2010)

The wireless uses a ralink rt2661 chipset.  I seem to have a working configuration right now, except that dhcp fails to configure the routing properly.  I'm not sure what is going on.

For the morbidly curious here is the rc.conf settings.

```
defaultrouter="192.168.1.1"
wlans_ral0="wlan0"
ifconfig_wlan0="SYNCDHCP -bgscan mode 11g"
```

I'm also using a /etc/start_if.wlan0 file which seems to just be a script file as the syntax is identical to ifconfig.
ifconfig wlan0 blah blah blah

The settings are demonstrably correct as I get a connection using them.  The problem is that after a random amount of time the wireless just stops. No reason that I can see.  My best guess is some misplaced powersaving feature in 8.1.


----------



## kpedersen (Aug 21, 2010)

hmm,

try using DHCP rather than SYNCDHCP

Also, what is in your /etc/resolv.conf?

If you are using DHCP, you do not want defaultrouter="... in your /etc/rc.conf

That's the only ideas I can come up with...


----------



## davidgurvich (Aug 21, 2010)

I agree entirely.  There should be no reason for syncdhcp other than dhcp fails, as in this case.  The syncdhcp gets an ip address but fails to set the routing properly.  You can see where this is going.

DHCP fails, use SYNCDHCP.
SYNCDHCP doesn't set routing, use defaultrouter. 

It's all very annoying.  On the plus side ZFS is working nicely on a P3 system with 1GB of ram.


----------



## jb_fvwm2 (Aug 21, 2010)

how much time is "a short while?"  You can
alias 

```
dhclient wlan0
```
to, say, "dw" if that would be unique, and if
that command restarts good rather than the 
more reliable

```
sh /etc/rc.d/netif restart
```
cli.


----------



## kpedersen (Aug 21, 2010)

As a last resort try my script from here (http://forums.freebsd.org/showthread.php?t=16854)

It is an ugly hack but works surprisingly well.

It basically keeps both wpa_supplicant and dhclient running in a loop so fixes the connection as soon as one ends etc...

Remember to `chmod +x` them all.


----------



## davidgurvich (Aug 21, 2010)

Right now the settings seem to be working.  I haven't had an unscheduled drop since my last post with no changes in the the settings.  Clearly more frustrating to have the dropped connection but I have no idea what happened.

EDIT:Just had it happen again.  Putting the ral0 interface down/up cycle seems to reconnect better than wlan0.  I'm going to add that to the start_if.wlan0 script and see what happens.

Does anyone know how the ifconfig powersave option works?  The symptoms looks like what's happening here from the man file description.


----------



## davidgurvich (Aug 23, 2010)

I'm still not sure what's going but clearly there is a problem. I've now changed over to manually setting the ip address and routing and occasionally do
	
	



```
/etc/rc.d/netif restart wlan0
```

That is fine for me but perhaps not for anyone else that I might hand the laptop over to.  I would like a good idea of how to check for a connection as ping doesn't timeout fast enough.  Alternatively, I could just have a script that restarts wlan0 every minute.  That goes so fast that my connection isn't even affected.


----------



## kpedersen (Aug 23, 2010)

Hmm, I got bitten my my *ss with that script.. it is really odd,

ural0 said associated but wlan0 said no carrier...

Man... wireless on FreeBSD isnt *quite* there yet for it to be reliable enough as a wifi torrent server 

Good luck.


----------



## davidgurvich (Aug 23, 2010)

The DHCP handshake takes too long for a netif restart to be an effective solution but with a manually set ip address and routing it takes under 3 seconds before reestablishing the connection.  All the routing can be set in start_if.wlan0 different versions of start_if.wlan0 for all the different locations that you may need wireless.

Here's the relevant portions of rc.conf, almost empty.

```
#wireless
wlans_ral0="wlan0"
ifconfig_wlan0="mcastrate 54 mode 11g"
```
and here's start_if.wlan0 with relevant information modified.

```
ifconfig wlan0 ssid myaccesspoint wepmode on wepkey 0x123456789a deftxkey 1
ifconfig wlan0 inet 192.168.1.200 netmask 0xffffff00
route add default 192.168.1.1
```
I also set resolv.conf manually but using something like the opendns servers would make it more universal.  I haven't yet made a script that would restart wlan0 every minute or so but am considering it.

The handbook and man pages are wrong on how to use ifconfig.  I had to use two separate lines because "inet" and "netmask" were not recognized as options if I had those in the first line.  Using two separate commands to set the ip address and ssid are actually required.  The man page example for ral doesn't work as a single command.


----------



## davidgurvich (Aug 24, 2010)

I decided to see what would happen if I added all the modules required in loader.conf but there was no difference.  I then tried wpa_supplicant, not necessary for WEP according to the handbook.  That didn't work until after I rebooted as wpa_supplicant failed to start.  I don't know why `/etc/rc.d/netif restart` wouldn't do anything.

Since then I've had a connection after boot and haven't needed to restart wlan0 while connected.  My rc.conf

```
wlans_ral0="wlan0"
ifconfig_wlan0="WPA DHCP"
```
my /etc/wpa_supplicant

```
# Let all users in wheel use wpa frontend
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel

# Home network
network={
	ssid="myssid"
	key_mgmt=NONE
	wep_tx_keyidx=0
	wep_key0=123456789A
}
```

Does anyone know why the connection works with wpa_supplicant but fails without it?


----------



## jb_fvwm2 (Aug 24, 2010)

I don't know, but I'd back up those 2-3 files in
case some other problem occurs (hard disk crash...)
(reinstall...)


----------



## davidgurvich (Aug 24, 2010)

The changes are small and trivial.  The system doesn't have a lot of effort installed in setting it up yet. I'm still considering a script to cycle ral0 down and up.  Cycling ral0 is faster than restarting wpa_supplicant and getting a DHCP handshake.  There seems to be a problem with the ral driver where it puts the radio to sleep and doesn't wake up. 

Anyone know how to post a bug report and where to post it for network drivers?  Also, there doesn't seem to be any error messages but the following:
	
	



```
ral0: need multicast update callback
interrupt storm detected on "irq11:"; throttling interrupt source
```
I no longer see ral0 in the list of interrupts with vmstat -i but it used to be on irq11 when I looked before.  I don't know why it has disappeared but I get that message whenever I cycle ral0 then 4 of the multicast messages.


----------



## davidgurvich (Aug 28, 2010)

*solved?*

I'm not sure but I think that what is happening is a problem with reception.  I just noticed that if I have no connection and move the laptop around that I magically get a connection.
I used the laptop with multiple Linux distributions and that is one thing that always worked well.  I'll see about installing a better wireless antenna but probably not for a while.  Until then, I'll keep waving the laptop around in the air like a demented lawyer.


----------

