====== Command line Wireless network (wpa2) in a pinch with WPA-supplicant ====== ===== Introduction ===== In some cases and situations it might not be possible to get your wireless network up with more advanced tools, and in such cases it is always useful to know how to get wireless networking up and running with the basic networking tools. This method works in all or most distroes, as they generally have these tools by default. The information is taken from an article that I have used many times (because I can't remember all the steps), but I'm adding it here because I tend to have troubles finding the article when I need it. **Summary:** iw dev ip link show wlan0 ifconfig wlan0 up iw wlan0 link iw wlan0 scan | less wpa_passphrase mywifiname >> /etc/wpa_supplicant.conf wpa_supplicant -B -D wext -i wlan0 -c /etc/wpa_supplicant.conf dhclient wlan0 ===== Prerequsites ===== Root access.\\ Basic knowledge of command line. ===== Gathering intel ===== **1. Find the name of the wireless device** iw dev In the case of Slackware this will almost always be "wlan0". (from here on, we assume it is "wlan0")\\ \\ **2. Check if the wireless card is up** ip link show wlan0 It should give you a line of information, including the word UP or DOWN. Another way to check if wlan0 is up is\\ ifconfig If you see the wlan0 card with ifconfig it is up, if not it is down.\\ \\ **3. Bring it up if it is not up** ifconfig wlan0 up OR use ip link set wlan0 up At this point you can repeat step 2 if you want to verify that it is up.\\ \\ **4. Check the connection status of wlan0** iw wlan0 link Not connected. If you have a keen eye, you can figure out pretty much the same with ifconfig === Scanning for wireless networks (optional) === If you already know the name of your wireless network, you can skip this step.\\ **5. Scan for wireless networks** iw wlan0 scan | less OR you can pipe output to file iw wlan0 scan > wireless.list nano wireless.list You can find your wireless network name (SSID) and other useful information here. ===== Connecting to your wireless network ===== Assuming your network name is "mywifiname" and your password is "password123" we continue like this.\\ **6. Input the password** wpa_passphrase mywifiname >> /etc/wpa_supplicant.conf **Type the password and hit enter.**\\ The above step seems a bit weird and unintuitive when you do it, and it is somewhat, because the tool pipes stdout to /etc/wpa_supplicant.conf and you don't seem to get any proper feedback or input. However, it does work. If you think you might have typed the password incorrectly, you can edit /etc/wpa_supplicant.conf or if you know how to manually add entries in /etc/supplicant.conf you can skip the wpa_passphrase command and just add the entry in the config file instead. Or you can delete the added entry in the config file and redo the wpa_passphrase step.\\ **7. Connect to the network with the info you have provided** wpa_supplicant -B -D wext -i wlan0 -c /etc/wpa_supplicant.conf This should work in most cases. "wext" is a generic wireless driver, and in some cases you might have to use another driver to connect, but in almost all cases "wext" should work. You can find further drivers and information with wpa_supplicant --help **8. Check if you are connected** iw wlan0 link This time it should give you quite alot of information, including mac address and SSID, which means you are connected. You have now connected your wireless card with the wireless router/modem/switch.\\ **9. Get IP address** dhclient wlan0 OR dhcpcd wlan0 It is assumed that if you use wireless that the computer is a user computer using dhcp. If you use some other solution than dhcp, feel free to add the information below for this step. ===== Appendage ===== Getting wireless network up with command line tools and wpa_supplicant is fairly easy, but it doesn't really replace using better tools for the same purpose. Manually invoking dhcp and flushing it is quite problematic. If you want to bring down/undo wpa_supplicant you can remove the file rm /var/run/wpa_supplicant/wlan0 Or you can kill the processes. ps x | grep -i supplicant 1234 Ss 0:00 wpa_supplicant -B -D wext -i wlan0 -c /etc/wpa_supplicant.conf kill -9 1234 If you want to release the dhclient lease, which doesn't always work, you can try it with dhclient -r ====== Sources ====== * Original source: [[https://linuxcommando.blogspot.com/2013/10/how-to-connect-to-wpawpa2-wifi-network.html]]\\ * Written by [[wiki:user:zeebra | zeebra]] {{tag>howtos network wireless wpa_supplicant author_zeebra}}