# No Wi-Fi



## Megameneer (Jan 25, 2016)

Hello everybody,

When my father changed the router this year, my FreeBSD laptop suddenly didn't have a wifi connection anymore. I checked it with another wifi-device and that device couldn't scan the network as well on FreeBSD, but it could do on Linux.
My /etc/rc.conf:

```
hostname="Zeebaars"
wlans_wpi0="wlan0"
ifconfig_wlan0="WPA DHCP"
sshd_enable="YES"
dumpdev="AUTO"
hald_enable="YES"
dbus_enable="YES"
devfs_system_ruleset="system"
cupsd_enable="YES"
```

My /etc/wpa_supplicant.conf:

```
ctrl_interface=/var/run/wpa_supplicant
eapol_version=2
ap_scan=1
fast_reauth=1

network={
ssid="triple checked this one"
psk="triple checked this one too"
priority=5
}
network={
priority=0
key_mgmt=NONE
}
```

In my humble opinion, it shouldn't be that hard to switch networks, right? All my devices support the new network but why does FreeBSD do so difficult...

But thanks in advance for your support


----------



## wblock@ (Jan 25, 2016)

Why are you setting or overriding the default values?  I would remove all that, plus the last network setting with no SSID, and try again:

```
ctrl_interface=/var/run/wpa_supplicant

network={
   ssid="triple checked this one"
  psk="triple checked this one too"
  priority=5
}
```


----------



## Megameneer (Jan 25, 2016)

