# wpa_supplicant.conf not being processed from rc.conf



## choppy812 (Jul 10, 2019)

If I reboot and "service netif restart", my RTL8192CU will connect to a random available network, but will not get an IP address.  It seems to not be looking at wpa_supplicant.conf.

If I reboot and do "wpa_supplicant -i _wlan0_ -c /etc/wpa_supplicant.conf", I will connect to the network specified in wpa_supplicant and get an IP address. However, even though things work, the terminal is not returned to me, and there's a line that reads, "Failed..." as seen here.


```
# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
Successfully initialized wpa_supplicant
wlan0: Trying to associate with 00:71:c2:92:34:b0 (SSID='WORK-2.4' freq=2437 MHz)
Failed to add supported operating classes IE
wlan0: Associated with 00:71:c2:92:34:b0
wlan0: WPA: Key negotiation completed with 00:71:c2:92:34:b0 [PTK=CCMP GTK=TKIP]
wlan0: CTRL-EVENT-CONNECTED - Connection to 00:71:c2:92:34:b0 completed [id=0 id_str=]
```


```
---/etc/rc.conf---
wlans_rtwn0="wlan0"
ifconfig_wlan0="DHCP"
```


```
---/etc/wpa_supplicant.conf---
network={
    ssid="WORK-2.4"
    key_mgmt=WPA-PSK
    psk="...password..."
}
```


```
---/boot/loader.conf---
urtwn-rtl8192cfwT_load="YES"
urtwn-rtl8192cfwU_load="YES"
if_rtwn_pci_load="YES"
if_rtwn_usb_load="YES"
#if_rtwn_load="YES"
legal.realtek.license_ack=1
wlan_ccmp_load="YES"
wlan_tkip_load="YES"
```


```
$ ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether 74:da:38:ef:f0:14
    inet 10.1.10.102 netmask 0xffffff00 broadcast 10.1.10.255
    groups: wlan
    ssid WORK-2.4 channel 6 (2437 MHz 11g ht/20) bssid 00:71:c2:92:34:b0
    regdomain FCC country US authmode WPA2/802.11i privacy ON
    deftxkey UNDEF TKIP 2:128-bit TKIP 3:128-bit txpower 30 bmiss 7
    scanvalid 60 protmode CTS ht20 ampdulimit 64k ampdudensity 8 shortgi
    -stbc -ldpc wme roaming MANUAL
    media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
    status: associated
    nd6 options=2b<PERFORMNUD,ACCEPT_RTADV,IFDISABLED,AUTO_LINKLOCAL>
```


```
FreeBSD myFreeBSD.mydomain 12.0-RELEASE-p7 FreeBSD 12.0-RELEASE-p7 GENERIC  amd64
```


----------



## ljboiler (Jul 11, 2019)

Try *ifconfig_wlan0="WPA DHCP"*; that should automatically start wpa_supplicant in the background when the interface is created.


----------



## SirDice (Jul 11, 2019)

Yep, the key here being WPA in `ifconfig_wlan0`. Without it the system simply doesn't know you want to use wpa_supplicant(8), and thus doesn't start it.


----------



## rpowell47 (Jul 14, 2019)

choppy812 said:


> If I reboot and "service netif restart", my RTL8192CU will connect to a random available network, but will not get an IP address.  It seems to not be looking at wpa_supplicant.conf.
> 
> If I reboot and do "wpa_supplicant -i _wlan0_ -c /etc/wpa_supplicant.conf", I will connect to the network specified in wpa_supplicant and get an IP address. However, even though things work, the terminal is not returned to me, and there's a line that reads, "Failed..." as seen here.
> 
> ...


In your boot/loader.conf
Add:
rtwnfw_load=“YES”

Or

urtwnfw_load=“YES”


----------



## choppy812 (Jul 18, 2019)

Changes made and still not working. I noticed when I went to the office, I was able to connect without problems to that wifi network. So the problem seems to be that the dongle or FreeBSD doesn't like my router at my home office. If I use the dongle on my OpenBSD laptop at my home office, it connects fine to my home wifi.

