Using wireless-tools to connect to wireless internet from the command line

by RogueClown adalia@weaknetlabs.com

Maybe the graphical interface on the computer you're using has become corrupted or somehow unusable. Before we begin. Make sure that you have these privileges. . and requires learning only a few simple commands. at least with respect to networking capabilities. and you need to get on the internet to figure out how to troubleshoot the problem. or install as few graphical programs as possible. the good news is that doing it is very easy. Whatever your reasons for needing to control your wireless connection from the command line. in a form that doesn't assume that you already know how to do it. it is going to happen. Maybe you will be on a computer that does not have a graphical interface installed for the wireless connection. If you do not have root privileges or wireless networking superuser privileges. your computer will not recognize the commands.ABSTRACT Sooner or later. consult your system administrator. Maybe you have an computer with so few system resources that you'd like to avoid installing a GUI at all. The hardest thing about it is finding all of the information you need in one place. note that almost all of the necessary commands require root or superuser privileges. Otherwise. Maybe you are just curious. and you will not be able to configure your wireless connection.

Odds are that it is installed already on your system.com/personal/Jean_Tourrilhes/Linux/Tools. Knoppix. if it is not. and -C network filters the list to show only network devices. and you can skip to the next section and start learning how to use it. you can check to see if you have the most current version of wireless-tools by opening up a terminal and typing the command: dpkg -l | grep wireless-tools This command looks at the list of all of the packages installed on your computer. However.html#latest Read the included instructions. and your computer does not have wireless-tools installed.hp. type the following command into your command line: ~$ sudo lshw -C network lshw produces the list of hardware connected to your computer.hpl.Making sure you have wireless-tools installed This tutorial covers basic wireless connection management using wireless-tools. don't be discouraged if it looks a little different. Xandros. download the suite at: http://www. it returns a line of text containing it. a suite of programs that comes with most Linux distributions. you need to find the name of your wireless card. What matters is off to the left of the line of text: that it says that wireless-tools is installed on your machine. and Damn Small Linux. Finding and turning on your wireless card Before scanning for a wireless network. . If your distribution does not have an automated package manager. looking something like this: ii wireless-tools Wireless Extens 29-1ubuntu2 Tools for manipulating Linux This is from an HP Pavilion laptop running Ubuntu 8. and lets it search for wireless-tools. If it does exist on your computer. To find the name of your wireless card. this is your 1 Debian-based distributions include some popular ones like Ubuntu. and turn it on. which explain how to install and compile the software. However. pipes the list into grep.04. and to verify whether your distribution has an automated package management system through which you can install wireless-tools. Find the entry that says description: Wireless interface. and your computer is currently connected to the internet. If you are using a Debian-based distribution1. a quick Google search for your distribution should tell you which core it is based on. check your distribution's documentation to verify how to check for an installed program. install it by typing: sudo apt-get install wireless-tools If you are not using a Debian-based distribution. this list is by no means exhaustive.

Piping it into less makes it a lot easier to scroll through. and note the logical name of your wireless interface. Even when you use a graphical program to connect to wireless. ask the staff for it. That name is called the "ESSID. If you cannot get the password for any of the stray wireless networks around. The last command uses ifconfig again. its scan mode reveals wireless networks that your card detects. Type the following into your command line: ~$ sudo iwlist [interface] scan | less and you will get a list of the wireless networks available.wireless card. If you're at a coffee house or another public place with WiFi. and find the one with the ESSID matching the wireless network to which you normally connect. a protocol discussed in a little more detail later in this article. Scanning for a wireless network wireless-tools has a useful utility called iwlist. iwlist gives you plenty of information with which to select a wireless network. Now you're ready to scan for a network. this time to bring your wireless interface back up. If you're in a familiar location like home or your favourite coffee shop. and the network associated with the location has a password. a password to get on the network. then you can do the same thing from the iwlist results that you . before you start connecting to a new wireless network. you need to make sure that your wireless interface is on and not still trying to connect to an old network from somewhere else. dhclient is a command-line program that manages connections to networks that use dynamic host configuration. The block of information with that ESSID is going to have everything you need to know--in fact. then finding the wireless network is easy. If it says “on”. First of all. The second command uses dhclient to release [-r] your wireless card from any IP address it had been bound to before. you can just use your up and down arrows. it will either say on or off. both wired and wireless. it shows wireless networking information that is not accessible from iwconfig. Make sure to pipe the iwlist scan into less. because you need it to tell your computer which piece of hardware to configure and connect with. type the following series of commands: ~$ sudo ifconfig [interface] down ~$ sudo dhclient -r [interface] ~$ sudo ifconfig [interface] up This series of commands uses two command-line network configuration programs: ifconfig and dhclient. ifconfig allows you to configure network interfaces. don't despair. Knowing the name of your wireless interface is important. According to the man page [accessible by typing man iwlist]. a whole lot more than you need to know--for connecting to the wireless network. because usually the list is too long to fit on one screen. the first command uses this program to turn your wireless card off. that means it has a WEP [Wireless Encryption Protocol] key. To accomplish this. it shows the name of the system. Look through the entries returned by iwlist. If you're in an unfamiliar location. look at the "Encryption key" field." wireless-tools gives you that same identifier. Now. What does this mean to you? Pertinent to getting your wireless working from the command line. Look down several lines.

