# Prevent wlan0 from auto-connecting to any open access point



## ngxw (Mar 4, 2017)

(reposting from freebsd-wireless@:
https://lists.freebsd.org/pipermail/freebsd-wireless/2017-March/007543.html)

Hi, I have a pretty basic question, but was unable to find any useful
answer in the Handbook or man pages.

I would like to prevent a USB Wifi card from automatically connecting
to an unencrypted network nearby.  It happens whenever the card is
plugged to the USB port and the wlan0 interface is brought up.  After
a few seconds it's connected to the first unencrypted net it can find.
How could it be stopped?

Thanks for help!

Stefan


freebsd-version:
11.0-RELEASE-p8

rc.conf:

```
wlans_urtw0="wlan0"
ifconfig_wlan0="NOAUTO"
ifconfig_urtw0="NOAUTO"
```

dmesg:

```
ugen0.2: <vendor 0x0bda> at usbus0
urtw0: <vendor 0x0bda product 0x8187, class 0/0, rev 2.00/1.00, addr 4> on usbus0
urtw0: unknown RTL8187L type: 0x8000000
urtw0: rtl8187l rf rtl8225u hwrev none
wlan0: Ethernet address: xx:xx:xx:xx:xx:xx
wlan0: link state changed to UP
```


----------



## Phishfry (Mar 4, 2017)

Instead of  "NOAUTO" what if you used this instead:

`ifconfig_wlan0="WPA"`
or more commonly used:
`ifconfig_wlan0="WPA DHCP"`

In fact I have no idea where you came up with "NOAUTO" as a setting. I am not seeing it in the manual.
https://www.freebsd.org/cgi/man.cgi?ifconfig(8)

edit-
Well looks like I was wrong. There is a post with the command:
https://forums.freebsd.org/threads/44956/#post-250815
Looking at the last thread it might not work now.


----------



## Kiiski (Mar 5, 2017)

Hi

 According to rc.conf(8) and network_interfaces section
 "NOAUTO" should work, but if I understood correctly it is not what you are after.


----------



## G4 (Apr 9, 2021)

Reviving this old thread, hoping that someone knows about a modern, working solution to the OP's question.

Any ideas?
Thanks!


----------



## grahamperrin@ (Apr 10, 2021)

Kiiski said:


> … rc.conf(8) …


… should be rc.conf(5)

Here, with FreeBSD 14.0-CURRENT: 


```
create_args_wlan0="country GB regdomain etsi"
wlans_iwn0="wlan0"
ifconfig_wlan0="NOAUTO WPA SYNCDHCP"
```

I added `NOAUTO` today
to the best of my recollection, I never found this notebook unexpectedly connected to a _non-encrypted_ wireless network.
(There's a wifi guest service at my place of work, which is _secure_ … rewind a couple of years or so, I vaguely recall people being unexpectedly joined to the service. Don't recall it happening to me, with FreeBSD.)

I'll try to find a non-encrypted network, for a proper test.


----------



## aragats (Apr 10, 2021)

As far as I remember the installer adds to /etc/wpa_supplicant.conf a section with:
	
	



```
network={
....
key_mgmt=NONE
}
```
That's why even if you configure WiFi with "WPA", it still will try to connect to open networks. Just remove/comment out this section as I do.


----------



## grahamperrin@ (Apr 10, 2021)

Thanks! I found this section in my file: 


```
network={
        ssid="go-brighton"
        bssid=04:f0:21:1a:63:8e
        key_mgmt=NONE
}
```

– not from installation, but from choosing to use Wi-Fi on Brighton & Hove Buses. So long ago that I can't remember how I made the connection. I wouldn't have written the file manually, I probably used the net-mgmt/networkmgr GUI.


----------



## grahamperrin@ (Sep 6, 2021)

Kiiski said:


> … "NOAUTO" should work, but if I understood correctly it is not what you are after.



FreeBSD bug 256957 – Wi-Fi: rc.conf(5) NOAUTO, ifconfig(8) up and unwanted WLAN connections to open networks


----------

