WLAN Konfiguration mit NetworkManager
Konfigurieren der WLAN Verbindung
RaspiOS benötigt die Einstelung der WiFi localisation in raspi-config vor hinzufügen der Verbindung!
Netzwerkverbindung hinzufügen:
Als erstes den Namen des WLAN-Interfaces anzeigen lassen:
nmcli
Der con-name kann frei vergeben werden, dieser wird später bei allen Konfigurationen verwendet.
Die verwendetenSSID Befehle:anzeigen lassen:
nmcli cdev wifi
Die Verbindung hinzufügen (im Beispiel: con-name: home-wifi, SSID: myhomewifi):
nmcli con add type <network type>wifi con-name <connection name>home-wifi ifname <interface>wlan0 ssid <myhomewifi
Um eine versteckte Netzwerkverbindung hinzuzufügen wird hidden yes angefügt.
nmcli con add type wifi con-name home-wifi ifname wlan0 ssid> myhomewifi hidden yes
Einrichten von Anmeldedaten
Für WPA PSK folgendes hinzufügen:
nmcli con modify <connection name>home-wifi wifi-sec.key-mgmt wpa-psk
Hinzufügen des Passworts mit modify:
nmcli con modify <connection name>home-wifi wifi-sec.psk ptclptclmysecretpassword
Verbinden mit dem WLAN-Netzwerk
Verbindung einschalten:
nmcli con up <connectionhome-wifi
Verbindung testen:
nmcli con show <connection name>home-wifi
Der Wert connection.autoconnect-retries gibt an wieviele Verbindungsversuche durchgeführt werden. Ist der Wert -1 werden vier Versuche durchgeführt. Bei 0 werden unendliche Versuche durchgeführt.
Ändern der Anzahl Verbindungsversuche:
nmcli connection modify CONNECTION NAME connection.autoconnect-retries 0
VerbindungNetzwerkverbindung hinzufügen:
nmcli c add type wifi con-name CONNECTION NAME ifname INTERFACE ssid SSIDLet’s break it down:
c object stands for connection
add signifies that we’re adding a connection
type indicates the type of connection we’re adding, such as “wifi“
con-name lets us set a custom name for the network that we’d see in the connections list
ifname lets us choose the network interface to use
ssid is the name of the access point that we are connecting to
In our case, the network type would be “wifi” and the interface would be the interface for our wireless card. We can easily get our interface name by issuing the ifconfig command.
Alternatively, we can also type nmcli to see a detailed list of our network interfaces:
$ nmcliwlp61s0:"Intel 8265 / 8275"wifi (iwlwifi), 20:79:18:BD:97:32, hw, mtu 1500ip4 default...
In addition to that, we can also use nmcli to get the list of available SSIDs in real-time:
$ nmcli dev wifiIN-USE BSSID SSID MODE CHAN RATE SIGNAL BA>00:27:19:28:B2:F4 Tplink Infra 6 54 Mbit/s 72 ▂▄>E0:28:61:E6:6C:10 SAK75 Infra 10 270 Mbit/s 39 ▂▄>18:52:82:F5:53:D5 PTCL-BB Infra 2 130 Mbit/s 35 ▂▄>
However, the SSID of the hidden wireless access points wouldn’t show in the list because a hidden network doesn’t broadcast its SSID. For that reason, we need to get the SSID from the Wi-Fi router’s control panel. Once we have our interface name and SSID, we can use the above command to add the hidden Wi-Fi network:
$ nmcli c add type wifi con-name home-wifi ifname wlp61s0 ssid zConnection 'home-wifi' (0dfc98e2-be00-480c-bf1f-674b9b3403d8) successfully added.
Setting Up Credentialsentfernen
Entfernen Afterder theVerbindung networkmit is added, we can add credentials for the network. However, before we set the credentials, we should know the type of the credentials. We can get this information from the control panel of our router. Of course, the process would differ for different routers, so we can check our router’s manual for the instructions.
Once we have the password key type, we can add it to our network:delete:
$ nmcli con modify home-wifi wifi-sec.key-mgmt wpa-pskThe modify verb lets us configure an existing connection. Next, we specify the actual password for our Wi-Fi:
$ nmcli con modify home-wifi wifi-sec.psk ptclptclWith our credentials added, we’re now ready to connect to the network.
Connecting to the Network
We can connect to the network with the up verb:
$ nmcli con up home-wifiLet’s test our connectivity with ping:
$ ping -c 1 baeldung.comPING baeldung.com (172.66.40.248): 56 data bytes64 bytes from 172.66.40.248: icmp_seq=0 ttl=56 time=49.470 ms--- baeldung.com ping statistics ---1 packets transmitted, 1 packets received, 0% packet lossround-trip min/avg/max/stddev = 49.470/49.470/49.470/0.000 ms
Deleting the Connection
We can remove the connection from the system using the delete verb:
$nmcli con delete home-wifiConnection 'home-wifi' (0dfc98e2-be00-480c-bf1f-674b9b3403d8) successfully deleted.
Connecting to Hidden Network With a Single Command
Once we have a basic understanding of using nmcli, we can quickly connect to a hidden network with a single command:
$ nmcli dev wifi connect z password ptclptcl hidden yesDisable IPv6
To disable IPv6 using nmcli, find your connection's name, modify it to ipv6.method
"disabled", and then reconnect using nmcli
connection up. This permanently disables IPv6 for that specific connection until it is manually re-enabled.
Steps to disable IPv6
List your network connections to find the name of the connection you want to modify.
$
nmcli
connection show
Modify the connection to disable IPv6. Replace Example with the name of your connection.
$
nmcli
connection modify Example ipv6.method "disabled"
Restart the connection to apply the changes.
$
nmcli
connection up Example