yet another part of the wireless-tools suite. The mode managed section of the command tells your wireless card that it is supposed to associate with a central access point that is offering wireless network services. and among those. or 'off' if no password] essid [E S SID] This command uses the program iwconfig. All ESSIDs. if you want to use interface ath0 to connect to a network called Robust Beans Coffee.can from a graphical interface: look for unsecured networks. It is important to remember to always give a key instruction to iwconfig. you must put it in quotes. if you wanted to use a wireless interface called eth1 to connect to a network called Homenet that doesn't use an encryption key. are case sensitive. with the passphrase lolrushas2bukkits@home. Don't be shy about jotting down your interface name and ESSID. with the encryption key cf1e94a35b. it makes connecting to the network easier. the network assigns a computer its identifying details. as shown above. the network key. be they single-word or multiword. Instead of memorizing the key. Until I had memorized the syntax of the commands and the information for my favourite wireless networks. you would type the following: ~$ sudo iwconfig eth1 mode managed key s:lolrushas2bukkits@home essid . look for the one with the highest Quality [another field on iwlist]. some systems instead give out an ASCII passphrase. instead of trying to connect directly with other computers in a network. I always had to write that information down. To use interface eth1 to connect to a network called allienet. you would type the following: ~$ sudo iwconfig ath0 mode managed key cf1e94a35b essid “Robust Beans Coffee” Instead of directly giving a key. Configuring your connection to the wireless network Most home and public wireless networks use a protocol called DHCP: Dynamic Host Configuration Protocol. including its IP address. In many cases. However. even if there is no key needed to get onto the wireless system. which can be difficult to memorize. This is good news for you. it will start giving that key to the wireless network that doesn't need one—and you will not get on the wireless network. especially if you're new to doing command-line wireless configuration. See which networks have "Encryption key:off". Take the information that you gathered during your scan. Otherwise. Instead of assigning a computer the same IP address to use for all time [as is true when a network uses a static protocol]. Thus. you can use iwconfig with that passphrase by prefacing the passphrase with s:. since not only is it a little more secure than static IP addressing. do not put single-word ESSIDs in quotes. if there was already a key configured for the wireless card's use. when it attempts to connect. So. you would type the following: ~$ sudo iwconfig eth1 mode managed key off essid Homenet Know also that if the ESSID has more than one word. the systems administrator comes up with a phrase that the router converts into a hexadecimal code. and type the following onto your command line: ~$ sudo iwconfig [interface name] mode managed key [password. to configure your wireless card to be ready to connect to the wireless network of your choice.

To do that. It's fairly intuitive which programs do what. connected to the network yet. If you have access to any of the other networks shown on iwlist. contact the systems administrator. Hit ctrl-C to stop the pinging.C.google. But. you need to get your wireless card to ask the network for a connection.167.B. and enjoy using the internet. If your dhclient command makes multiple attempts to connect does not return the bound to message.com (64. If you have any questions about the content of this paper.com. Type: ~$ sudo dhclient [interface] This command should connect you to the wireless network. You are not. and the network binds your computer to an IP address. Conclusion Connecting to wireless from the command line using the wireless-tools suite may seem a little complicated at first. please e-mail me at adalia@weaknetlabs. .147): icmp_seq=5 ttl=242 time=60. you are not connected to the internet. If you do not. and assigned all of the commands that needed [interface] fields to the correct name of your wireless interface. you have told your wireless card what it needs to know in order to find the network and ask it for a connection. after a few times going through this process.B. however.google.D] A. it will say on the screen: bound to [A. and it's a useful skill to have in case you need a wireless internet connection from a Linux computer without a graphical wireless program. attempt to connect to it. then it could be a problem with the network. start from the beginning and try again. Go back and make sure that you typed all of the commands correctly. it will be four numbers separated by periods. If you typed all of the commands in correctly. If it's successful.allienet After typing this configuration command. the syntax will come. is your IP address on the network.9 ms Congratulations! You're on the internet.C. especially if you are unaccustomed to using the command line.com If the ping starts returning lines like this: 64 bytes from py-in-f147. If you typed any of the commands incorrectly. and instead returns an error. To make sure your connection works. It will ask the access point to assign your computer an IP address. go ahead and ping a website you know will be up: ~$ ping www.D.233.

Sign up to vote on this title
UsefulNot useful