Tuesday, May 24, 2022

Setting up Wi-Fi on Linux Hosts using NetworkManager Client on Command Line

This is a note about setting up Wi-Fi interface on Linux hosts using NetworkManager client on the command line.

  1. The first step is to figure out the name of the Wi-Fi interface. For this, we can use the nmcli device command, e.g.,
    
    $ nmcli device
    DEVICE          TYPE      STATE         CONNECTION
    wlp5s0          wifi      disconnected  --
    p2p-dev-wlp5s0  wifi-p2p  disconnected  --
    
    where wlp5s0 is the Wi-Fi interface. Below we use this name in our examples and should replace it with the actual interface name.

  2. For a Wi-Fi interface, we can create connection profiles to connect to Wi-Fi Access Points. In the following, we assume that
    • the Wi-Fi interface name is wlp5s0,
    • we name the Wi-Fi connection profile HomeWiFi5GhzConnection,
    • the ssid of the Access Point that the Wi-Fi interface connects to is WiFiAp5GHz,
    • the Access Point does not broadcast ssid, i.e., is hidden, and
    • the Access Point is configured to use the WPA-PSK security protocol, and the PSK password is "ThisPasswordIsDumb".
    , which we should replace with actual ones.

    We create the connection profile,
    sudo nmcli connection add type wifi con-name HomeWiFi5GhzConnection ifname wlp5s0 ssid WiFiAp5GHz
    sudo nmcli connection modify HomeWiFi5GhzConnection wifi-sec.key-mgmt wpa-psk
    sudo nmcli connection modify HomeWiFi5GhzConnection wifi-sec.psk ThisPasswordIsDumb
    sudo nmcli connection modify HomeWiFi5GhzConnection 802-11-wireless.hidden yes
    
  3. Finally, to connect to the Wi-Fi access point using the connection profile, use the nmcli connection up command, e.g.,
    sudo nmcli connection up HomeWiFi5GhzConnection    
    

No comments:

Post a Comment