# wpa_supplicant



## talin (May 8, 2013)

Hello!

I have defined a few networks in my wpa_supplicant.conf. My problem is that my laptop keeps preferring a "guest" network in the office. So it's quite random whether I have a network connection in meetings. I need to way to block that particular network, or to force wpa_supplicant to use only networks that are defined in my wpa_supplicant.conf.

Any ideas?


----------



## strontium90 (May 8, 2013)

You might be able to indicate your preferred networks via the priority parameter in network configuration blocks of /etc/wpa_supplicant.conf. To quote wpa_supplicant.conf(5):

```
priority
	     The priority of a network when selecting among multiple networks;
	     a higher value means a network is more desirable.	By default
	     networks have priority 0.	When multiple networks with the same
	     priority are considered for selection, other information such as
	     security policy and signal strength are used to select one.
```


----------



## talin (May 8, 2013)

Yes, I tried setting it with priority 0 whereas the other networks have priority 5. The "guest" network still gets picked 80% of the time. I suppose the signal strength is better.


----------



## talin (May 8, 2013)

Now I am in an area with ~20 networks. Since wpa_supplicant picks at random, there is a 5% chance that I will connect to the right network.


----------



## talin (May 10, 2013)

Would it be possible to block the MAC-address of the access points I don't want to connect to using pf, as a last resort, just to get it working?


----------



## talin (May 15, 2013)

After running `wpa_supplicant` with -d, I discovered that I had a network block that was defined with psk="". Apparently wpa_supplicant considers this an error, so it silently skips the rest of the file. 

It works now. Thank you for the help!


----------



## wblock@ (May 17, 2013)

That sounds like a bug to me.  Please enter a PR.


----------



## fonz (May 17, 2013)

wblock@ said:
			
		

> That sounds like a bug to me.


I'm not sure. According to wpa_supplicant.conf(5):

```
[u]psk[/u]     WPA preshared key used in WPA-PSK mode. The key is specified as
             64 hex digits or as an 8-63 character ASCII passphrase.
```
Apparently, if an empty key is needed this has to be specified differently. If I remember correctly, it's

```
key_mgmt=NONE
```
I'm not entirely certain, but I suspect that rejecting

```
psk=""
```
might actually be correct behaviour.


----------



## kpa (May 17, 2013)

This is definitely an error:

```
psk=""
```

From /usr/share/examples/etc/wpa_supplicant.conf:

```
psk: WPA preshared key; 256-bit pre-shared key
# The key used in WPA-PSK mode can be entered either as 64 hex-digits, i.e.,
# 32 bytes or as an ASCII passphrase (in which case, the real PSK will be
# generated using the passphrase and SSID). ASCII passphrase must be between
# 8 and 63 characters (inclusive).
```


----------



## wblock@ (May 18, 2013)

If it rejects an invalid PSK silently and then ignores the rest of the file, that's a bug.  It should at least complain about invalid options (pretty sure it does) and either report that it stopped or not stop.


----------

