Solved Setting up WLAN ready to connect without connecting at boot

Hello,

I would like the WLAN interface on my laptop to be down by default but ready to connect to my network with a simple ifconfig wlan0 up.

Everything works as expected with the following configuration:

/etc/rc.conf
Code:
wlans_iwn0="wlan0"
ifconfig_wlan0="WPA DHCP country CH"

/etc/wpa_supplicant.conf
Code:
network={
 ssid="myssid"
 psk="mypsk"
 priority=1
}

... but that automatically connects the interface at boot, which is not what I want.

So, I tried to use NOAUTO:
Code:
ifconfig_wlan0="WPA DHCP NOAUTO country CH"

As expected, no automatic connection occurs.

However, when turning on the interface with ifconfig wlan0 up, the computer doesn't connect to the SSID set in wpa_supplicant.conf but to a random unprotected network in the neighbourhood. It seems that wpa_supplicant is not called when starting the interface manually.

What could I do?
 
With a low priority set to that particular network, the computer keeps trying to connect to various networks without any success (all other networks in the area are protected). I think the problem is the missing call of wpa_supplicant, which prevents connection to the correct network, therefore the fallback to other available networks.

Thank you for pointing to this bug report, I'll add information there.
 
In the meanwhile, I use the following workaround:

* don't create wlan0 at boot, so I removed wlans_iwn0="wlan0" from /etc/rc.conf

* aliases to easily enable and disable the WLAN interface:

~/.shrc
Code:
alias wlan-on='sudo ifconfig wlan0 create wlandev iwn0 && sudo service netif restart'
alias wlan-off='sudo ifconfig wlan0 destroy && sudo service netif restart'
 
Thank you! That's exactly what I was looking for. I didn't know you can add an argument to service netif start, I thought you could only start/stop/restart etc. the whole networking that way, not a specific interface.

This example case would be a good addition to the handbook, which neither mentions such a use of service (service(8) and rc(8) don't either and there is no manpage for netif), nor the use of NOAUTO in network configuration. I'll probably submit something to the doc team.

Do you know other services which accept such extra arguments like service xyz start argument? That's the first time I ever meet one.
 
Do you know other services which accept such extra arguments
service dhclient stop wlan0
service dhclient restart em1

You can find the interface names in the directory /var/db/
(For my example interface)
/var/db/dhclient.leases.em1
You might also find stale or removed interface names possible in the directory.

ps -ax will also show the active individual dhclient processes.
555 - Is 0:00.00 dhclient: em1 [priv] (dhclient)
 
Do you know other services which accept such extra arguments
jail.

edit: I'm not sure this would be a good addition to the handbook. IMHO, the handbook is for end-users and administrators, guiding them through the most common tasks, anything beyond should better be limited to reference-style docs. But maybe, the "doc people" have a different opinion on that ;)

As for the reference docs, NOAUTO is documented where I would expect it: in rc.conf(5). I indeed couldn't find docs for command-arguments supported by some init scripts like netif on a quick search. Maybe they are missing and should be added (but IMHO either in comments on the top of these init-scripts or in manpages).
 
Was also curious, searched and hoped it was somewhere in the man pages. It occurs in the FreeBSD Handbook but in the section for Bluetooth in 32.5.1. Loading Bluetooth Support where it occurs in an example block:
Code:
# service bluetooth start ubt0
Absolutely FreeBSD by Micheal Lucas gives a netif example on page 149.

As stated service(8) does not mention it, but that is non-specific where it concerns the rc.d script of netif. I agree it should be mentioned somewhere in the man pages. Also a good extra possibility, IMHO, would be as an addition to the more netif specific usage message that is triggered as a result of service netif help.
 
It would be nice to have the dhclient manual updated with an EXAMPLE section. Show per interface usage.
For me examples are the best guides. All our manpages need them when possible.
 
Back
Top