3

There is info on how to connect to ethernet(eth0) with nmcli using a static IP, but nothing on how to connect to wifi (wlan0)?
This sets up a connection profile but how to add the password and actually bring up the connection?

nmcli con add con-name "mySSID" ifname wlan0 type wifi ssid "mySSID" ip4 192.168.100.101
1

NOTE: The following is only guaranteed to work with nmcli v1.22 (because that's what version I have), the latest is probably very similar but, in my case there's a random -- required; it is in the documentation specified for that command. Check your version with nmcli -v then check the specific documentation here >>Network Manager (after you click your version click the nmcli link)

I.e., for Version 1.2

nmcli con add con-name "&%TEST%&" type wifi ifname mlan0 ssid "&%SSIDNAME%&" -- wifi-sec.key-mgmt wpa-psk wifi-sec.psk "&%PASSPHRASE%&" ipv4.method manual ipv4.address 192.168.1.51/16 ipv4.dns 8.8.8.8,8.8.8.4 ipv4.gateway 192.168.1.1

Then

nmcli con up "&%TEST%&"

However, it may be more wise to ignore the con-name because you can have multiple connections with the same name. (Luckily nmcli con delete "&%TEST%& deletes all of those at once!)

You could use the uuid instead.

find it by nmcli con show then connect using

nmcli con up uuid 1c86c960-8533-11e7-bb31-be2e44b06b34 (*your uuid will not be the same...)

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.