Ok, did that, runned `sudo service netif restart` without success and that gave these logs 


 

  (sorry that it had to be in pictures but I didn't want to type it over on my other PC)


----------



## tobik@ (Jan 25, 2016)

But wpi0 says it's associated. I would consider this success. Can you show the output of `ifconfig wlan0`?


----------



## asteriskRoss (Jan 25, 2016)

I was going suggesting trying to change the channel on your father's router, since the US allows fewer channels than the rest of the world (limitations on spectrum I believe) and I'm pretty sure FreeBSD defaults to the US region for WiFi cards.  However, I agree with tobik, in that it looks like you have successfully associated with the access point.  Try killing the dhclient process and starting it by hand with `dhclient wlan0`.  If you are running a firewall (rc.conf indicates you are not) then try disabling it to ensure you are not blocking any of the DHCP broadcasts or replies.

In the past I have seen WiFi cards that simply don't play well with particular access points.  For a while some years back the company I was working for used Draytek routers and had issues with cards from a number of manufacturers using both GNU/Linux and Windows XP.  Can you try a different card?  Or a different access point?


----------



## wblock@ (Jan 25, 2016)

The first screen says wlan0 does not exist.  (And ow, my neck.)

I have found either `dhclient` or `wpa_supplicant` do not like to be restarted with `service netif restart`.  They sometimes have to be manually stopped and started.  It is usually quicker to just restart the machine.


----------



## asteriskRoss (Jan 25, 2016)

Good spot, wblock@.  Without restarting, it is possible to create wlan0 yourself with `ifconfig wlan0 create wlandev wpi0` and then try to configure WPA with `wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf`, referencing the excellent Wireless Networking page in the FreeBSD handbook.  I end up doing this on one of my laptops when I forget to have the USB WiFi card plugged in at boot (note to self -- must get around to configuring devd(8) to do this automatically).


----------



## asteriskRoss (Jan 25, 2016)

Megameneer Now I also have an aching neck, I also noticed you accidentally included in the photos what looks like you new forums password.  You might want to change it


----------



## tobik@ (Jan 25, 2016)

wblock@ asteriskRoss  Right-click on the images and click "View image" to save yourselves some neck pain.


----------



## Megameneer (Jan 25, 2016)

tobik said:


> But wpi0 says it's associated. I would consider this success. Can you show the output of `ifconfig wlan0`?


Here it is


 


asteriskRoss said:


> I was going suggesting trying to change the channel on your father's router, since the US allows fewer channels than the rest of the world (limitations on spectrum I believe) and I'm pretty sure FreeBSD defaults to the US region for WiFi cards.  However, I agree with tobik, in that it looks like you have successfully associated with the access point.  Try killing the dhclient process and starting it by hand with `dhclient wlan0`.  If you are running a firewall (rc.conf indicates you are not) then try disabling it to ensure you are not blocking any of the DHCP broadcasts or replies.
> 
> In the past I have seen WiFi cards that simply don't play well with particular access points.  For a while some years back the company I was working for used Draytek routers and had issues with cards from a number of manufacturers using both GNU/Linux and Windows XP.  Can you try a different card?  Or a different access point?


I have tried it with a different USB Wi-Fi stick. It did not work as well. It could not even detect the network with 
	
	



```
sudo ifconfig wlan0 up list scan
```



wblock@ said:


> The first screen says wlan0 does not exist.  (And ow, my neck.)
> 
> I have found either `dhclient` or `wpa_supplicant` do not like to be restarted with `service netif restart`.  They sometimes have to be manually stopped and started.  It is usually quicker to just restart the machine.


It still does not work, even after rebooting.


asteriskRoss said:


> Good spot, wblock@.  Without restarting, it is possible to create wlan0 yourself with `ifconfig wlan0 create wlandev wpi0` and then try to configure WPA with `wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf`, referencing the excellent Wireless Networking page in the FreeBSD handbook.  I end up doing this on one of my laptops when I forget to have the USB WiFi card plugged in at boot (note to self -- must get around to configuring devd(8) to do this automatically).




```
ifconfig: create: bad value
```
 when tried `sudo ifconfig wlan0 create wlandev wpi0`



asteriskRoss said:


> Megameneer Now I also have an aching neck, I also noticed you accidentally included in the photos what looks like you new forums password.  You might want to change it


Thanks. I will definitely change it. Once. Upon a time. I'm quite good at forgetting things . If my account will ever spawn trolls and spams, you now know it's not from me.


----------



## asteriskRoss (Jan 25, 2016)

Megameneer said:


> I have tried it with a different USB Wi-Fi stick. It did not work as well. It could not even detect the network with
> 
> 
> 
> ...


Does the NIC you are using now (wpi0) detect the access point when you scan?



Megameneer said:


> ```
> ifconfig: create: bad value
> ```
> when tried `sudo ifconfig wlan0 create wlandev wpi0`


I think that is happening because after the reboot wlan0 has already been created, whereas as wblock@ pointed out before, in your earlier post that interface didn't exist.



asteriskRoss said:


> I was going suggesting trying to change the channel on your father's router


Humour me and try changing the channel on the access point.  Choose a number of 11 or lower.



asteriskRoss said:


> [...] referencing the excellent Wireless Networking page in the FreeBSD handbook. [...]


Running the ifconfig and wpa_supplicant commands by hand rather than through the start up scripts would be worth doing, since you can see more verbose output that might indicate where the problem is.

Can you connect to other access points using WPA2?  Have you tried connecting to the access point using a connection without encryption?  I am not suggesting you run an open access point, but it would be good to check that it is the WPA part that is the issue, not a more general connection issue.


----------



## Megameneer (Jan 26, 2016)

asteriskRoss said:


> Does the NIC you are using now (wpi0) detect the access point when you scan?


No, it did not. However, there were other entries on the list from my neighbours.


asteriskRoss said:


> Humour me and try changing the channel on the access point. Choose a number of 11 or lower.


My father does not allow me to modify his router. He changed his router because he switched to a new internet provider. "You're not going to mess with our network. It brings only more trouble. Go get yourself a normal operating system instead of MS-DOS with all those freaky commands." is what he would say.


asteriskRoss said:


> Running the ifconfig and wpa_supplicant commands by hand rather than through the start up scripts would be worth doing, since you can see more verbose output that might indicate where the problem is.


How exactly would I do that? Stopping the service and then restart them by hand?


asteriskRoss said:


> Can you connect to other access points using WPA2? Have you tried connecting to the access point using a connection without encryption? I am not suggesting you run an open access point, but it would be good to check that it is the WPA part that is the issue, not a more general connection issue.


Yes, I can. Before my father installed our new router, the connection ran fine, als with other hosts.


----------



## asteriskRoss (Jan 26, 2016)

Let's eliminate my channel theory.  In your screenshot of output from `ifconfig wlan0`, there is part of one line that says country US.  I suspect this will limit the channels your WiFi card can operate on.  It should be possible to display available channels (noting I'm not on a FreeBSD machine to test this) with `ifconfig wlan0 list chan`.

Assuming you are not in the US it should be possible to reconfigure the country, which I am hoping will enable your WiFi card to use the the channel that I suspect your router is on.  You can list the possible options with `ifconfig wlan0 list countries` and then set the country with `ifconfig wlan0 country Albania`, substituting your country's name.  `ifconfig wlan0` should show the new country, though I also note that according to the man page for ifconfig(8):


> Note that
> not all devices support changing the country code from a default
> setting; typically    stored in EEPROM.



I am hoping if you list the channels again with `ifconfig wlan0 list chan` you will now see more channels and if you scan again with `ifconfig wlan0 list scan` you will be able to see your router.  Have a go and I will keep my fingers crossed.


----------



## Megameneer (Jan 26, 2016)

asteriskRoss said:


> Let's eliminate my channel theory. In your screenshot of output from  ifconfig wlan0, there is part of one line that says country US. I suspect this will limit the channels your WiFi card can operate on. It should be possible to display available channels (noting I'm not on a FreeBSD machine to test this) with  ifconfig wlan0 list chan.




 
I don't know which one is my father's one. But I could check that out with my Linux box if necessary.


asteriskRoss said:


> Let's eliminate my channel theory.  In your screenshot of output from `ifconfig wlan0`, there is part of one line that says country US.  I suspect this will limit the channels your WiFi card can operate on.  It should be possible to display available channels (noting I'm not on a FreeBSD machine to test this) with `ifconfig wlan0 list chan`.
> 
> Assuming you are not in the US it should be possible to reconfigure the country, which I am hoping will enable your WiFi card to use the the channel that I suspect your router is on.  You can list the possible options with `ifconfig wlan0 list countries` and then set the country with `ifconfig wlan0 country Albania`, substituting your country's name.





I feel we are pretty close to the solution, however


----------



## asteriskRoss (Jan 26, 2016)

Perhaps.  Can you check which channel the router is operating on as you offered?  That will at least tell us whether it is a channel that your WiFi card can currently use.  I'm not sure why the attempt to change the country failed.  Perhaps the wlan0 and/or wpi0 interface needs to be marked as down to be reconfigured, though I am guessing here.  Try `ifconfig wlan0 down && ifconfig wlan0 country Netherlands && ifconfig wlan0 up` (wrap in `sudo sh -c "<command>"` for use with sudo).


----------



## asteriskRoss (Jan 26, 2016)

Another thought: perhaps the wlan0 interface needs to be created with the country parameter set.  Try `ifconfig wlan0 destroy && ifconfig wlan0 create wlandev wpi0 country Netherlands`.


----------



## Megameneer (Jan 26, 2016)

asteriskRoss said:


> Perhaps. Can you check which channel the router is operating on as you offered?


Under Arch Linux, I used `iw list` and that gave this (finally, sane plain text as error log )

```
Frequencies:
            * 2412 MHz [1] (20.0 dBm)
            * 2417 MHz [2] (20.0 dBm)
            * 2422 MHz [3] (20.0 dBm)
            * 2427 MHz [4] (20.0 dBm)
            * 2432 MHz [5] (20.0 dBm)
            * 2437 MHz [6] (20.0 dBm)
            * 2442 MHz [7] (20.0 dBm)
            * 2447 MHz [8] (20.0 dBm)
            * 2452 MHz [9] (20.0 dBm)
            * 2457 MHz [10] (20.0 dBm)
            * 2462 MHz [11] (20.0 dBm)
            * 2467 MHz [12] (20.0 dBm) (no IR)
            * 2472 MHz [13] (20.0 dBm)
            * 2484 MHz [14] (20.0 dBm) (no IR)
```



