1

I'm facing an issue where nmcli stops working on a custom rockchip controller.

When running nmcli dev wifi, I get no results so I had to start using iwlist scan. Is there something similar for nmcli d wifi connect?

I keep getting back No network with SSID '2KLIC Guests' found with nmcli.

This is the script I want to replace:

if [ -n "$2" ];then
  nmcli d wifi connect "$1" password "$2"
else
  nmcli d wifi connect "$1"
fi

Or maybe there is a command I can run to fix nmcli (it did return results at one point, seems it had its configurations changed while using AP mode).


Results of iwconfig wlan3:

wlan3     unassociated  Nickname:"<WIFI@REALTEK>"
          Mode:Auto  Frequency=2.412 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=0/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
3

You can connect through wpa_supplicant command , create a wpa_supplicant.conf file through wpa_passphrase command then connect:

touch /etc/wpa_supplicant/wpa_supplicant.conf
echo ctrl_interface=/run/wpa_supplicant > /etc/wpa_supplicant/wpa_supplicant.conf
echo update_config=1 >> /etc/wpa_supplicant/wpa_supplicant.conf
wpa_passphrase "Your_SSID" Your_PASSWORD >> /etc/wpa_supplicant/wpa_supplicant.conf
i=$(iw dev | grep Interface | awk '{ print $2}')
killall wpa_supplicant
wpa_supplicant -i $i -c/etc/wpa_supplicant/wpa_supplicant.conf -B
dhclient $i

A sample script may contain the following lines:

i=$(iw dev | grep Interface | awk '{ print $2}')
killall wpa_supplicant
wpa_supplicant -i $i -c/etc/wpa_supplicant/wpa_supplicant.conf -B
dhclient $i

The killall wpa_supplicant is added because you are using network-manager , it will create a wpa_supplicant instance.

Also you can connect through wpa_supplicant using a WEP key.

Create a wpa_supplicant.conf manually (wpa_passphrase will not work to generate a conf file) , e,g:

ctrl_interface=/run/wpa_supplicant
update_config=1

network={
    ssid="YOUR-SSID"
    key_mgmt=NONE
    wep_key0="12345"
    wep_tx_keyidx=0
}

Or simply you can connect through :

iwconfig <interface> essid "Your_SSID" key WEP_KEY

or:

iw dev <interface> connect "Your_SSID" key 0:WEP_KEY

The wpa_cli command line tool (recommanded by @dirkt) is also an alternative to nmcli , you can use the interactive mode by typing wpa_cli or directly by:

wpa_cli -p/var/run/wpa_supplicant OPTION

The OPTION can be : scan ; scan_results , add_network 0 ..... see man wpa_cli and wpa_cli --help for more details.

  • Thanks, I can't test right now but I will asap. I assume this solution will fail on WEP? – Philip Kirkbride Oct 27 '17 at 18:20
  • 2
    Wpa_supplicant support WEP ; WPA and WPA2 – GAD3R Oct 27 '17 at 18:21
  • I have update my answer, a WEP key is supposed weak and unsecured – GAD3R Oct 27 '17 at 18:48
  • 1
    In addition, it's also possible to use wpa_cli to add networks from the command line or in a script if this is more convenient than making a configuration file. wpa_cli help lists the commands (more than mentioned in the documentation). – dirkt Oct 27 '17 at 20:59
  • 1
    @GAD3R just one, I found people on Pi having a similar issue using iw raspberrypi.stackexchange.com/questions/39601/… I can use iwlist but not iw for some reason. Opened another question related unix.stackexchange.com/questions/401413/… – Philip Kirkbride Oct 30 '17 at 14:31
1

I ended up replacing my script with this. Seems to work on my system and keeps the original structure.

wifi=$(cat /proc/net/wireless | perl -ne '/(\w+):/ && print $1')

if [ -n "$2" ];then
  iwconfig $wifi essid "$1" key "s:$2"
else
  iwconfig $wifi essid "$1" key
fi

dhclient $wifi
  • 2
    This will not work for WPA, only for WEP. I strongly recommend against using WEP, it's broken. – dirkt Nov 15 '17 at 16:29
  • WEP is broken as in "people will break the password and look at your traffic or use your AP" – A.B Mar 17 at 16:32
0

You can use Wicd, it has a command line and GUI interface for managing your wifi networking. I have used it for a while, as a lightweight alternative to NM. It will save you of having to deal with wpa_supplicant manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.