# Wifi hotspot: partially connected



## ixterm (Apr 3, 2011)

Hello

It seems that my wifi connection is not properly running. I'm on 8.1, using an iwi0 driver which is working fine. To connect to a hotspot, I initiate:

```
ifconfig wlan0 ssid "the_ssid_name"
```

After that, I launch *dhclient wlan0*, after a while I get the IP addresses. I verify that /etc/resolv.conf has the right dns, the default gateway IP is properly setup as well. But when I open the browser (any browser), it tries to connect, I see the title of the webpage coming on the top, but the connection hangs and stops.

That reoccurs with any hotspots (free unencrypted hotspots). I'm sure it's not a browser issue, because when I use a LAN connection, I can browse successfully. Moreover, the wifi internet connection works fine on different operating systems (linux, windows.....etc). It is unclear why under FreeBSD it's acting like that.

Maybe I am creating the wlan0 in a wrong way? (*ifconfig wlan0 create wlandev iwi0*)


----------



## bluetick (Apr 4, 2011)

Not enough information for me to help you.


But it's covered in this section of the handbook.
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-wireless.html


----------



## ixterm (Apr 4, 2011)

The weirdest part is that it gets connected but it loses the connection immediately; for example after *dhclient* is done, I open the browser, default page google which is displayed properly, now when I type a keyword to search, it hangs.

I did ping tests, as soon as the dhcp is done, I can ping anything (yahoo, google). When I run a second ping, it times out, connection lost again.

I reinitiate the network interface by doing 
	
	



```
/etc/rc.d/netif restart
```
and this is the lethal command, because it crashes FreeBSD and reboots the system.

I dont know why, maybe a bug in the driver.


----------



## wblock@ (Apr 4, 2011)

My experience with restarting netif is that it does sometimes cause a reboot.  It's been rare enough on my systems that I've never pursued it.

If the "first ping works, second fails" is consistent, check if authorization is required at the access point.  Also check to see if you have some firewall rules on the FreeBSD system that are kicking in.


----------



## grigorovl (Apr 4, 2011)

I had problems with no password networks, too. Did you try creating an entry in /etc/wpa_supplicant.conf? Then restart netif and [cmd=]# dhclient INTERFACE[/cmd]


----------



## ixterm (Apr 4, 2011)

For the access point, it's a free unencrypted wifi router. I connect to it from linux or windows, without any problem. So there might firewalls blocking the wireless network interface. I haven't a /etc/wpa_supplicant.conf file  yet, I will give it a try.

What do you type under passphrase or password, for no password networks?


----------



## grigorovl (Apr 5, 2011)

The file is not created by default. You can copy the sample conf or use something like this:

```
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel

network={
        ssid="your essid goes here"
        key_mgmt=NONE
}
```

Then restart netif and try dhclient.


----------



## ixterm (Apr 5, 2011)

Ok, so I found that there was the wpa_supplicant.conf file:


```
network={
        ssid="ssid name"
        key_mgmt=NONE
}
```

This was created by the tool *wifimgr*. Sometimes I use *wifimgr* to get a visual quick look at available hotspots. I wondered if this could cause the issue, previoulsy I commented hostname under /etc/rc.conf so I was running without a hostname. I reenabled the hostname, I still get the same behavior. Once dhclient acquires IP, I open the browser, google opens properly, and then the connection is lost again.


----------



## wblock@ (Apr 5, 2011)

After it stops responding, see what ifconfig(8) shows about wlan0.  Is it still connected?


----------



## ixterm (Apr 6, 2011)

So here is the series of tests I did:


```
root@fbsd[171]# dhclient wlan0
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.1
bound to 192.168.0.130 -- renewal in 302400 seconds.
root@fbsd[172]# ifconfig wlan0

wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:13:46:49:41:76
        inet 192.168.0.130 netmask 0xffffff00 broadcast 192.168.0.255
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
        status: associated
        ssid dlink channel 5 (2432 MHz 11g) bssid 3c:d8:67:5b:ad:31
        country US authmode OPEN privacy OFF txpower 0 bmiss 24 scanvalid 60
        protmode CTS wme roaming MANUAL

root@fbsd[173]# ping www.freebsd.org
PING red.freebsd.org (69.147.83.34): 56 data bytes
64 bytes from 69.147.83.34: icmp_seq=0 ttl=54 time=83.952 ms
64 bytes from 69.147.83.34: icmp_seq=1 ttl=54 time=83.039 ms
64 bytes from 69.147.83.34: icmp_seq=4 ttl=54 time=88.026 ms
64 bytes from 69.147.83.34: icmp_seq=8 ttl=54 time=84.964 ms
64 bytes from 69.147.83.34: icmp_seq=9 ttl=54 time=86.152 ms
64 bytes from 69.147.83.34: icmp_seq=10 ttl=54 time=84.162 ms
64 bytes from 69.147.83.34: icmp_seq=11 ttl=54 time=87.213 ms
64 bytes from 69.147.83.34: icmp_seq=12 ttl=54 time=87.887 ms
64 bytes from 69.147.83.34: icmp_seq=13 ttl=54 time=85.420 ms
64 bytes from 69.147.83.34: icmp_seq=15 ttl=54 time=79.079 ms
64 bytes from 69.147.83.34: icmp_seq=18 ttl=54 time=84.461 ms
64 bytes from 69.147.83.34: icmp_seq=19 ttl=54 time=82.957 ms
64 bytes from 69.147.83.34: icmp_seq=20 ttl=54 time=82.645 ms
ping: sendto: Network is down
^C   ===========> I did a Ctrl+C
--- red.freebsd.org ping statistics ---
23 packets transmitted, 13 packets received, 43.5% packet loss
round-trip min/avg/max/stddev = 79.079/84.612/88.026/2.364 ms

root@fbsd[174]# ping www.freebsd.org

PING red.freebsd.org (69.147.83.34): 56 data bytes
64 bytes from 69.147.83.34: icmp_seq=0 ttl=54 time=93.601 ms
64 bytes from 69.147.83.34: icmp_seq=1 ttl=54 time=112.298 ms
^C  ========> Ctrl+C
--- red.freebsd.org ping statistics ---
3 packets transmitted, 2 packets received, 33.3% packet loss
round-trip min/avg/max/stddev = 93.601/102.950/112.298/9.348 ms

root@fbsd[175]# ping www.google.com

PING www.l.google.com (72.14.204.99): 56 data bytes
64 bytes from 72.14.204.99: icmp_seq=0 ttl=56 time=32.946 ms
64 bytes from 72.14.204.99: icmp_seq=1 ttl=56 time=30.056 ms
^C
--- www.l.google.com ping statistics ---
3 packets transmitted, 2 packets received, 33.3% packet loss
round-trip min/avg/max/stddev = 30.056/31.501/32.946/1.445 ms
```

Then I opened the browser, the blank page was loading indefinitely. Then:

```
root@fbsd[176]# ping www.google.com

ping: cannot resolve www.google.com: Host name lookup failure

root@fbsd[177]# ifconfig wlan0

wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:13:46:49:41:76
        inet 192.168.0.130 netmask 0xffffff00 broadcast 192.168.0.255
        media: IEEE 802.11 Wireless Ethernet OFDM/48Mbps mode 11g
        status: associated
        ssid dlink channel 5 (2432 MHz 11g) bssid 3c:d8:67:5b:ad:31
        country US authmode OPEN privacy OFF txpower 0 bmiss 24 scanvalid 60
        protmode CTS wme roaming MANUAL
```


No matter what the signal strength is or the router's dhcp capability, the dhclient sometimes takes several minutes to achieve (like 30 lines of DHCPREQUEST on wlan0 to 255.255.255.255 port 67).


----------



## wblock@ (Apr 6, 2011)

What version of FreeBSD?


----------



## davidgurvich (Apr 6, 2011)

