<?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>Made of Bugs &#187; wpa_supplicant</title>
	<atom:link href="http://blog.nelhage.com/tag/wpa_supplicant/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nelhage.com</link>
	<description>It's software. It's made of bugs.</description>
	<lastBuildDate>Thu, 18 Aug 2011 21:57:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>wpa_supplicant: GUI and wpa_action</title>
		<link>http://blog.nelhage.com/2008/09/wpa_supplicant-gui-and-wpa_action/</link>
		<comments>http://blog.nelhage.com/2008/09/wpa_supplicant-gui-and-wpa_action/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 16:07:49 +0000</pubDate>
		<dc:creator>nelhage</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wifi]]></category>
		<category><![CDATA[wpa_supplicant]]></category>

		<guid isPermaLink="false">http://blog.nelhage.com/?p=13</guid>
		<description><![CDATA[I&#8217;ve made two new interesting discoveries about wpa_supplicant since writing my last blog post on the subject. (Actually, I pretty much made both of them while reading documentation in order to write it, and have been lame about writing them up). Using wpa_gui It turns out that wpa_gui not only allows you to select existing [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve made two new interesting discoveries about <code>wpa_supplicant</code> since
writing my last blog post on the subject. (Actually, I pretty much
made both of them while reading documentation in order to write it,
and have been lame about writing them up).</p>

<h2>Using <code>wpa_gui</code></h2>

<p>It turns out that <code>wpa_gui</code> not only allows you to select existing
networks, but also to scan for and add new networks to your
configuration file. In addition, you can run it as yourself, without
needing to <code>sudo</code> it. In order to do so, you need to add two lines to
<code>/etc/wpa_supplicant/wpa_supplicant.conf</code>:</p>

<pre><code>ctrl_interface_group=netdev
update_config=1
</code></pre>

<p><code>ctrl_interface_group</code> selects a UNIX group that will be given
permission to read/write the control socket. I chose <code>netdev</code> because
it seems like it&#8217;s supposed to be networking-related, and my login
user was already in it on my Ubuntu machine.</p>

<p><code>update_config</code> allows <code>wpa_supplicant</code> to write back to its conf file
if instructed to configure new networks by a UI (<code>wpa_cli</code> or
<code>wpa_gui</code>). Note that this will squash any comments you have in the
file.</p>

<h2><code>wpa_action</code> — a mostly-baked roaming solution</h2>

<p>The setup I described in the previous post causes <code>wpa_supplicant</code> to
manage associating with access points, while Debian&#8217;s <code>ifupdown</code>
request DHCP independently. There&#8217;s no communication between the
layer, so if you switch networks, or associate sometime <em>after</em> we
bring up the interface, nothing tells <code>dhclient</code> to request a new
lease. It turns out we can turn this picture inside-out, and make
<code>wpa_supplicant</code> responsible for bringing up and down a virtual
interface, whenever it associates or loses association.</p>

<p>To make this work, we&#8217;re going to need to edit
<code>/etc/network/interface</code> again. Our <code>wpa_supplicant.conf</code> can stay
unchanged; Debian&#8217;s wrapper scripts do all the magic. Replace your
<code>ath0</code> block and add a virtual <code>default</code> interface as follows:</p>

<pre><code>iface ath0 inet manual
  wpa-driver wext
  wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp
</code></pre>

<p>The way this is going to work is that, whenever <code>wpa_supplicant</code>
associates to a network, it will bring up the virtual <code>default</code>
interface, causing <code>ifupdown</code> to spawn <code>dhclient</code> and request
DHCP. When it loses association, it brings it down, killing the DHCP
daemon.</p>

<p>Furthermore, we can associate different virtual interfaces with
different networks. Suppose that I usually want DHCP, but at home
(essid <code>nelhage</code>) I don&#8217;t run a DHCP server, and just want my laptop
to always grab <code>10.0.1.100</code>. I can add an interface to
<code>wpa_supplicant.conf</code>:</p>

<pre><code>network={
    ssid="nelhage"
    id_str="nelhage"
    key_mgmt=NONE
}
</code></pre>

<p>And then I add a new virtual interface to <code>interfaces</code>, corresponding
to the <code>id_str</code>:</p>

<pre><code>iface nelhage inet static
        address 10.0.1.100
        netmask 255.255.255.0
        network 10.0.1.0
        gateway 10.0.1.1
</code></pre>

<p>Now, if <code>wpa_supplicant</code> associates to the <code>nelhage</code> network, it will
bring up the <code>nelhage</code> interface, binding <code>ath0</code> to the static
configuration there listed.</p>

<p>For documentation, check out the third section of
<code>/usr/share/doc/wpasupplicant/README.modes.gz</code> on your Debian or
Ubuntu machine.</p>

<h2>In conclusion&#8230;</h2>

<p>This setup actually seems pretty close to the correct design for a
roaming wifi architecture, to me. Unfortunately, my experience is that
it hasn&#8217;t worked well for me; For some reason, when I put it in
roaming mode, it fails to associate with networks that it otherwise
works fine with. I suspect that this is related to <code>madwifi</code> suckage
as much as <code>wpa_supplicant</code> suck, though, so I&#8217;d encourage everyone
else who&#8217;s been fighting with wifi to try it out and report back if it
works for them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nelhage.com/2008/09/wpa_supplicant-gui-and-wpa_action/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using wpa_supplicant on Debian/Ubuntu</title>
		<link>http://blog.nelhage.com/2008/08/using-wpa_supplicant-on-debianubuntu/</link>
		<comments>http://blog.nelhage.com/2008/08/using-wpa_supplicant-on-debianubuntu/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 18:06:00 +0000</pubDate>
		<dc:creator>nelhage</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[wifi]]></category>
		<category><![CDATA[wpa_supplicant]]></category>

		<guid isPermaLink="false">http://nelhage.scripts.mit.edu/madeofbugs/?p=10</guid>
		<description><![CDATA[I&#8217;ve been using wpa_supplicant to manage wifi on my Ubuntu laptop for a while, and have found that it&#8217;s pretty close to what I want for managing wireless — closer than anything else I&#8217;ve found, at least. I figured I should document my setup and experiences. Some Background You probably all know just how much [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <code>wpa_supplicant</code> to manage wifi on my Ubuntu laptop
for a while, and have found that it&#8217;s pretty close to what I want for
managing wireless — closer than anything else I&#8217;ve found, at least. I
figured I should document my setup and experiences.</p>

<h2>Some Background</h2>

<p>You probably all know just how much wireless on Linux can be a pain to
get working right. Getting drivers and so forth working is usually
fine these days, especially if you&#8217;re using Ubuntu, but managing
connecting to multiple networks and dealing with WPA and WEP is a
serious pain in the ass. Debian&#8217;s solution the <code>ifupdown</code>
infrastructure lets you specify a single network or <code>any</code>, and doesn&#8217;t
have an answer for encryption, as far as I can tell. Ubuntu (and
Fedora)&#8217;s NetworkManager works great when it works, but it wants to
own your entire networking stack, isn&#8217;t very transparent or debuggable
when networking isn&#8217;t working, and the only interface is a dock
applet, which is problematic for my minimalist <a href="http://xmonad.org">XMonad</a>-based
desktop.</p>

<h2>Enter <code>wpa_supplicant</code></h2>

<p>Despite its name, <code>wpa_supplicant</code> isn&#8217;t just about WPA. It&#8217;s actually
a general management system for your wireless in disguise. You give it
a config file of networks you want to connect to if they&#8217;re available,
optionally with priorities, and settings about the kind of encryption
and a password or key if needed. You then tell it &#8220;go&#8221;, and it will go
scan for networks and connect to the appropriate ones as needed. If
you need to override it, there&#8217;s a command line client (<code>wpa_cli</code>) to
connect to the running ndaemon and tell it connect to a specific
network or AP (I think — I haven&#8217;t actually had occasion to use it
much at all)</p>

<h2>My configuration</h2>

<p>I have an Atheros wifi card, so my wifi device is <code>ath0</code>. Adjust this
as appropriate (it&#8217;ll probably be <code>eth1</code> with most other drivers)</p>

<p>First, install the necessary packages:</p>

<pre><code>$ sudo apt-get install wpasupplicant
</code></pre>

<p>Then set up your configuration:</p>

<ul>
<li><p><code>/etc/network/interfaces</code> — We&#8217;re still going to use <code>ifupdown</code> to
manage getting DHCP, but just not for wireless. So add a stanza to
<code>interfaces</code> that looks something like:</p>

<pre><code>auto ath0
iface ath0 inet dhcp
wpa-driver wext
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
</code></pre></li>
<li><p><code>/etc/wpa_supplicant/wpa_supplicant.conf</code> — This is the file where
you&#8217;re going to specify what networks you want to connect
to. <code>/usr/share/doc/wpasupplicant/examples/</code> can explain the full
range of options better than I can, but there are some examples
below. For now, you can just put a</p>

<pre><code>ctrl_interface=/var/run/wpa_supplicant
</code></pre></li>
</ul>

<p>at the start of the file.</p>

<p>Now, configure your networks in <code>wpa_supplicant.conf</code>. Some examples:</p>

<ul>
<li><p>MIT&#8217;s network &#8212; open, no encryption</p>

<pre><code>network={
    ssid="MIT"
    key_mgmt=NONE
}
</code></pre></li>
<li><p>WEP, hex key</p>

<pre><code>network={
    ssid="langtonlabs"
    key_mgmt=NONE
    wep_key0=deadbeef
}
</code></pre></li>
<li><p>WPA1, password</p>

<pre><code>network={
    ssid="wireless-is-a-lie"
    psk="passw0rd"
}
</code></pre></li>
</ul>

<p>Now if you bring up the interface with <code>ifup ath0</code>, <code>wpa_supplicant</code>
will start scanning for networks and associate as needed. The crappy
thing about this solution is that there&#8217;s no communication between
<code>wpa_supplicant</code> and <code>dhclient</code>, so you won&#8217;t automatically try to get
a new lease if you switch networks. I solve this with a <code>ifup --force
ath0</code> when I move my laptop between access points. I don&#8217;t do this too
often without suspending, though, so it&#8217;s not a huge deal. Browsing
documentation points me at something called <code>wpa_action</code> that&#8217;s
supposed to fix this&#8230; If I figure it out I&#8217;ll post again.</p>

<p>This works quite well for me, better than any other solution I&#8217;ve
found for moving my laptop between multiple access points, and handles
WEP, WPA, and WPA2 just fine. Hopefully it&#8217;ll be helpful for someone
else.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nelhage.com/2008/08/using-wpa_supplicant-on-debianubuntu/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

