15

I have a problem with the wpa_supplicant program.

My problem is about the use of wpa_cli which needs wpa_supplicant. Error when I'm executing sudo wpa_cli:

Could not connect to wpa_supplicant

The manual start of wpa_supplicant gives me some errors:

sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

rfkill: Cannot open RFKILL control device
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
wlan0: CTRL-EVENT-DISCONNECTED bssid=00:00:00:00:00:00 reason=0   ### NEW!!!

Config dhcp

## /etc/dhcp/dhcpd.conf
subnet 192.168.2.0 netmask 255.255.255.0 {
   range 192.168.2.2 192.168.2.9;
   option domain-name-servers 192.168.1.1;
   option domain-name "home";
   option routers 192.168.2.1;
}

Config wpa_supplicant

## /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
# network={
#   ssid="__SSID__"
#   key_mgmt=WPA-PSK
#   psk="__PASS__"
#   id_str="home"
# }

Config hostapd

## /etc/hostapd/hostapd.conf
interface=wlan0
driver=rtl871xdrv
ieee80211n=1
ssid=__SSID__
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=__PASS__
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

# EDIT
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0

Results of ifconfig / iwconfig

wlan0   Link encap:Ethernet  HWaddr c0:4a:00:17:40:fd
          inet adr:192.168.2.1  Bcast:192.168.2.255  Masque:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     IEEE 802.11bgn  ESSID:"__SSID__"  Nickname:"<WIFI@REALTEK>"
          Mode:Master  Frequency:2.412 GHz  Access Point: C0:4A:00:17:40:FD
          Sensitivity:0/0
          Retry:off   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=100/100  Signal level=0 dBm  Noise level=0 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

How can I start wpa_supplicant without errors and have wpa_cli connect?

2 Answers 2

8

The errors wpa_supplicant produces are not necessarily related to your wpa_cli connection problem. The trouble here is that wpa_cli is unable to establish connection with wpa_supplicant - unable to open the control socket. This can have several causes:

  1. user running wpa_cli is unable to access the socket given e.g. in wpa_supplicant.conf:

    ctrl_interface=DIR=/var/run/wpa_supplicant
    

    You need to check that files in that directory are accessible to the user under which wpa_cli runs. That means not just the sockets being rw - all above directories have to be at least x, the last one probably also r so that wpa_clie can list all available sockets.

  2. Unlike wpa_supplicant, wpa_cli is not DBus capable. Make sure wpa_supplicant is not listening via DBus only. Judging by your configuration files this is probably not your case.

  3. wpa_supplicant not running (as per comments below). This would indicate, that there indeed might be a connection between the error messages emitted by wpa_supplicant and not being able to connect to it. To make sure run it in verbose mode (-d or even -dd) and not daemonizing (which is the default - just make sure you are not using the -B option). You can also watch out for the control socket, e.g.:

    watch -n 0.1 "ls -al /var/run/wpa_supplicant"
    

    Remember that most of these commands need to be run with root privileges, so for debugging it might be easier to just su - root permanently rather than prefixing each command with sudo.

9
  • Thanks for your answer. About your first point, I have to tell you that the file /var/run/wpa_supplicant does not exist.. Do you think this is the problem ?
    – Val
    Feb 7, 2014 at 20:50
  • 1
    It is created by wpa_supplicant when needed. If it doesn't exist while it is running, then option 2 suddenly becomes more likely. :)
    – peterph
    Feb 7, 2014 at 20:57
  • Okay, but I don't really know how to apply your option 2.. You're sepaking about a "main application", but I'm just using the commands I spoke about wpa_cli and wpa_supplicant, and I don't know how to avoid dbus only.. I had to tell you that rfkill list is giving me errors too (if it's related) "Can't open RFKILL device: No such file or directory".. I'm really lost
    – Val
    Feb 7, 2014 at 21:01
  • 1
    main applicatin = wpa_supplicant - I've fixed it, it was a bit misleading indeed. Socket: check lsof | grep wpa_supplicant (when you have it running) - it should show you the open socket. As for rfkill - is /dev/rfkill accessible for the user running rfkill?
    – peterph
    Feb 7, 2014 at 21:16
  • I tried the lsof | grep wpa_supplicant command, but it doesn't return a result. Btw, I think my problem is that wpa_supplicant is not starting.. I tried a ps -e | grep wpa and it's empty too. About rfkill, /dev/rfkill doesn't exist for me..
    – Val
    Feb 7, 2014 at 21:23
5

Finally, the written errors didn't affect the system.

My /etc/network/interfaces file looks like (only wlan part) :

iface wlan0 inet static
    address 192.168.2.1
    netmask 255.255.255.0
    pre-up wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B

With this config, I can use the sudo wpa_cli command without error !
Thanks to peterph anyway :) !

1
  • I was looking for this for hours. The last line fixed my problem. Thanks.
    – mehrmoudi
    Oct 22, 2015 at 17:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .