Wi-Fi with Master Mode! Finally!
Friday, 23. October 2009, 06:38:25
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:
- Probably the git version that I downloaded had some new bugs and wasn't a working revision.
- I still had a non-working configuration for my "denilson" Wi-Fi at 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...
Update, after I woke up: it still seems to be working.









qlue # 23. October 2009, 07:53
My problem is that it sometimes doesn't work the next day!