asteriskRoss said:


> ifconfig wlan0 down && ifconfig wlan0 country Netherlands && ifconfig wlan0 up (wrap in  sudo sh -c "<command>" for use with sudo).


I used:
`sudo ifconfig wlan0 down` which succeed and then
`sudo ifconfig wlan0 country Netherlands` which succeed and then
`sudo ifconfig wlan0 up` which succeed as well and then
`sudo service netif restart` but still no connection.


asteriskRoss said:


> Another thought: perhaps the wlan0 interface needs to be created with the country parameter set.  Try `ifconfig wlan0 destroy && ifconfig wlan0 create wlandev wpi0 country Netherlands`.


I used:
`sudo ifconfig wlan0 destroy`
`sudo ifconfig wlan0 create wlandev wpi0 country Netherlands`
and then restarted netif but still no success.


----------



## asteriskRoss (Jan 26, 2016)

Slow down a bit -- running `service netif restart` will make various call to ifconfig and put you back where you started.

OK, so additional channels 12, 13 and 14 (for 802.11g) are available under Arch GNU/Linux...  Did you check which channel the access point is using?

After you successfully changed country (please repeat the steps and check the country has in fact changed -- please post the output of `ifconfig wlan0`) are those additional channels also available on FreeBSD (post the output of `ifconfig wlan0 list chan`)?  And can you now see the access point (`ifconfig wlan0 list scan`)?  If you can, try running `wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf`, grabbing the output to post here, wait around 10 seconds and then post the output of `ifconfig wlan0`.  We can try making any permanent changes in the configuration files once we know things work.


----------



## Megameneer (Jan 27, 2016)

asteriskRoss said:


> OK, so additional channels 12, 13 and 14 (for 802.11g) are available under Arch GNU/Linux... Did you check which channel the access point is using?


According to the WifiAnalyzer app for Google Android, it uses channel 13.



asteriskRoss said:


> In the past I have seen WiFi cards that simply don't play well with particular access points. For a while some years back the company I was working for used Draytek routers and had issues with cards from a number of manufacturers using both GNU/Linux and Windows XP. Can you try a different card? Or a different access point?


My father's router is from Draytek according to WifiAnalyzer.


asteriskRoss said:


> After you successfully changed country (please repeat the steps and check the country has in fact changed -- please post the output of `ifconfig wlan0`) are those additional channels also available on FreeBSD (post the output of `ifconfig wlan0 list chan`)?  And can you now see the access point (`ifconfig wlan0 list scan`)?


I did as you do: `sudo ifconfig wlan0 down`, `sudo ifconfig wlan0 country Netherlands` and `sudo ifconfig wlan0 up`. Here are the screenshots of the commands `sudo ifconfig wlan0`, `sudo ifconfig wlan0 list chan` and `sudo ifconfig wlan0 list scan`



So, does it mean I have to switch to a different operating system?


----------



## tobik@ (Jan 27, 2016)

Can you try setting the country in /etc/rc.conf?

```
ifconfig_wlan0="WPA DHCP country NL"
```
Make sure to reboot afterwards.

Also please do a `ifconfig wlan0 scan` to initiate a new scan. `ifconfig wlan0 list scan` just shows the APs that were found during the last scan. According to the man page wpi(4) does not support background scanning, so it's likely that the list isn't updated automatically after setting the country.


----------



## Megameneer (Jan 27, 2016)

tobik said:


> Can you try setting the country in /etc/rc.conf?
> 
> ```
> ifconfig_wlan0="WPA DHCP country NL"
> ...


Ok, I changed the country in /etc/rc.conf and rebooted. After I ran `sudo ifconfig wlan0 scan` in a plain console (so outside of X), it gave the white-coloured message:

```
wpi0: fatal firmware error
```


----------



## asteriskRoss (Jan 28, 2016)

Megameneer said:


> According to the WifiAnalyzer app for Google Android, it uses channel 13.


Great -- so I hope if we can also configure your WiFi card to use channel 13 (which it wasn't before) then you will be able to connect, unless there are also other issues.



Megameneer said:


> I did as you do [...] So, does it mean I have to switch to a different operating system?


So, the good news is that you successfully managed to change country from US to Netherlands.  The bad news is that your WiFi card isn't reporting the additional channels I would expect (12, 13, 14).  Since these channels were available in Arch GNU/Linux, this cannot be an issue with your card.

I am mindful of wblock@'s comments regarding the `service netif restart` not playing well with WiFi cards; in fact this has caused my kernel to panic in the past when using a USB WiFi card.  tobik's suggestion of making the changes in /etc/rc.conf and rebooting is sensible.  However, I think we should try a slightly different configuration.  According to the man page for rc.conf(5):


> If a _wlans_*_*<_interface_>    variable is set, an wlan(4) interface
> will be created for each item in the list with    the _wlandev_
> argument set to _interface_.  Further wlan cloning arguments
> may be    passed to the ifconfig(8) *create* command by setting
> the _create_*_*_args_*_*<_interface_> variable.



I therefore suggest trying the following in /etc/rc.conf:

```
wlans_wpi0="wlan0"
create_args_wpi0="country Netherlands"
ifconfig_wlan0="WPA DHCP"
```
And the following in /etc/wpa_supplicant.conf:

```
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel
network={
        ssid="triple checked this one"
        key_mgmt=WPA-PSK
        psk="triple checked this one too"
}
```
Then reboot and see where you end up.  Outputs of `ifconfig wlan0`, `ifconfig wlan0 list chan` and `ifconfig wlan0 scan` (forcing a foreground scan, mindful of tobik's helpful observation that the wpi(4) driver does not support background scanning) would be useful.  If you need to explore further, I see it is possible to generate more detailed debugging output with wlandebug(8) though I will say that I have never needed to do this.


----------



## Megameneer (Jan 28, 2016)

asteriskRoss said:


> Since these channels were available in Arch GNU/Linux, this cannot be an issue with your card.


I need to say that I use FreeBSD on my laptop with an onboard card and Arch GNU/Linux on my desktop with an USB card. So they do not use the same card.
However, when I put in the USB card, changed 
	
	



```
wlans_wpi0="wlan0"
```
 to 
	
	



```
wlans_run0="wlan0"
```
, rebooted and entered `sudo ifconfig wlan0 list chan` only display channels 1 to 11. Should I check with a Puppy GNU/Linux bootable CD-ROM if it is also an issue under GNU/Linux?


asteriskRoss said:


> I therefore suggest trying the following in /etc/rc.conf:
> 
> ```
> wlans_wpi0="wlan0"
> ...


Done that...


asteriskRoss said:


