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.
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.
1) Ping
2) ip
3) iw
4) wpa-supplicant
Brief summary of the tools mentioned.
IW
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.
IP
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 componetnt 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.
PING
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 .
root@localhost ~]# 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.
root@localhost ~]#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
root@localhost ~]# sudo ip link set wlan0 up
STEP 4: Check connection status.
Use the following command to check connection status
root@localhost ~]# iw wlan0 link
To find all WIFI networks detected, type the following command on the terminal.
root@localhost ~]# iw wlan0 scan
STEP 5: Generate WPA/WPA2 config file foe wpa-supplicant that contains pre-shared key for all wifi network
root@localhost ~]# wpa_passphrase SSID_name >> /etc/wpa_supplicant.conf
Step 6: Connect to WPA/WPA2 wifi network using wpa_supplicant
root@localhost ~]# 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
root@localhost ~]# dhclient wlan0
Verify IP address with the ifconfig command.
root@localhost ~]# ifconfig -a
STEP 8: Add default routing rule to make sure you have correct routing rules
root@localhost ~]# 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.
root@localhost ~]# ping 8.8.8.8
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.
1) Ping
2) ip
3) iw
4) wpa-supplicant
Brief summary of the tools mentioned.
IW
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.
IP
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 componetnt 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.
PING
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 .
root@localhost ~]# 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.
root@localhost ~]#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
root@localhost ~]# sudo ip link set wlan0 up
STEP 4: Check connection status.
Use the following command to check connection status
root@localhost ~]# iw wlan0 link
To find all WIFI networks detected, type the following command on the terminal.
root@localhost ~]# iw wlan0 scan
STEP 5: Generate WPA/WPA2 config file foe wpa-supplicant that contains pre-shared key for all wifi network
root@localhost ~]# wpa_passphrase SSID_name >> /etc/wpa_supplicant.conf
Step 6: Connect to WPA/WPA2 wifi network using wpa_supplicant
root@localhost ~]# 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
root@localhost ~]# dhclient wlan0
Verify IP address with the ifconfig command.
root@localhost ~]# ifconfig -a
STEP 8: Add default routing rule to make sure you have correct routing rules
root@localhost ~]# 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.
root@localhost ~]# ping 8.8.8.8
0 comments:
Post a Comment
Say About Us.. :)