Skip to content

Setting up WIFI using nmcli

Hecatron edited this page Jun 20, 2020 · 1 revision

If you want to get wifi working within the SD card for gentoo for the rpi.
One approach is to add a section to the startup.sh file in the boot partition.
This has the advantage of being accessible from a separate windows or linux device since the boot partition is FAT formatted, so can be done headless.

As an example

echo "Setting up WiFi with automatically assigned address..."
nmcli con del "MyWiFi-DHCP-IP"
nmcli con add con-name "MyWiFi-DHCP-IP" type wifi \
  ifname wlan0 ssid "MY-SSID-GOES-HERE" -- \
  wifi-sec.key-mgmt wpa-psk \
  wifi-sec.psk "MY-WIFI-PASSWORD-GOES-HERE" \
  ipv4.method auto
nmcli con up "MyWiFi-DHCP-IP"

The two main values to fill in are the "MY-SSID-GOES-HERE" and "MY-WIFI-PASSWORD-GOES-HERE"

To list the active connections

nmcli connection show --active

# Results
MyWiFi-DHCP-IP  2098f0f5-04f8-4b11-b308-138c4be9b5f5  wifi  wlan0

To show the connection details

nmcli connection show id MyWiFi-DHCP-IP

# Results
connection.id:                          MyWiFi-DHCP-IP
connection.uuid:                        2098f0f5-04f8-4b11-b308-138c4be9b5f5
connection.stable-id:                   --
connection.type:                        802-11-wireless
connection.id:                          MyWiFi-DHCP-IP
connection.uuid:                        2098f0f5-04f8-4b11-b308-138c4be9b5f5
connection.stable-id:                   --
connection.type:                        802-11-wireless
connection.interface-name:              wlan0
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
...
Clone this wiki locally