The most easiest way to connect to a wireless network in Linux is by using Network Manager’s GUI, but in this tutorial we will learn how to connect via CLI, root privileges are required, tested on Debian 9.6.
1. Install the software
apt-get install wireless-tools wpasupplicant
2. Make sure your network card was detected, in this example my wireless card is
If your wireless card is not detected please check this guide -> help.ubuntu.com.
wlan0 unassociated ESSID:"" Nickname:"<WIFI@REALTEK>" Mode:Managed Frequency=2.412 GHz Access Point: Not-Associated Sensitivity:0/0 Retry:off RTS thr:off Fragment thr:off Encryption key:off Power Management:off Link Quality:0 Signal level:0 Noise level:0 Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:0 Missed beacon:0 lo no wireless extensions. eth0 no wireless extensions.
3. Create wpa_supplicant.conf based on your SSID and password.
wpa_passphrase YourSSID >> /etc/wpa_supplicant.conf
Enter your password and press Enter, passphrase must be 8 – 63 characters.
4. Authenticate to your network
wpa_supplicant -D wext -i wlan0 -B -c /etc/wpa_supplicant.conf
5. Check if you are authenticated, you should have an Access Point associated.
wlan0 IEEE 802.11bgn ESSID:"YourSSID" Nickname:"<WIFI@REALTEK>" Mode:Managed Frequency:2.432 GHz Access Point: 11:22:33:AA:BB:CC Bit Rate:72.2 Mb/s Sensitivity:0/0 Retry:off RTS thr:off Fragment thr:off Encryption key:****-****-****-****-****-****-****-**** Security mode:open Power Management:off Link Quality=100/100 Signal level=100/100 Noise level=0/100 Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:0 Missed beacon:0
Note: If you have issues while authenticating please check syslog.
6. Request or set IP address.
Now that you are authenticated to communicate with your network you must have an IP address, you must request it from a DHCP server or manually set.
Note: If you are using
netplan please skip this step and check https://netplan.io/examples.
dhclient -nw wlan0
b) Set IP address, default gateway and DNS server
ip addr add dev wlan0 192.168.1.100/24
ip route add default via 192.168.1.1
echo "nameserver 126.96.36.199" > /etc/resolv.conf