Connecting to a network via Linux Terminal is as sweet as candy. Have you bumped into issues and unknown errors while trying to connect to WIFI network before?. If so, then you have to learn how to don it on command line. Some Linux flavors and distributions will fail to connect to wifi network at some point but using Terminal to connect to WIFI network never fails.
If you’ve just installed your Linux, we have a lot of tutorials on How to for Linux.
This tutorial is universal and will work well on most Linux distros out there, both old and future releases. It also work well on both WPA/WPA2 wireless networks.
These are the tools you would require to connect to wireless network in Linux’s command line terminal.
Brief summary of the tools mentioned.
It is anew 802.11 base CLI configuration utility for all wireless devices. It has support for all new drivers that have been added to the kernel recently.
It stands for Internet protocol. It is a utility in Linux used to test and show routing ,devices,policy routing and tunnels.
Linux WPA/WPA2/IEEE 802.1X SUPPLICANT
Supplicant is the IEEE 802.1X/WPA component uses at the client station. Its purpose is implementing key negotiation with a WPA Authentication and Controlling roaming and IEEE 802.11 authentication and association Wlan drivers.
Utility used to test whether destination host is live or dead. It uses ICMP echo messages.
STEP 1: Finding all available Wifi and adapters.
Begin by finding all available Wifi and adapters with iw command .
# iw dev phy #1 Interface wlan0 ifindex 4 wdev 0x1 addr 00:27:10:0e:b3:54 type managed
Wlan0 is the device names. Phy#1 is the designated name. Type managed means it is client that connects to AP.
ifindex 4 means is as per connected port.
STEP 2: Check Device Status
To check if the wireless device is up or not, we use the following command.
# ip link show wlan0
The output show us Wlan0 as up and wlan1 as down.
STEP 3: Bring up the wifi interface
Use the following command
# sudo ip link set wlan0 up
STEP 4: Check connection status.
Use the following command to check connection status
# iw wlan0 link
To find all WIFI networks detected, type the following command on the terminal.
# iw wlan0 scan
STEP 5: Generate WPA/WPA2 config file foe wpa-supplicant that contains pre-shared key for all wifi network
# wpa_passphrase SSID_name >> /etc/wpa_supplicant.conf
Step 6: Connect to WPA/WPA2 wifi network using wpa_supplicant
# wpa_supplicant -B -D wext -i wla0 -C /etc/wpa_supplicant.conf
-D specifies the wireless driver wext generic driver.
-C gives the actual path of config file
-B runs the wpa_supplicant on the background.
STEP 7: Get IP address fro DHCP server
# dhclient wlan0
Verify IP address with the ifconfig command.
# ifconfig -a
STEP 8: Add default routing rule to make sure you have correct routing rules
# ip route show default via 10.0.0.40 dev wlan0 10.0.0.0/24 dev wlan0 proto kernel scope link src 10.0.0.8
STEP 9: Test the connectivity by ping to any IP address global like google DNS servers.
Wifi connectivity with Terminal in Linux
How to connect to WIfi in Linux easily
Using Terminal to connect to WPA wireless network.