The same issue occurs regardless of wireless card on FreeBSD.  The inferior range is maddening, compared to any other OS, but the spontaneous reboots when reloading the driver or restarting netif are enough.  I'm no longer using FreeBSD on any laptops because of that.  

If you don't need flash or wine then try openbsd.  Doesn't crash the system when reloading the wireless driver.  

As a side rant, no system should ever crash from reloading a stable kernel module.  I've had systems crash when testing ndis drivers on linux, opensolaris, windows, and FreeBSD.  That's to be expected since these are windows drivers.  I don't expect native drivers to cause a system crash simply by unloading and reloading kernel modules.

If you are wondering which wireless chipsets work well then I don't know.  All the ones I've tried have the same issue.  That includes intel, ralink, broadcom and others.  I can get a connection when close enough to the transmitter but that connection is unstable and the system will crash if the wireless module is reloaded.  If the first reload doesn't crash the system then keep trying.


----------



## ixterm (Apr 6, 2011)

> What version of FreeBSD?



It's version 8.1.


----------



## wblock@ (Apr 6, 2011)

There have been updates to iwi(4) since 8.1.  Upgrade to at least 8.2-RELEASE.  It may be possible to upgrade the iwi driver alone via source.


----------



## wblock@ (Apr 6, 2011)

davidgurvich said:
			
		

> As a side rant, no system should ever crash from reloading a stable kernel module.  I've had systems crash when testing ndis drivers on linux, opensolaris, windows, and freebsd.  That's to be expected since these are windows drivers.  I don't expect native drivers to cause a system crash simply by unloading and reloading kernel modules.



I don't think *netif* reloads modules, but I don't know.  While I agree crashes shouldn't happen, there should also be little need to reload a wireless module.  The short-term workaround is to not use *netif*, but restart *wpa_supplicant* or *dhclient* individually.



> If you are wondering which wireless chipsets work well then I don't know.  All the ones I've tried have the same issue.  That includes intel, ralink, broadcom and others.  I can get a connection when close enough to the transmitter but that connection is unstable and the system will crash if the wireless module is reloaded.  If the first reload doesn't crash the system then keep trying.



I've used Atheros b/g, old Intel 2100 (ipw), some Broadcoms, and RealTek 8187 (urtw).  The Atheros works great, and I bought some extra and have replaced the cards in some systems.  The Broadcom card results were mixed.  Broadcom recently released open drivers, but I don't know if that's made any difference in the existing drivers yet.

If you've got hardware that easily reproduces the problem, enter a PR or it may never get fixed.


----------



## davidgurvich (Apr 6, 2011)

The poor connectivity doesn't show any particular errors, just doesn't work.  How does one get error logs for the system crash?  That particular problem I can usually recreate by restarting *wpa_supplicant* or *netif* or unloading and reloading the module.


----------



## wblock@ (Apr 6, 2011)

It depends on where the crash happens.  Probably best to start another thread, or post on the mailing lists.  Maybe freebsd-net.


----------



## ixterm (Apr 6, 2011)

To test, what can be done is that I connect with LAN, then I upgrade the iwi driver.


----------



## ixterm (Apr 26, 2011)

OK, so I upgraded to version 8.2 using a LAN connection which works perfectly, but after that, still the same issue. When the wifi gets connected, the first 2 pings on Google succeed, and then the third one fails, and loses the connection.


----------



## davidgurvich (Apr 27, 2011)

I've been trying out 9-current and haven't had any problems with a wireless connection yet.  There appears to have been significant positive changes.


----------



## ixterm (Apr 27, 2011)

Are my sysctl parameters useful to see if there is anything blocking the wireless connection, on hard/software level ?


----------



## ixterm (May 2, 2011)

I did another test. this time I was able to browse through internet properly with the hotspot but after a while the connection was lost, I reinitiate dhclient, but it's runnig endlessly:

```
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
```

Is the router unable to manage dhcp requests from FreeBSD, or is the dhclient application unable to send dhcp requests to the router?


----------

