Wireless Networking Setup on Raspberry Pi Using Command Line
This comprehensive guide will walk you through setting up a wireless connection on your Raspberry Pi using the command line interface.
This method is versatile and should work for various security protocols, including WEP, WPA, WPA2, and WPA3.
Enable Wireless Networking
Before configuring your Wi-Fi, ensure the wireless radio is enabled and set the correct country code to comply with local regulations:
Set WLAN Country: Open the raspi-config
tool to set your country for wireless networking.
Navigate to Localisation Options
> WLAN Country
and select your country.
Check Wi-Fi Status: Verify if the Wi-Fi radio is enabled.
If it returns disabled
, enable it:
Finding Networks
Scan for available Wi-Fi networks:
This command displays a list of available networks. Identify the SSID (network name) you wish to connect to.
Connect to a Network
Secured Network
To connect to a secured network:
Replace <example_ssid>
with your network's SSID. You will be prompted to enter the network password.
Unsecured Network
For an unsecured network:
Hidden Network
For a hidden network, specify it's hidden:
Set Network Priority
Your Raspberry Pi can automatically connect to a preferred network among several known ones based on priority:
Check Current Priority
This command shows the priority values for known networks.
Change Network Priority
To prioritise a network, adjust its autoconnect priority:
This example sets "Pi Towers" as a preferred network with a priority of 10.
Confirm Connection
After connecting, confirm that your Pi is connected to the desired network:
Look for an asterisk (*) in the "IN-USE" column next to your network.
Additional Tips
Editing Network Configurations: Directly edit connection configurations at
/etc/NetworkManager/system-connections/
.Security Note: Exercise caution when connecting to unsecured wireless networks.
Network Troubleshooting: If you encounter connection issues, recheck your SSID and password, and ensure your Raspberry Pi is within a good range of the Wi-Fi signal.
By following these steps, you can configure and prioritize wireless networks on your Raspberry Pi using the command line, providing flexibility and control over your device's network connections.
Last updated
Was this helpful?