<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>gHacks Technology News &#124; Latest Tech News, Software And Tutorials &#187; iwconfig</title> <atom:link href="http://www.ghacks.net/tag/iwconfig/feed/" rel="self" type="application/rss+xml" /><link>http://www.ghacks.net</link> <description>A technology news blog covering software, mobile phones, gadgets, security, the Internet and other relevant areas.</description> <lastBuildDate>Sat, 11 Feb 2012 09:52:46 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/> <item><title>Connect to a wireless network via command line</title><link>http://www.ghacks.net/2009/04/14/connect-to-a-wireless-network-via-command-line/</link> <comments>http://www.ghacks.net/2009/04/14/connect-to-a-wireless-network-via-command-line/#comments</comments> <pubDate>Tue, 14 Apr 2009 15:22:01 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Advice]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Mobile Computing]]></category> <category><![CDATA[Networks]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Tutorials Advanced]]></category> <category><![CDATA[Tutorials Basic]]></category> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[ifconfig]]></category> <category><![CDATA[iwconfig]]></category> <category><![CDATA[iwlist]]></category> <category><![CDATA[wireless networking]]></category> <guid
isPermaLink="false">http://www.ghacks.net/?p=12001</guid> <description><![CDATA[I know, the first thing you are asking is &#8220;Why would I want to have to connect to a wireless network from the command line?&#8221; To that question I can give you a simple answer&#8230;What if you want to create a script to run that will bring up your wireless network as soon as your [...]]]></description> <content:encoded><![CDATA[<p>I know, the first thing you are asking is &#8220;Why would I want to have to connect to a wireless network from the command line?&#8221; To that question I can give you a simple answer&#8230;What if you want to create a script to run that will bring up your wireless network as soon as your desktop is loaded? You could get really complex and create a start up script to load a desktop based on what wireless access point you needed to join. That&#8217;s one of the beauties of Linux, if you can dream it, you can do it.</p><p><span
id="more-12001"></span>But I am getting too far ahead of myself. Let&#8217;s get back to the basics shall we? First I am going to assume that your wireless card was detected by your distribution and has the proper drivers loaded. With that accomplished you will need to have the following tools:</p><ul><li>ifconfig: Enable your wireless device.</li><li>iwlist: List the available wireless access points.</li><li>iwconfig: Configure your wireless connection.</li><li>dhclient: Get your IP address via dhcp.</li></ul><p>The first command you need to use is ifconfig. With this command you are going to enable your wireless device. Most likely your device will be called wlan0. So in order to enable this you would enter the command (as root):</p><p><em>ifconfig wlan0 up</em></p><p>You won&#8217;t see any feedback unless there is a problem.</p><p>The next step is to scan for your wireless network to make sure it is available. Do this with the following command:</p><p><em>iwlist wlan0 scan</em></p><p>With this command you will see output like the following:</p><p><code>Cell 01 - Address: 00:21:43:4E:9B:F0<br
/> ESSID:"HAIR STROBEL"<br
/> Mode:Master<br
/> Channel:5<br
/> Frequency:2.432 GHz (Channel 5)<br
/> Quality=100/100? Signal level:-45 dBm? Noise level=-95 dBm<br
/> Encryption key:on<br
/> IE: WPA Version 1<br
/> Group Cipher : TKIP<br
/> Pairwise Ciphers (1) : TKIP<br
/> Authentication Suites (1) : PSK<br
/> IE: IEEE 802.11i/WPA2 Version 1<br
/> Group Cipher : TKIP<br
/> Pairwise Ciphers (1) : CCMP<br
/> Authentication Suites (1) : PSK<br
/> Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 22 Mb/s<br
/> 6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s<br
/> 36 Mb/s; 48 Mb/s; 54 Mb/s<br
/> Extra:tsf=000002f1d9be01b7</code></p><p>So you know this network is available. From the above output you can also see this network is employing WPA2, so you will need a passkey. If you don&#8217;t know that passkey, you are out of luck (which would be the case no matter if you were using a front end in Linux, Windows, or Mac.)</p><p>Now it&#8217;s time to configure your connection. To do this issue the command:</p><p><em>iwconfig wlan0 essid NETWORK_ID key WIRELESS_KEY</em></p><p>Where NETWORK_ID is the ESSID of the network with which you want to connect and WIRELESS_KEY is the security key needed to connect to the wireless access point.</p><p>Note: iwconfig defaults to using a HEX key. If you want to use an ascii key you will have to add the &#8220;s:&#8221; prefix to your key like so:</p><p><em>iwconfig wlan0 essid NETWORK_ID key s:WIRELESS_KEY</em></p><p>Now that you have your configuration set, it&#8217;s time to get an IP address with the help of dhclient. Issue the command:</p><p><em>dhclient wlan0</em></p><p>If no output is reported there are no errors. You should now be up and running.</p><p><strong>Make it a script</strong></p><p>Of course who wants to type out all of those commands. Instead of doing this you could create a script for this like so:</p><p><code>#! /bin/bash<br
/> ifconfig wlan0<br
/> iwconfig wlan0 essid NETWORK_ID key WIRELESS_KEY<br
/> dhclient wlan0</code></p><p>Where NETWORK_ID is the actually essid of the network and WIRELESS_KEY is the security key for that network. Save this script with the filename <strong>wireless_up.sh </strong>and then make this script executable with the command:</p><p><em>chmod u+x wireless_up.sh</em></p><p>You can make this a global command by placing this script in <strong>/usr/local/bin</strong>. You can now issue the command <strong>wireless_up.sh</strong> from anywhere in your directory structure and it will run, connecting you to the configured wireless access point.</p><p>If you frequent many wireless access points you can create a script for each one giving them each unique names. By doing this, when you need to connect to a specific access point, just run the script associated with that access point and you&#8217;re good to go.</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2009/04/14/connect-to-a-wireless-network-via-command-line/feed/</wfw:commentRss> <slash:comments>35</slash:comments> </item> </channel> </rss>
