View previous topic :: View next topic |
Author |
Message |
thermoman n00b
Joined: 18 Aug 2004 Posts: 28
|
Posted: Sun Jan 08, 2006 1:26 pm Post subject: [HOWTO] RaLink rt2500 with WPA-PSK + AES "The Gentoo Wa |
|
|
Keywords: ralink iwpriv pccard pcmcia rt2500 rt2x00 serialmonkey
Hi,
i suddenly got an Asus WL-107G Wireless 54MBit/s PCCARD with the RaLink rt2500 chipset working under Gentoo on my notebook and wanted to share my experience while trying to configure things the Gentoo way. This howto is about getting the kernel module compiled and setup WPA with a PSK (pre shared key) using AES encryption. No WEP, no Radius.
Let's start:
At the time of this writing the needed ebuild is masked, so we need to unmask it:
Code: | # echo 'net-wireless/rt2500 ~x86' >> /etc/portage/package.keywords |
Emerge the package (version 1.1.0_beta3 at the time of this writing)
Code: | # emerge -av rt2500 |
After this you should have a kernel module named rt2500 in /lib/modules/<your kernel version here>/kernel/drivers/net/rt2500.ko
To make sure the module is recognized by modprobe:
Try to load the module and check for the new device ra0:
Code: | # modprobe rt2500 ; iwconfig ra0 ; ifconfig ra0
ra0 RT2500 Wireless ESSID:""
Mode:Managed Frequency=2.412 GHz Bit Rate:1 Mb/s
RTS thr:off Fragment thr:off
Encryption key:off
Link Quality=0/100 Signal level=-120 dBm Noise level:-256 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
ra0 Protokoll:Ethernet Hardware Adresse 00:11:22:33:44:55
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11 Basisadresse:0x8000 |
At this point you finished the hardest part - if you don't get a similar output don't go any further - it won't work unless you got this right here. Check the output of 'dmesg'.
If you've got an access point already running in your area then it's time to check if the card can see it:
Code: | # ifconfig ra0 up ; iwlist ra0 scanning
ra0 Scan completed :
Cell 01 - Address: aa:bb:cc:dd:ee:ff
Mode:Managed
ESSID:"FooBar"
Encryption key:on
Channel:11
Quality:0/100 Signal level:-48 dBm Noise level:-195 dBm |
It might be that you'll have to fire up the command twice or wait some seconds between the ifconfig up and the scanning to see your AP.
Now it's time to write a little script since you can't use iwconfig for setting the auth mode (WPAPSK), the encrypt mode (AES) and the secred key. instead for these 3 values you have to use iwpriv.
We will create a script/profile for each AP we want to use, e.g. a script with all the needed values for profile 'home' and one for the companies' network called 'company'.
Code: | # mkdir /etc/wireless
# chmod 700 /etc/wireless
# cd /etc/wireless
# ls -lA
total 8
lrwxrwxrwx 1 root root 4 Jan 6 20:58 _loadprofile -> home
-rwx------ 1 root root 396 Jan 6 20:58 company
-rwx------ 1 root root 453 Jan 8 13:43 home |
Contents of /etc/wireless/home
Code: | #!/bin/sh -e
[ $# -ne 1 ] && exit 1
DEVICE=$1
MY_MODE=managed
MY_SSID="yourSSIDhere"
MY_AUTHMODE=WPAPSK
MY_ENCRYPT=AES
MY_KEY="yourKEYhere"
MY_SLEEP=3
ifconfig ${DEVICE} up
iwconfig ${DEVICE} mode "${MY_MODE}"
iwpriv ${DEVICE} set AuthMode="${MY_AUTHMODE}"
iwpriv ${DEVICE} set EncrypType="${MY_ENCRYPT}"
iwpriv ${DEVICE} set WPAPSK="${MY_KEY}"
iwconfig ${DEVICE} essid "${MY_SSID}"
sleep "${MY_SLEEP}" |
Make sure /etc/wireless is only accessibile for root and all the scripts/profiles are executable for root. At last point a symbolic link named '_loadprofile' to the script whose profile you wanna use:
Code: | # cd /etc/wireless
# ln -s home _loadprofile |
What have we done? We have an executable script named /etc/wireless/_loadprofile which sets all the needed information about the Access Point you want to connect to. Now it's time to configure /etc/conf.d/net to use this script/profile before firing up the device ra0 and then eventually run dhcpcd on it.
My Laptop has a build in NIC (eth0) and the wireless card (ra0) - modifiy for your needs.
Contents of my /etc/conf.d/net
Code: | # eth0
#########
# config_eth0=( "192.168.5.6/24" )
# routes_eth0=( "default via 192.168.5.1" )
config_eth0=( "dhcp" )
# ra0
#########
modules_ra0=( "!iwconfig" )
config_ra0=( "dhcp" )
preup() {
# check eth0 for a link
if [ "x${IFACE}" = "xeth0" ] ; then
if ethtool "${IFACE}" | grep -q 'Link detected: no'; then
ewarn "No link on "${IFACE}", aborting configuration"
return 1
else
return 0
fi
# load wlan profile for ra0
elif [ "x${IFACE}" = "xra0" ] ; then
einfo "Loading WLAN profile '`readlink /etc/wireless/_loadprofile`'"
/etc/wireless/_loadprofile ra0
return $?
fi
# Remember to return 0 on success
return 0
} |
The *_eth0 should be self-explanatory.
modules_ra0=( "!iwconfig" ) means not to use iwconfig when trying to bring this device up because we handle all the iwconfig stuff in our profile script.
config_ra0=( "dhcp" ) means to use dhcp and get ip stuff over the wireless network
The preup function is explained here. It's simply a function which is called when present before an interface is brought up - so i use it to check eth0 for a link (you need to emerge sys-apps/ethtool) and abort bringing up eth0 when no cable is plugged in. If the device to bring up is ra0 we run the /etc/wireless/_loadprofile script which sets all the wireless parameters. Finally, the config_ra0=( "dhcp" ) makes gentoo start a dhcp client for this interface.
The only thing left is a symbolic link for /etc/init.d/net.ra0
Code: | # cd /etc/init.d
# ln -s net.lo net.ra0 |
Now it's time to see if it works (cross your fingers )
Code: | /etc/init.d/net.ra0 start
* Starting ra0
* Running preup function
* Loading WLAN profile 'home'
* Bringing up ra0
* dhcp
* Running dhcpcd ... [ ok ]
* ra0 received address 192.168.168.4 |
Same here - sometimes you'll need to start this twice. E.g. the first time i fire the interface up i see the link led on the WLAN card goes on but off 2 seconds later. Gentoo then hangs at "Running dhcpcd ..." ... pressing CRTL+C and starting it again solves the issue. I don't know what causes this.
What's missing? A script that scans for AccessPoints in the area and sets the symbolic link /etc/wireless/_loadprofile to the right profile so you don't have to do it on your own each time you want to connect to a different wireless network. But this is beyond this little howto
Have fun with your wireless card
Greetings,
thermoman. |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
wizard69 Apprentice
Joined: 22 Sep 2003 Posts: 178 Location: Berlin
|
Posted: Mon Jan 09, 2006 1:55 pm Post subject: |
|
|
@UberLord will this patch work with my linksys wusb54g with the rt2570 module. I have been waiting to use wpa for ages but can't get it to work up to now i hope. So if it works i would love to give your patch a try |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
thermoman n00b
Joined: 18 Aug 2004 Posts: 28
|
Posted: Mon Jan 09, 2006 9:17 pm Post subject: |
|
|
So,
here are my testing results. In general, your patch works fine, uberlord. But with rt2500 i had some issues:
1. sleep_scan_ra0="5" is needed (only for the record)
2. The driver seems to go jumpy when issuing the iwconfig ra0 essid any command. So i had to replace /sbin/iwconfig with a wrapper:
Code: | # ls -la /sbin/iwconfig*
-rwxr-xr-x 1 root root 81 9. Jan 21:55 /sbin/iwconfig*
-rwxr-xr-x 1 root root 21276 25. Dez 20:02 /sbin/iwconfig.orig*
# cat /sbin/iwconfig
#!/bin/sh
[ $# -eq 3 ] && [ $2 = "essid" -a $3 = "any" ] && exit 0
$0.orig $@ |
Else the essid command is executed and the init-script hangs at starting dhcp for the interface - reproduceable, every time.
With this little fix it now works after it hangs one time after inserting the module.
1. insert card, module gets loaded
2. /etc/init.d/net.ra0 start
3. Script will hang when trying to get dhcp up
4. Press CRTL+C
5. goto 2
This time it works and even the rest of the time until you remove the module again - then first start hangs again. You can see the link led going on and seconds after going off. This loops. When issueing this command for the second or more time, the led keeps on and all works. |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
wizard69 Apprentice
Joined: 22 Sep 2003 Posts: 178 Location: Berlin
|
Posted: Tue Jan 10, 2006 10:08 am Post subject: |
|
|
@UberLord thanks for the answer what must i do to install your patch? |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
Posted: Tue Jan 10, 2006 12:34 pm Post subject: |
|
|
OK, I just got this working
Looks like my the rt2500 driver does not want to connect to a DrayTek Vigor 2600 AP that accepts both WPA and WEP. If the AP is configured to only accept WPA or WEP then it works fine!.
Interesting to note that I cannot find any workaround for the first time -> hang, all other times it works error :/
Also, I have to have a sleep_scan of 10 seconds to reliably find my AP.
All in all, a badly written driver
But atleast WPA now works for it
Luckily the new rt2x00 driver works a lot better and has none of the above problems - but it has more serious issues
- can hang the kernel hard
- no wpa_suppliant support yet
- connection drops for no good reason
I'll apply my final patch to svn later today and will be in baselayout-1.12.0_pre14 _________________ Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool |
|
Back to top |
|
|
thermoman n00b
Joined: 18 Aug 2004 Posts: 28
|
Posted: Tue Jan 10, 2006 1:03 pm Post subject: |
|
|
Tried rt2500 daily cvs from yesterday to check if the first hang is fixed - but this version was totally broken - iwlist ra0 scanning did hang ...
thermoman |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
randomeister n00b
Joined: 05 Jan 2005 Posts: 43
|
Posted: Sun Jan 22, 2006 4:30 pm Post subject: |
|
|
Hey! I had it working before, thanks to Uberlords patch, but I had to do an update of the system, in which baselayout was upgraded to 1.12.0_pre15, and now the same thing happens, i.e. no IP on boot, but when I start net.ra0 manually from a terminal, it works. Is this just happening to me? |
|
Back to top |
|
|
wizard69 Apprentice
Joined: 22 Sep 2003 Posts: 178 Location: Berlin
|
Posted: Mon Jan 23, 2006 10:24 am Post subject: |
|
|
No i can't seem to get it to work either. With dhcp the script hangs and i don't recieve an ip address. With a static address i can't ping my router wep works fine but i can't get wpa to work. Which is a shame because wep seems useless to me if it can be hacked within seconds. |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
Posted: Mon Jan 23, 2006 10:51 am Post subject: |
|
|
randomeister wrote: | Hey! I had it working before, thanks to Uberlords patch, but I had to do an update of the system, in which baselayout was upgraded to 1.12.0_pre15, and now the same thing happens, i.e. no IP on boot, but when I start net.ra0 manually from a terminal, it works. Is this just happening to me? |
How are you starting net.ra0 on boot?
pre15 fixes a bug where init scripts such as net.ra0 where being started too early by udev.
If you're using a file in /etc/modules.autoload.d to load the ra0 module then you'll need to add net.ra0 to the default runlevel. _________________ Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool |
|
Back to top |
|
|
randomeister n00b
Joined: 05 Jan 2005 Posts: 43
|
Posted: Mon Jan 23, 2006 12:52 pm Post subject: |
|
|
UberLord wrote: | How are you starting net.ra0 on boot?
pre15 fixes a bug where init scripts such as net.ra0 where being started too early by udev.
If you're using a file in /etc/modules.autoload.d to load the ra0 module then you'll need to add net.ra0 to the default runlevel.
|
I start rt2500 in /etc/modules.autoload.d/kernel-2.6 and net.ra0 at default runlevel.
Is there a specific version of udev I need to have to take advantage of that bug fix? |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
randomeister n00b
Joined: 05 Jan 2005 Posts: 43
|
Posted: Mon Jan 23, 2006 4:49 pm Post subject: |
|
|
Quote: | udev 079-r1 or 081-r1 use the fixed scripts |
No, sorry... I use udev 079-r1. Behaviour is as described above by thermoman, i.e. it blinks a couple of times during dhcpcd at startup, but no IP. Then I can easily restart net.ra0 post boot to get it working straight away. Anything else I can check? |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
randomeister n00b
Joined: 05 Jan 2005 Posts: 43
|
Posted: Mon Jan 23, 2006 6:25 pm Post subject: |
|
|
UberLord wrote: | Ah. First attempt to get dhcpcd always fails and a manual restart works. Known issue with the rt2500 driver I'm afraid :/ |
OK, curious in that case that it WAS working properly at bootup before I upgraded to baselayout 1.12.0_pre15. Unfortunately 1.12.0_pre14-r2 is removed, so I can't go back and check if that's what made the difference...
Anyway, thanks heaps UberLord! |
|
Back to top |
|
|
overkll Veteran
Joined: 21 Sep 2004 Posts: 1249 Location: Austin, Texas
|
Posted: Wed Jan 25, 2006 3:21 am Post subject: |
|
|
Just came across this post. Looks like I wasn't the only one trying to bring up ra0 the "Gentoo Way" with the baselayout's new wireless feature. I, however, was unable to do so.
I currently use the /etc/Wireless/RT2500STA/RT2500STA.dat file for the configuration of ra0 with a simple /etc/conf.d/net file (static ip). Im using WPAPSK with TKIP and it works like a charm. If anyone is interested in the details I'll post 'em.
iwpriv-usage.txt from the rt2500 tarball (both beta3 and cvs) instructs one to bring up the interface ra0 using the commands:
Code: | 1. iwconfig ra0 mode managed
2. iwpriv ra0 set AuthMode=WPAPSK
3. iwpriv ra0 set EncrypType=TKIP
4. iwpriv ra0 set WPAPSK="AP's wpa-preshared key"
5. iwconfig ra0 essid "AP's SSID" |
But what really works is:
Code: | 1. iwconfig ra0 mode managed
2. iwpriv ra0 set AuthMode=WPAPSK
3. iwpriv ra0 set EncrypType=TKIP
4. iwconfig ra0 essid "AP's SSID"
5. iwpriv ra0 set WPAPSK="AP's wpa-preshared key" |
Swaping steps 4 and 5 was suggested by the rt2500 dev.
Anyone want to test this to see if it holds true for their card/system as well?
Thermoman, if you swap steps 4 and 5 like above in your /etc/wireless/home script, does it make any difference? Do you still need to start it twice?
I've tested manually bringing up ra0 using the altered instructions I posted above with both dhcp and static ip configs and both work perfectly everytime (with WPA-TKIP). dhcp is of course slower since the client is waiting for the config info, but it doesn't hang.
Questions for Uberlord:
1. I'd like to try the new baselayout to use the "Gentoo Way" to bring up ra0. Are there any issues with any of the other (unstable ~) baselayout components that I should be aware of?
2. How do I get Gentoo's baselayout to execute the iwpriv/iwconfig commands in the order I desire? Is there a "Gentoo Way" or do I need a custom script for that?
3. Would you mind posting your ra0 specific config info ie /etc/conf/net and/or wireless? |
|
Back to top |
|
|
randomeister n00b
Joined: 05 Jan 2005 Posts: 43
|
Posted: Wed Jan 25, 2006 6:08 am Post subject: |
|
|
overkll wrote: | Swaping steps 4 and 5 was suggested by the rt2500 dev.
Anyone want to test this to see if it holds true for their card/system as well? |
I'll be friggin darned! It not only worked for me, it now boots up getting an IP adress! Thanks for the post, overkll!
I guess that also answers your question 2. It seems the order in thermoman's /etc/wireless/home above does matter. |
|
Back to top |
|
|
overkll Veteran
Joined: 21 Sep 2004 Posts: 1249 Location: Austin, Texas
|
Posted: Wed Jan 25, 2006 6:22 am Post subject: |
|
|
Quote: | I'll be friggin darned! It not only worked for me, it now boots up getting an IP adress! Thanks for the post, overkll! |
Ur welcome, randomeister. Looks like you beat me to the punch. I got curious and tried thermoman's solution. I had to remove the line:
from /etc/wireless/home and swap the steps like I suggested. Even reduced MY_SLEEP=3 to 0. Works for both dhcp and static ip. |
|
Back to top |
|
|
overkll Veteran
Joined: 21 Sep 2004 Posts: 1249 Location: Austin, Texas
|
Posted: Wed Jan 25, 2006 6:51 am Post subject: |
|
|
Found another solution. Its rather simple and probably good for a non-portable computer since it doesn't take profiles into account. I tried it the the current stable baselayout-1.11.14-r2 (x86)
Keep in mind, I dont use eth0 on this box, so /etc/init.d/eth0 is disabled.
/etc/conf.d/net:
Code: | modules=( "!iwconfig" )
# eth0
#config_eth0=( "10.0.0.8/24 brd 10.0.0.255" )
#routes_eth0=( "default via 10.0.0.1" )
#ra0
#config_ra0=( "dhcp" )
#dhcpcd_ra0="-R -N"
config_ra0=( "10.0.0.100/24 brd 10.0.0.255" )
routes_ra0=( "default via 10.0.0.1" )
preup () {
iwconfig ra0 mode managed
iwpriv ra0 set AuthMode=WPAPSK
iwpriv ra0 set EncrypType=TKIP
iwconfig ra0 essid "your ssid"
iwpriv ra0 set WPAPSK="your key"
# Remeber to return 0 on success
return 0
} |
Adjust ra0 to your network settings. I use a static address and leave the dhcp commented. That way if I want to change them, I just uncomment the dhcp settings and comment the static settings. |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
Posted: Wed Jan 25, 2006 10:16 am Post subject: |
|
|
overkll wrote: |
But what really works is:
Code: | 1. iwconfig ra0 mode managed
2. iwpriv ra0 set AuthMode=WPAPSK
3. iwpriv ra0 set EncrypType=TKIP
4. iwconfig ra0 essid "AP's SSID"
5. iwpriv ra0 set WPAPSK="AP's wpa-preshared key" |
Swaping steps 4 and 5 was suggested by the rt2500 dev.
Anyone want to test this to see if it holds true for their card/system as well?
|
Does it work if you do it in this order?
Code: | 1. iwconfig ra0 mode managed
2. iwconfig ra0 essid "AP's SSID"
3. iwpriv ra0 set AuthMode=WPAPSK
4. iwpriv ra0 set EncrypType=TKIP
5. iwpriv ra0 set WPAPSK="AP's wpa-preshared key" |
I ask as that's a very very simple code change and I can't test the rt2500 driver just yet. _________________ Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool |
|
Back to top |
|
|
wizard69 Apprentice
Joined: 22 Sep 2003 Posts: 178 Location: Berlin
|
Posted: Wed Jan 25, 2006 10:54 am Post subject: |
|
|
@overkil i am trying to use your script but all i get is "Invalid command : set" which seems to come from iwpriv does anyone have a clue. |
|
Back to top |
|
|
|