> And the following in /etc/wpa_supplicant.conf:
> 
> ```
> ctrl_interface=/var/run/wpa_supplicant
> ...


...done that (I also did the line 
	
	



```
ctrl_interface_group=wheel
```
 even though I didn't think it wasn't necessary, but at least I don't have to use sudo anymore)...


asteriskRoss said:


> Then reboot and see where you end up


...and done that. No connection. I will post the outputs in my following comment.


----------



## Megameneer (Jan 28, 2016)

Here are the outputs:


----------



## asteriskRoss (Jan 28, 2016)

In your screenshot, your WiFi card is still showing as configured for US region, though when you changed it by hand using `ifconfig wlan0 country Netherlands` it you said the command ran successfully.  I am confused.  I looked at the script that handles wireless network set up (relevant section starts line 1415) which seems to do what the man page for rc.conf(5) suggests and would read the create_args_wpi0 variable.  Perhaps you can try again changing the country by hand and checking that it is actually changing:
`ifconfig wlan0 down`
`ifconfig wlan0 country Netherlands`
`ifconfig wlan0 up`
`ifconfig wlan0` (post output)
`ifconfig wlan0 list chan` (post output)
`ifconfig wlan0 scan` (post output)


----------



## asteriskRoss (Jan 28, 2016)

Of course, if you could change the channel of the wireless access point to something between 1 and 11, I would expect everything would work fine...


----------



## Megameneer (Jan 28, 2016)

asteriskRoss said:


> ifconfig wlan0 down
> ifconfig wlan0 country Netherlands
> ifconfig wlan0 up
> ifconfig wlan0 (post output)


I did it in the console. Things start to get interesting, since I see a lot of more messages here:



 


asteriskRoss said:


> ifconfig wlan0 list chan (post output)





asteriskRoss said:


> ifconfig wlan0 scan (post output)


----------



## asteriskRoss (Jan 28, 2016)

Bad news, I am afraid.  I see there is PR 172706, which has not yet been fixed, reporting the same issue.  It also suggests using one of the channels available with the country as "US" (that is 1-11) as a work-around.

You mentioned you had another USB WiFi card.  Perhaps you could use that and change /etc/rc.conf to:

```
wlans_run0="wlan0"
create_args_run0="country Netherlands"
ifconfig_wlan0="WPA DHCP"
```

_Edit: Changed wpi0 to run0 in rc.conf excerpt_


----------



## Megameneer (Jan 28, 2016)

asteriskRoss said:


> Perhaps you could use that and change /etc/rc.conf to:


Before I did so, I noticed that I had to write 
	
	



```
create_args_wpi0="country Netherlands"
```
 instead of 
	
	



```
create_args="country Netherlands"
```
. So I tried it that way first. But still no success.
My other USB card didn't work as well, however, it did load normally. An odd thing is that I had to change the country by hand after boot to Netherlands. This card displayed even less channels, only 1 to 11. Quite odd, since it does work on Arch GNU/Linux.
So, what to do now? Lay my laptop to rest until my father will change to another router next year or when the bug has been fixed and install the new driver by hand? Or are there any other suggestions?


----------



## tobik@ (Jan 28, 2016)

Megameneer said:


> Lay my laptop to rest until my father will change to another router next year or when the bug has been fixed and install the new driver by hand?


Ask your father nicely to configure the router to use a channel <= 11. It's easy to do and clients should pick up the new channel automatically, so your father needn't worry that anything breaks 


Megameneer said:


> My other USB card didn't work as well, however, it did load normally. An odd thing is that I had to change the country by hand after boot to Netherlands. This card displayed even less channels, only 1 to 11. Quite odd, since it does work on Arch GNU/Linux.


Is buying another card an option for you? I have a card with an Atheros AR9285 chipset (ath_hal(4)) and can confirm that switching countries and using channel 13 work just fine.


----------



## asteriskRoss (Jan 28, 2016)

Megameneer said:


> So, what to do now? Lay my laptop to rest until my father will change to another router next year or when the bug has been fixed and install the new driver by hand? Or are there any other suggestions?


Erm... Assuming you don't have the skills and/or time to fix the bug with the wpi(4) driver yourself, I think I covered the obvious other option 


asteriskRoss said:


> I was going suggesting trying to change the channel on your father's router





asteriskRoss said:


> Humour me and try changing the channel on the access point.  Choose a number of 11 or lower.





asteriskRoss said:


> Of course, if you could change the channel of the wireless access point to something between 1 and 11, I would expect everything would work fine...





asteriskRoss said:


> It also suggests using one of the channels available with the country as "US" (that is 1-11) as a work-around.


Reconfiguring the access point to use a different channel is easy and is unlikely to affect any other device.  Your father wouldn't even notice if you did it without telling him   Even tobik agrees so it must be true!


----------