I noticed on bootup that there was a hang on DHCPDISCOVER after wlan0 came up. So I logged in, killed dhclient and tried dhclient wlan0... same result.

I have a Linksys WRT3200ACM router with dd-wrt firmware. Not sure how to move forward in figuring this out.


```
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether 74:da:38:ef:f0:14
    inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255 
    groups: wlan 
    ssid WORK-2.4 channel 9 (2452 MHz 11g ht/20) bssid 24:f5:a2:2d:ff:db
    regdomain FCC country US authmode WPA2/802.11i privacy ON
    deftxkey UNDEF AES-CCM 3:128-bit txpower 30 bmiss 7 scanvalid 60
    protmode CTS ht20 ampdulimit 64k ampdudensity 4 shortgi -stbc -ldpc
    wme roaming MANUAL
    media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
    status: associated
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
root@idea5:~ # killall dhclient
root@idea5:~ # dhclient wlan0
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 13
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 9
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 15
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 1
No DHCPOFFERS received.
No working leases in persistent database - sleeping
```


```
----------/etc/rc.conf------------
wlans_rtwn0="wlan0"
ifconfig_wlan0="WPA SYNCDHCP"
```


```
wlan_ccmp_load="YES"
wlan_tkip_load="YES"
rtwnfw_load="YES"
legal.realtek.license_ack=1
if_rtwn_pci_load="YES"
if_rtwn_usb_load="YES"
```


----------



## choppy812 (Jul 18, 2019)

I take that back... the wifi dongle doesn't work on OpenBSD either; it works, but it associates with a neighbors network. My router's DHCP server works well for wired NICs on Free- and OpenBSD, and it serves up IPs for wifi cards on Linux and windows. I know my password is correct (using simple pass in wpa_supplicant).


----------



## SirDice (Jul 19, 2019)

choppy812 said:


> So the problem seems to be that the dongle or FreeBSD doesn't like my router at my home office.


Did you perhaps enable MAC address filtering on your wireless access point?


----------



## choppy812 (Jul 20, 2019)

No filtering. It works if I use it on a Windows machine. 





SirDice said:


> Did you perhaps enable MAC address filtering on your wireless access point?


----------



## choppy812 (Aug 3, 2019)

I've tooled around with this a lot -- reinstalled FreeBSD 12 Release and started from scratch. I think I have it fixed. I removed wlan_tkip_load="YES" from /boot/loader.conf and left only wlan_ccmp_load="YES" there. This did the trick on reboot.

I'm also explicitly loading all the firmwares in loader.conf and still need to start removing some... pretty sure I don't need to have them all there.


```
# /boot/loader.conf

# per FreeBSD Handbook, 31.3
wlan_ccmp_load="YES"
#wlan_tkip_load="YES"

# per 'man rtwn' for usb edimax EW-7722UTn V2 (rtl8192CU)
# see also 'man rtwn', 'man rtwn_usb', 'man rtwnfw'
# see sysctl dev.rtwn for tuneables (and 'man rtwn')
# rtwn_usb does not support any of the 802.11ac capabilites
# of the adapter. (more work needed).

if_rtwn_usb_load="YES"

# per 'man rtwnfw' can load all firmware images here
# some are not for my usb adapter,
rtwn-rtl8188eufw_load="YES"
rtwn-rtl8192cfwE_B_load="YES"
rtwn-rtl8192cfwE_load="YES"
rtwn-rtl8192cfwT_load="YES"
rtwn-rtl8192cfwU_load="YES"
rtwn-rtl8192eufw_load="YES"
rtwn-rtl8812aufw_load="YES"
rtwn-rtl8821aufw_load="YES"

# per 'man rtwnfw', legal for RealTek
legal.realtek.license_ack=1
```



```
# /etc/rc.conf

# my setup with Edimax
wlans_rtwn0="wlan0"
ifconfig_wlan0="WPA DHCP"
```


```
# /etc/wpa_supplicant.conf
network={
    ssid="my_wifi_network"
    psk="my_literal_password_in_quotes"
}
```


----------



## rpowell47 (Aug 3, 2019)

choppy812 said:


> I take that back... the wifi dongle doesn't work on OpenBSD either; it works, but it associates with a neighbors network. My router's DHCP server works well for wired NICs on Free- and OpenBSD, and it serves up IPs for wifi cards on Linux and windows. I know my password is correct (using simple pass in wpa_supplicant).




Try loading pkg wifimgr then open it see what it has detected and click the reconnect and save button. After that view your wpa_supplicant.conf file for any change. You may find the answer there.


----------



## choppy812 (Sep 12, 2019)

This is an older thread by now, but thought I would clarify for anyone reading it, the problem for me is DD-WRT and OpenWRT router firmwares. 

If I return to Linksys firmware on the wrt3200acm, I can connect with the Edimax EW-7722UTn V2 (urtwn).

I have yet to try wifimgr as suggested by rpowell47.  I'll likely just look for a new wifi dongle, but here are the responses I get when plugging it in and running "wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf"


```
Successfully initialized wpa_supplicant
wlan0: Trying to associate with 24:f5:a2:2d:ff:db (SSID='home-wifi' freq=2452 MHz)
Failed to add supported operating classes IE

wlan0: Authentication with 24:f5:a2:2d:ff:db timed out.
wlan0: CTRL-EVENT-DISCONNECTED bssid=24:f5:a2:2d:ff:db reason=3 locally_generated=1
ioctl[SIOCS80211, op=103, val=0, arg_len=128]: Operation now in progress
wlan0: CTRL-EVENT-SCAN-FAILED ret=-1 retry=1
ioctl[SIOCS80211, op=103, val=0, arg_len=128]: Operation now in progress
wlan0: CTRL-EVENT-SCAN-FAILED ret=-1 retry=1
wlan0: Trying to associate with 24:f5:a2:2d:ff:db (SSID='home-wifi' freq=2452 MHz)
Failed to add supported operating classes IE
wlan0: Associated with 24:f5:a2:2d:ff:db
wlan0: WPA: Invalid EAPOL-Key MIC when using TPTK - ignoring TPTK
wlan0: WPA: Could not verify EAPOL-Key MIC - dropping packet
;
wlan0: Authentication with 24:f5:a2:2d:ff:db timed out.
wlan0: CTRL-EVENT-DISCONNECTED bssid=24:f5:a2:2d:ff:db reason=3 locally_generated=1
wlan0: WPA: 4-Way Handshake failed - pre-shared key may be incorrect
wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="home-wifi" auth_failures=1 duration=10 reason=WRONG_KEY
wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="home-wifi" auth_failures=2 duration=31 reason=CONN_FAILED
wlan0: CTRL-EVENT-DISCONNECTED bssid=24:f5:a2:2d:ff:db reason=3 locally_generated=1
wlan0: CTRL-EVENT-DISCONNECTED bssid=24:f5:a2:2d:ff:db reason=3 locally_generated=1
wlan0: CTRL-EVENT-DISCONNECTED bssid=24:f5:a2:2d:ff:db reason=3 locally_generated=1
wlan0: CTRL-EVENT-DISCONNECTED bssid=24:f5:a2:2d:ff:db reason=3 locally_generated=1
wlan0: CTRL-EVENT-SSID-REENABLED id=0 ssid="home-wifi"
wlan0: Trying to associate with 24:f5:a2:2d:ff:db (SSID='home-wifi' freq=2452 MHz)
Failed to add supported operating classes IE
wlan0: Associated with 24:f5:a2:2d:ff:db
wlan0: CTRL-EVENT-DISCONNECTED bssid=24:f5:a2:2d:ff:db reason=0
wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="home-wifi" auth_failures=3 duration=30 reason=CONN_FAILED
wlan0: CTRL-EVENT-DISCONNECTED bssid=24:f5:a2:2d:ff:db reason=3 locally_generated=1
wlan0: CTRL-EVENT-TERMINATING
```


----------



## jbowen (Jan 20, 2020)

I know this thread is a few months old, but what is the issue with OpenWRT firmware? I ran into this issue after a fresh install of FreeBSD 12.1 Release and also have a WRT3200ACM running OpenWRT (19.07.0).

I'm able to connect a bunch of Android/Linux devices just fine.


----------

