CrazyTB's blog

Wi-Fi with Master Mode! Finally!

, , , ,

Woohoo! Finally I could get my ralink card work in Master mode! My previous attempt was about 2 months ago.

It seems to work, but now it's almost 4:00 AM and I haven't had enough time to really test it. But my notebook can see and connect to my desktop-working-as-access-point, and I need to document this victory!

My system

Desktop (which is the server) is Gentoo/Linux amd64, with RaLink RT2561/RT61 802.11g PCI Wi-Fi card, which uses rt61pci driver (from rt2x00 driver family).

Notebook (which is the client) is also Gentoo/Linux amd64, but has Intel Corporation PRO/Wireless 3945ABG card, with iwl3945 driver.

How to...

Okay, finally I could get it working. Did I need the latest development branch from Git? Nope! Did I need any special patches? Nope! Just the plain stable packages from Gentoo were enough!

emerge -av sys-kernel/gentoo-sources net-wireless/hostapd

The installed versions are sys-kernel/gentoo-sources-2.6.30-r5 and net-wireless/hostapd-0.6.9.

Then, I've configured /etc/conf.d/net, as described at the hostapd-0.6.9 ebuild message:

config_wlan0=( "192.168.1.1/24" )
channel_wlan0="9"
essid_wlan0="denilson"
mode_wlan0="master"

I've checked /etc/conf.d/hostapd, and it didn't require any changes.

Finally, I've edited the almighty /etc/hostapd/hostapd.conf. I'm listing below what I've changed from the default hostapd.conf. Please note that this is not a complete configuration file! Don't copy and paste this, as it won't work. These are just the differences when comparing with the default file.

# Notice: this is NOT a complete hostapd.conf file.
# These are just the required changes to the default hostapd.conf file.
driver=nl80211
ssid=denilson
country_code=BR
hw_mode=g
channel=9
max_num_sta=4
wpa=2
wpa_passphrase=aVeryCleverPassphraseThatImNotTellingYou
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP

Why do I need to set ssid and channel at two files? (/etc/conf.d/hostapd and /etc/hostapd/hostapd.conf) I don't know, and right now I don't care, as it is much more important to just have it working! (if you know the reason, please post a comment)

It's not required to change max_num_sta, but I did it anyway, since I won't be serving more than... well... one machine.

Then I run: /etc/init.d/net.wlan0 restart

It complains that wlan0 does not support setting the mode to "master", but this is normal. The rt2x00 developers programmed the driver to only allow the interface to get into the master mode when running hostapd daemon. This makes sense, since master mode without a daemon is completely useless.

And, finally, /etc/init.d/hostapd restart

And it works! And I can see my AP being shown at Wi-Fi scanning results on my notebook!

(omitted here: instructions about how to configure dhcpd and NAT, because they were already configured on my system, and because you can find a lot of information about them at the Internet)


Now, I just need to configure the client. On my notebook, I add these lines to /etc/wpa_supplicant/wpa_supplicant.conf:

network={
        ssid="denilson"
        psk="aVeryCleverPassphraseThatImNotTellingYou"
        priority=5
}

And that's all! I'm done! It works!

Why didn't it work before?

Why didn't it work on my previous try? I can give you two reasons:
  1. Probably the git version that I downloaded had some new bugs and wasn't a working revision.
  2. I still had a non-working configuration for my "denilson" Wi-Fi at wpa_supplicant.conf
Yeah, that's true. I still had these lines at my /etc/wpa_supplicant/wpa_supplicant.conf:

# Notice: These lines don't work
network={
       ssid="denilson"
       key_mgmt=NONE
       priority=5
       pairwise=NONE
       mode=1
}

I had these lines when I was trying to set-up the ad-hoc network with wpa_supplicant. However, these lines don't work. They didn't work for me when I had an ad-hoc Wi-Fi network; and they don't work for managed/AP networks.

What's next?

I could connect to the access point using WPA2 and could get an IP address. I can ping the desktop over Wi-Fi.

Thus, the basic tests passed. The basic things are working.

From now on, I must keep using this Wi-Fi and test its stability. I'll do that after some sleep... smile

Update, after I woke up: it still seems to be working.

A message to 2D BoyNokia and the Daylight Saving Time

Comments

Mad Scientistqlue Friday, October 23, 2009 7:53:56 AM

You sound like me! Go without sleep untill it works. p.
My problem is that it sometimes doesn't work the next day! scared. (whichever problem I happen to be working on that is! p)

Unregistered user Sunday, December 20, 2009 6:01:21 PM

Pete writes: Thanks for the write-up Denilson! I finally managed to get my RA61 (Sitecom WL-171) working under Debian Linux. I had to backport the hostapd 0.6.9 from the testing branch to get it to work, the older version in stable didn't have the nl80211 driver.

Unregistered user Sunday, March 21, 2010 1:06:10 PM

Alex writes: Thanks a lot for your help, please help me to finish this: I got in partially, I followed your post and I can connect with my laptop to the AP created, but I can't ping the AP. in /etc/conf.d/net I have config_wlan0=( "192.168.2.1/24) the rest as you post it I manually changed the settings on the laptop: IP 192.168.2.2, netmask 255.255.255.o, gateway 192.168.2.1 From the laptop I ping 192.168.2.1 I get destination host unreachable Any ideas? Do I forget something? Thank you a lot

Denilson Figueiredo de SáCrazyTerabyte Sunday, March 21, 2010 5:40:38 PM

Alex, sorry, but I don't have any idea. I'd double-check the IPs of both hosts ("ifconfig" or "ip address show") and also the routing table ("route -n" or "ip route show"). I'd also check if the Wi-Fi signal is okay, and if you are really associated with the AP.

Other than that, well, it's difficult to solve without a close look.

Unregistered user Sunday, March 21, 2010 9:14:41 PM

alex writes: Well, I don't understand...I deactivated all encryption settings and it works (commented out all concerned lines in hostapd.conf). So it was an encryption problem, but for the moment I cannot see it...:( I'll keep going like that and return later. All that after hours of changing routes, ips etc etc...aah Thx for helping

Unregistered user Tuesday, March 23, 2010 2:35:05 AM

Anonymous writes: I just setup my asus G31 pci card (rt2561 chip) along with OpenWrt and it works fine in master mode, except that the TX power in very low. See here https://forum.openwrt.org/viewtopic.php?id=23953 Any idea? Thank you for your suggestion.

Denilson Figueiredo de SáCrazyTerabyte Tuesday, March 23, 2010 8:27:59 PM

No idea. Also, I think I haven't changed the default TX power from my card, after all, the notebook is just a few meters from the desktop.

Unregistered user Tuesday, February 15, 2011 5:47:34 AM

flibitijibibo writes: Funny how these things work out. I visited this blog after you commented in the DRM article and it just so happened that what you were doing here is what I've been attempting to do for MONTHS. Thank you thank you thank you thank you thank you (Oh and I'm sorry that I'm commenting on an article this old but seriously this is awesome)

Denilson Figueiredo de SáCrazyTerabyte Tuesday, February 15, 2011 11:05:28 AM

No problem commenting on old articles. A good comment is a good comment anytime. smile

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies

May 2012
S M T W T F S
April 2012June 2012
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31