# [HOWTO] RaLink rt2500 with WPA-PSK + AES "The Gentoo Way"

## thermoman

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:

```
# echo 'net-wireless/rt2500 ~x86' >> /etc/portage/package.keywords
```

Emerge the package (version 1.1.0_beta3 at the time of this writing)

```
# 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:

```
# depmod -a
```

Try to load the module and check for the new device ra0:

```
# 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:

```
# 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'.

```
# 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

```
#!/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:

```
# 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

```
# 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

```
# cd /etc/init.d

# ln -s net.lo net.ra0
```

Now it's time to see if it works (cross your fingers  :Smile: )

```
/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  :Wink: 

Have fun with your wireless card  :Smile: 

Greetings,

thermoman.

----------

## UberLord

http://dev.gentoo.org/~uberlord/baselayout/iwconfig-rt2500.patch

Patch against baselayout-1.12.0_pre13 that allows my rt2500 to use WPA.

Sample config

```
iwpriv_ESSID=(

    "set AuthMode=WPAPSK"

    "set EncrypType=TKIP"

    "set WPAPSK=yourpasskey"

)
```

baselayout of course supports scanning and config selection via the iwconfig module so you no longer need the above script and/or modules=( "!iwconfig") directive.

If someone would like to try this patch out to verify it works, I'll slap it into the next baselayout release  :Smile: 

----------

## wizard69

@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

----------

## UberLord

 *wizard69 wrote:*   

> @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

 

No idea. My patch is not rt2500 specifc in any way, it just allows multiple iwpriv commands to work.

In theory it should work just fine.

Why don't you try it?   :Wink: 

----------

## thermoman

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:

```
# 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.

----------

## UberLord

 *thermoman wrote:*   

> The driver seems to go jumpy when issuing the iwconfig ra0 essid any command.

 

Comment out line the iwconfig ... any statement around line 432 of /lib/rcscripts/net.modules.d/iwconfig

However, I cannot get this working at all on my rt2500 pcmcia card at home :/

----------

## wizard69

@UberLord thanks for the answer what must i do to install your patch?

----------

## UberLord

cd /

patch -p0 < /path/to/patch

----------

## UberLord

OK, I just got this working  :Smile: 

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  :Sad: 

But atleast WPA now works for it  :Smile: 

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

----------

## thermoman

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

----------

## UberLord

afaik development on the rt2500 driver has stopped in favour of rt2x00, so don't expect anything to be fixed atm ...

----------

## randomeister

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?

----------

## wizard69

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.

----------

## UberLord

 *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.

----------

## randomeister

 *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?

----------

## UberLord

udev 079-r1 or 081-r1 use the fixed scripts

----------

## randomeister

 *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?

----------

## UberLord

Ah. First attempt to get dhcpcd always fails and a manual restart works. Known issue with the rt2500 driver I'm afraid :/

----------

## randomeister

 *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!

----------

## overkll

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:

```
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:

```
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?

----------

## randomeister

 *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.

----------

## overkll

 *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:

```
DEVICE=$1
```

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.

----------

## overkll

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:

```
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.

----------

## UberLord

 *overkll wrote:*   

> 
> 
> But what really works is:
> 
> ```
> ...

 

Does it work if you do it in this order?

```
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.

----------

## wizard69

@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.

----------

## overkll

 *Quote:*   

> Does it work if you do it in this order?
> 
> ```
> 1. iwconfig ra0 mode managed
> 
> ...

 

Uberlord, yes it does - for me anyway.  May want to confirm with others.  Im using

udev-079-r1

baselayout-1.11.14-r2

rt2500-1.1.0_beta3

----------

## overkll

 *wizard69 wrote:*   

> @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.

 

It isn't a script, its the /etc/conf.d/net file.  But anyway it looks like you may have a typo somewhere.  I recall the error you describe from about six months ago.  But I cant replicated it

Do you have any settings in /etc/conf.d/wireless?  I don't use the wireless file.

You may want to test manually before setting up in your /etc/conf.d/net file.  Also to test manually, comment out the preup function in /etc/conf.d/net.  

Unload the module if its loaded

```
modprobe -r rt2500
```

and comment out the preup function in /etc/conf.d/net.

```
#preup () {

#        iwconfig ra0 mode managed

#        iwpriv ra0 set AuthMode=WPAPSK

#        iwpriv ra0 set EncrypType=TKIP

#        iwconfig ra0 essid "homenet"

#        iwpriv ra0 set WPAPSK="thisismysupersecretpassphrase"

#        # Remeber to return 0 on success

#        return 0

#}
```

Then try issuing the 5 iwconfig/iwpriv commands manually.  If the module doesnt load automatically after the first iwconfig command, your should get an error:

```
Error for wireless request "Set Mode" (8B06) :

    SET failed on device ra0 ; No such device.
```

If it doesn't, load it

```
modprobe rt2500
```

Then issue the 5 commands

You should be able to track down the specific error that way.  Make sure that your essid and passphrase are in quotes.

Hope this helps

----------

## UberLord

 *overkll wrote:*   

>  *Quote:*   Does it work if you do it in this order?
> 
> ```
> 1. iwconfig ra0 mode managed
> 
> ...

 

Cool

Could you test that exact order off a clean boot without any net scripts (except lo) from starting (moving /lib/rcscripts/net.modules.d/iwconfig to a temp location works) please?

If you verify that it still works, I'll post a patch here so that baselayout-1.12 will do this  :Smile: 

----------

## overkll

 *Quote:*   

> Cool
> 
> Could you test that exact order off a clean boot without any net scripts (except lo) from starting (moving /lib/rcscripts/net.modules.d/iwconfig to a temp location works) please?
> 
> If you verify that it still works, I'll post a patch here so that baselayout-1.12 will do this 

 

Not sure I fully understand what you want, so I did the following.

1.  Moved /lib/rcscripts/net.modules.d/iwconfig to a temp location.

2.  Removed /etc/init.d/net.ra0 from all runlevels (only had default).

3.  Commented out my preup function in /etc/conf.d/net which contained the iwpriv/iwconfig commands.

4.  Rebooted

5.  Module was loaded but not configured.  Still in /etc/modules.autoload/kernel-2.6

6.  Manually ran commands in requested orded with both static and dhcp settings in /etc/conf.d/net

7.  Results - Successful

1.  Uncommented preup function with requested command order in /etc/conf.d/net - using static ip config

2.  Added /etc/init.d/net.ra0 to default runlevel

3.  Rebooted

4.  Results - Successful

1.  Ran /etc/init.d/net.ra0 stop, then start.  Successful

2.  Ran /etc/init.d/net.ra0 restart.  Sucessful

1.  Edited /etc/conf.d/net to use dhcp settings and rebooted.

2.  Result - Successful

1.  Ran /etc/init.d/net.ra0 stop, then start.  Successful

2.  Ran /etc/init.d/net.ra0 restart.  Sucessful

I think I covered the bases with those tests.  It all worked.

Note that I did update baselayout today to the lastest stable version 1.11.14-r3

I also have noticed that if the preup or any other config file like /etc/Wireless/RT2500STA/RT2500STA.dat are present upon the loading of the rt2500 module, the card is configured and "/etc/init.d/net.ra0 status" shows started, even though the command wasn't issued.  Don't worry, I had already renamed the .dat and .ui files so they wouldn't be used when the module was loaded.   :Wink: 

Hope this helps.

----------

## randomeister

 *overkll wrote:*   

>  *Quote:*   Does it work if you do it in this order?
> 
> ```
> 1. iwconfig ra0 mode managed
> 
> ...

 

Works fantastically well here too. I also set the SLEEP down to zero.

----------

## UberLord

OK, here's the patch for baselayout-1.12.0_pre15

http://dev.gentoo.org/~uberlord/baselayout/iwconfig.patch

I managed to test it with my rt2500 this morning, and it does work  :Smile:  Thanks for the ordering info guys!

It will be in pre16 and it will vanish from my web space when pre16 is released, just incase anyone asks me where it went  :Wink: 

----------

## overkll

 *UberLord wrote:*   

> OK, here's the patch for baselayout-1.12.0_pre15
> 
> http://dev.gentoo.org/~uberlord/baselayout/iwconfig.patch
> 
> I managed to test it with my rt2500 this morning, and it does work  Thanks for the ordering info guys!
> ...

 

Your welcome Uberlord, and thank you for intergrating it into Gentoo!  I should have spoke up 6 months ago!   :Embarassed: 

Is this a patch for pre15, pre15-r1 or both?

----------

## UberLord

 *overkll wrote:*   

> Your welcome Uberlord, and thank you for intergrating it into Gentoo!  I should have spoke up 6 months ago!   

 

Don't ask, don't get  :Razz: 

 *Quote:*   

> Is this a patch for pre15, pre15-r1 or both?

 

Both.

----------

## randomeister

Sorry to stir the pot again, but does that patch not include the original setup in this thread? Or does it just make the order of commands irrelevant in the wireless profile? I can see that it's a patch to iwconfig, but I'm not sure what it's changing...

----------

## overkll

 *randomeister wrote:*   

> Sorry to stir the pot again, but does that patch not include the original setup in this thread? Or does it just make the order of commands irrelevant in the wireless profile? I can see that it's a patch to iwconfig, but I'm not sure what it's changing...

 

If I understand correctly, the patch makes the baselayout work with the rt2500 driver work the "Gentoo Way" rendering custom scripts obsolete.  So one should be able to follow the docs and use /etc/conf.d/net and /etc/conf.d/wireless files as intended.  You shouldn't need the setup from the original post with the patch or next baselayout pre16.

That being said.... Uberlord have the config declarations changed from the current baselayout to this one?  Would you mind posting your config files relevant to the ra0 interface?

----------

## UberLord

 *overkll wrote:*   

> If I understand correctly, the patch makes the baselayout work with the rt2500 driver work the "Gentoo Way" rendering custom scripts obsolete.  So one should be able to follow the docs and use /etc/conf.d/net and /etc/conf.d/wireless files as intended.  You shouldn't need the setup from the original post with the patch or next baselayout pre16.

 

Correct. Although there is nothing rt2500 specific in baselayout, we have moved things around a little bit to cater for it without breaking anything else (hopefully).

 *Quote:*   

> That being said.... Uberlord have the config declarations changed from the current baselayout to this one?  Would you mind posting your config files relevant to the ra0 interface?

 

```
sleep_scan_ra0="5"

iwpriv_ESSID=(

   "set AuthMode=WPAPSK"

   "set EncrypType=TKIP"

   "set WPAPSK=ESSIDPASSPHRASE"

)

config_ESSID=( "dhcp" )

```

The above snippet is all I have in my config, and it works a champ  :Smile: 

----------

## overkll

 *Quote:*   

> 
> 
> ```
> sleep_scan_ra0="5"
> 
> ...

 

Uberlord, is this you /etc/conf.d/wireless file?

----------

## UberLord

Yes

----------

## overkll

Uberlord, I updated to latest unstable (~x86) baselayout-1.12.0_pre15-r1, etc-updated and applied your patch.  Seems the baselayout *won't* work with the rt2500 if the essid is hidden while issuing the commands manually does.

My /etc/conf.d/wireless (fake essid, passphrase)

```
sleep_scan_ra0="5"

essid_ra0="foo"

iwpriv_foo=(

        "set AuthMode=WPAPSK"

        "set EncrypType=TKIP"

        "set WPAPSK=passphraseforfoo"

)
```

/etc/conf.d/net

```
#ra0

config_ra0=( "10.0.0.100/24 brd 10.0.0.255" )

routes_ra0=( "default via 10.0.0.1" )
```

============================

with ssid broadcast disabled

============================

result of /etc/init.d/net.ra0 start (fake essid, mac address)

```
# /etc/init.d/net.ra0 start

 * Caching service dependencies ...                             [ ok ]

 * Starting ra0

 *   Loading networking modules for ra0

 *     modules: apipa arping macchanger macnet rename iwconfig 

essidnet iptunnel ifconfig system dhcpcd

 *       iwconfig provides wireless

 *       ifconfig provides interface

 *       dhcpcd provides dhcp

 *   Configuring ra0 for MAC address 00:XX:Xx:XX:XX:XX ...      [ ok ]

 *   Configuring wireless network for ra0

 *   Connecting to "foo" (WEP Disabled) ...                     [ !! ]

 *   Failed to configure wireless for ra0                       [ !! ]
```

============================

with ssid broadcast enabled

============================

```
# /etc/init.d/net.ra0 start

 * Starting ra0

 *   Loading networking modules for ra0

 *     modules: apipa arping macchanger macnet rename iwconfig 

essidnet iptunnel ifconfig system dhcpcd

 *       iwconfig provides wireless

 *       ifconfig provides interface

 *       dhcpcd provides dhcp

 *   Configuring ra0 for MAC address 00:XX:XX:XX:XX:XX ...      [ ok ]

 *   Configuring wireless network for ra0

 *   Connecting to "foo" (WEP Disabled) ...                     [ ok ]

 *     ra0 connected to "foo" at 00:XX:Xx:XX:XX:XX

 *     in managed mode on channel 3 (WEP disabled)

 *   Configuring ra0 for ESSID "foo" ...                        [ ok ]

 *   Bringing up ra0

 *     10.0.0.100/24                                            [ ok ]

 *   Adding routes

 *     default via 10.0.0.1 ...                                 [ ok ]
```

====================================

had to add essid_ra0="foo" or I would get error with

broadcast enabled

====================================

```
# /etc/init.d/net.ra0 start

 * Starting ra0

 *   Loading networking modules for ra0

 *     modules: apipa arping macchanger macnet rename iwconfig 

essidnet iptunnel ifconfig system dhcpcd

 *       iwconfig provides wireless

 *       ifconfig provides interface

 *       dhcpcd provides dhcp

 *   Configuring ra0 for MAC address 00:XX:XX:XX:XX:XX ...      [ ok ]

 *   Configuring wireless network for ra0

 *   Scanning for access points

 *     Found "foo" at 00:XX:XX:XX:XX:XX

 *   WEP key is not set for "foo" - not connecting

 *   Couldn't associate with any access points on ra0

 *   Failed to configure wireless for ra0                       [ !! ]

```

Now, If I just use this /etc/conf.d/net file with no /etc/conf.d/wireless:

/etc/conf.d/net

```
modules=( "!iwconfig" )

#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

        iwconfig ra0 essid "foo"

        iwpriv ra0 set AuthMode=WPAPSK

        iwpriv ra0 set EncrypType=TKIP

        iwpriv ra0 set WPAPSK="passphraseforfoo"

        # Remeber to return 0 on success

        return 0

}
```

===================================

and issue /etc/init.d/net.ra0 start with the essid hidden

ie ssid brodcast disabled

===================================

```
# /etc/init.d/net.ra0 start

 * Caching service dependencies ...                             [ ok ]

 * Starting ra0

 *   Loading networking modules for ra0

 *     modules: apipa arping essidnet iptunnel macchanger macnet 

rename ifconfig system dhcpcd

 *       ifconfig provides interface

 *       dhcpcd provides dhcp

 *   Running preup function                                     [ ok ]

 *   Configuring ra0 for ESSID "foo" ...                        [ ok ]

 *   Configuring ra0 for MAC address 00:XX:XX:XX:XX:XX ...      [ ok ]

 *   Bringing up ra0

 *     10.0.0.100/24                                            [ ok ]

 *   Adding routes

 *     default via 10.0.0.1 ...                                 [ ok ]
```

Is your ssid hidden?  Im guessing its not.  Maybe the code change may be a little tricker than expected.

Thanks for the hard work you do for all us Gentoo users.

----------

## UberLord

I cannot make rt2500 work unless SSID broadcast is enabled. That's not using any of this, just simple commands like you used.

Basically when we are associated, iwconfig reports the MAC address of the AP it's associated with. If it does not then we assume that we are not associated. My prism54 card works fine, it's just 2500 that does not so I'm guessing it's a driver bug.

Besides, not broadcasting the SSID does not make it any safer really.

At this time, you have to set a WEP key when scanning even if you're using WPA and not WEP. This bypasses the error mentioned. I may make it skip the error and continue if there's a set WPAPSK= in iwpriv_ESSID though.

----------

## overkll

 *Quote:*   

> I cannot make rt2500 work unless SSID broadcast is enabled. That's not using any of this, just simple commands like you used. 

 

Really?  Mine works perfectly with the commands.  Has for about a year.  Maybe its card or AP specific or both.

 *Quote:*   

> Besides, not broadcasting the SSID does not make it any safer really.

 

Doesn't WPA take the SSID and the passphrase to hash a 256 bit key to be used for authentication?

BTW, app-admin/apg (automatic password generator) is great for 63 character WPA keys.

```
# apg -n1 -m63

jaidjagauloiddyodobNekyitghibwaytJesactyiac%odbifNewJeaquagCev7
```

Hopefully the rt2x00 beta4 will integrate better into the baselayout.  Thanks again for your efforts.

P.S.  With baselayout-1.12.0_pre15-r1, my courier-imapd wouldn't start.  Courier-authlib would, but not courier-imapd.  Switched back to baselayout-1.11.14-r3 and courier-imap started no problem.

----------

## randomeister

 *overkll wrote:*   

>  *Quote:*   I cannot make rt2500 work unless SSID broadcast is enabled. That's not using any of this, just simple commands like you used.  
> 
> Really?  Mine works perfectly with the commands.  Has for about a year.  Maybe its card or AP specific or both.

 

Interesting, I've got three wireless connections running - one Centrino laptop, one laptop with the rt2500 and one NetGear USB dongle. None of them work unless I turn SSID broadcast on!

----------

## UberLord

 *overkll wrote:*   

>  *Quote:*   I cannot make rt2500 work unless SSID broadcast is enabled. That's not using any of this, just simple commands like you used.  
> 
> Really?  Mine works perfectly with the commands.  Has for about a year.  Maybe its card or AP specific or both.

 

I would say both as my prism54 can associate with my DrayTek with hidden SSID but not with my brothers D-LINK AP when it hides SSID.

 *Quote:*   

>  *Quote:*   Besides, not broadcasting the SSID does not make it any safer really. 
> 
> Doesn't WPA take the SSID and the passphrase to hash a 256 bit key to be used for authentication?

 

Yes it does. However, obtaining the SSID can still be sniffed trivially afaik. If you're that paranoid then you'd run unsecured wireless with a honeypot and run the real traffic encrypted through a tunnel - say use openvpn.

 *Quote:*   

> Hopefully the rt2x00 beta4 will integrate better into the baselayout.  Thanks again for your efforts.

 

I know it will  :Smile:  However,  I'm waiting for rt2x00 wpa_supplicant support first!

 *Quote:*   

> P.S.  With baselayout-1.12.0_pre15-r1, my courier-imapd wouldn't start.  Courier-authlib would, but not courier-imapd.  Switched back to baselayout-1.11.14-r3 and courier-imap started no problem.

 

courier-imap sucks, change to dovecot.

Aside from that, open a bug on bugs.gentoo.org

----------

## UberLord

 *randomeister wrote:*   

>  *overkll wrote:*    *Quote:*   I cannot make rt2500 work unless SSID broadcast is enabled. That's not using any of this, just simple commands like you used.  
> 
> Really?  Mine works perfectly with the commands.  Has for about a year.  Maybe its card or AP specific or both. 
> 
> Interesting, I've got three wireless connections running - one Centrino laptop, one laptop with the rt2500 and one NetGear USB dongle. None of them work unless I turn SSID broadcast on!

 

Is that using gentoo scripts, direct commands or something else?

----------

## wizard69

i am wondering if someone can help me i am using a Linksys wusb54g v4 with the rt2570 driver. I can connect to my AP with WEP but i can't seem to be able to connect with WPA.

My /etc/conf.d/net

# eth0

#########

config_eth0=( "192.168.1.10/24" )

routes_eth0=( "default via 192.168.1.200" )

#config_eth0=( "dhcp" )

# wusb54g Wireless

#########

config_rausb0=( "dhcp" )

My /etc/conf.d/wireless

mode_rausb0="Managed"

channel_rausb0="11"

associate_order_rausb0="forcepreferred"

preferred_aps=( "linux" )

iwpriv_linux=(

"set AuthMode=WPAPSK"

"set EncrypType=TKIP"

"set WPAPSK=mypassword"

)

when i start the device i get:

/etc/init.d/net.rausb0 start

  * Service net.rausb0 starting

 Trying to force preferred in case they are hidden

Invalid command : set

 rausb0 does not support the following private ioctls

   set AuthMode=WPAPSK

Invalid command : set

 rausb0 does not support the following private ioctls

   set EncrypType=TKIP

Invalid command : set

is this a driver problem perhaps the driver i am using does not support authentication with WPA ?

----------

## UberLord

http://rt2x00.serialmonkey.com/wiki/index.php/Mandrake_10_rt2570_Howto

Looks like WPA works but the syntax is different.

----------

## randomeister

 *UberLord wrote:*   

>  *randomeister wrote:*   Interesting, I've got three wireless connections running - one Centrino laptop, one laptop with the rt2500 and one NetGear USB dongle. None of them work unless I turn SSID broadcast on! 
> 
> Is that using gentoo scripts, direct commands or something else?

 

Scripts, according to different forums, howtos and wiki docs around the gentoo community. The centrino runs ipw2200 and wpa_supplicant, and the dongle runs ndiswrapper and wpa_supplicant.

I'm still not out of the water with the rt2500 though. I've got two wireless networks here, one internet AP and one LAN with a wirelss router (linksys). Now, I want to route all my wireless traffic through the LAN, so that I can access all the services on the server from the lan side as well as get the internet access. So I want to simply change the SSID to get to the LAN wireless instead, since the same settings apply for both APs.

That worked a charm for the Centrino. Not a hangup. However, when I tried with the rt2500, I don't get anything but a flashing card. It simply stops at dhcpcd. If I go back to the old SSID, it all works again. 

First with the "failing" SSID:

```
iwconfig ra0

ra0       RT2500 Wireless  ESSID:"Rednet"  

          Mode:Managed  Frequency=2.412 GHz  Bit Rate:36 Mb/s  

          RTS thr:off   Fragment thr:off

          Encryption key:off

          Link Quality=41/100  Signal level=-51 dBm  Noise level:-194

          dBm

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
```

Then with the old "successful" SSID:

```
iwconfig ra0

ra0       RT2500 Wireless  ESSID:"Johan"  

          Mode:Managed  Frequency=2.462 GHz  Access Point:

          00:14:6C:21:CE:50  

          Bit Rate:54 Mb/s  

          RTS thr:off   Fragment thr:off

          Encryption key:off

          Link Quality=45/100  Signal level=-73 dBm  Noise level:-192

          dBm

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
```

Interestingly, if I run iwconfig WHILE the card is flashing, I get the correct AP address. 

I've also made sure that no MAC filtering is set in the router. And I ran a test with security all off, and I had no problem connecting to the router. Any ideas? I've done everything according to this thread.

----------

## overkll

Randomeister,

Figure out which commands you have to run manually, and in what order.  Then just use /etc/conf.d/net file that implements the preup function like I listed above.  Don't forget to have

```
modules=( "!iwconfig" )
```

in the net file and to rename or move the wireless file to prevent the baselayout script from interfering with initialization.

You may also want to try a static IP address that is in your LAN's address range and specify the route to the internet gateway.

EDIT:  Randomeister, have you tried emerging the rt2570 with the "qt" use flag?  This will give you a QT based GUI to configure the card and requires only a simple /etc/conf.d/net file.  The module is configured upon loading with the /etc/Wireless/RT2500STA/RT2500STA.dat file that is created by the GUI.  I don't know how well it works with the USB chip, but it works perfectly with my PCI based card (rt2500).

Uberlord,

I think there is a problem with the way baselayout scripts use iwconfig as far as RaLink chipsets are concerned.  I have a Hawking PCI card, and it works flawlessly with manual commands or with the RT2500STA.dat config file.  Both methods can connect to a hidden ssid using WPAPSK with TKIP, for both DHCP and static address.  However, with the baselayout scripts using the wireless file, it cannot connect to an AP with a hidden ssid but it can connect to an AP with a visible ssid (ssid broadcast enabled).

 *Uberlord wrote:*   

> I cannot make rt2500 work unless SSID broadcast is enabled. That's not using any of this, just simple commands like you used.
> 
> Basically when we are associated, iwconfig reports the MAC address of the AP it's associated with. If it does not then we assume that we are not associated. My prism54 card works fine, it's just 2500 that does not so I'm guessing it's a driver bug. 

 

This is a problem.  If a connection to an AP with a hidden ssid using WPA with TKIP cannot be established with the manual commands, how can you properly test the scripts?

Does your card have any known issues?  Is it PCI, PCMCIA, or built in to a laptop?  Have you tried it with a different AP?  Is your AP WPA standard compliant?

----------

## randomeister

 *overkll wrote:*   

> Figure out which commands you have to run manually, and in what order.  Then just use /etc/conf.d/net file that implements the preup function like I listed above.  Don't forget to have
> 
> ```
> modules=( "!iwconfig" )
> ```
> ...

 

Yup, tried all of that!

 *overkll wrote:*   

> EDIT:  Randomeister, have you tried emerging the rt2570 with the "qt" use flag?  This will give you a QT based GUI to configure the card and requires only a simple /etc/conf.d/net file.  The module is configured upon loading with the /etc/Wireless/RT2500STA/RT2500STA.dat file that is created by the GUI.  I don't know how well it works with the USB chip, but it works perfectly with my PCI based card (rt2500).

 

I don't have an rt2570, I think you're confusing it with someone else who's posting here. Mine is a Cardbus rt2500 sitting in a Thinkpad.

Yes, I did try the QT interface, with the same results. Thanks for your ideas though! Anything else I can try/show the output of?

It works in Windows XP with this card/AP combination, so I don't think there's any reason why it shouldn't work.

----------

## UberLord

 *overkll wrote:*   

>  *Uberlord wrote:*   I cannot make rt2500 work unless SSID broadcast is enabled. That's not using any of this, just simple commands like you used.
> 
> Basically when we are associated, iwconfig reports the MAC address of the AP it's associated with. If it does not then we assume that we are not associated. My prism54 card works fine, it's just 2500 that does not so I'm guessing it's a driver bug.  
> 
> This is a problem.  If a connection to an AP with a hidden ssid using WPA with TKIP cannot be established with the manual commands, how can you properly test the scripts?

 

I test them properly with my madwifi and prism54 cards - both of which work when SSID broadcast is disabled. Hence, seeing as the only card I have which does not work with SSID broadcast disabled is my rt2500 then I will assume that it's a driver bug

 *Quote:*   

> Does your card have any known issues?  Is it PCI, PCMCIA, or built in to a laptop?  Have you tried it with a different AP?  Is your AP WPA standard compliant?

 

No know issues, it's PCMCIA and yes it could be an AP issue too as I only have DrayTek Vigor Wirless AP/Routers to test against.

----------

## thermoman

In what baselayout version is this patch included to get the card up already at the first time?

----------

## UberLord

baselayout-1.12.0_pre16 and later have it.

----------

## HotBBQ

Just wanted to post a "me too".  It took me a while to parse this thread and figure out where to put things.  I got it to work by using the following:

/etc/conf.d/net

```
modules=( "!iwconfig" )

config_ra0=( "dhcp" )

dhcpcd_ra0="-R -N"

preup () {

        iwconfig ra0 mode managed

        iwconfig ra0 essid "myssid"

        iwpriv ra0 set AuthMode=WPAPSK

        iwpriv ra0 set EncrypType=TKIP

        iwpriv ra0 set WPAPSK="mypasskey"

        return 0

}

```

I had some problems getting the script to work because I had forgotten to remove wpa_supplicant.  After removing it, the script work perfectly.  Thanks overkll and UberLord!  Your hard work is greatly appreciated.

----------

## yoyo

Hi HotBBQ and every others !   :Wink: 

I recently bought an rt2570 based chipset (which is a rt2500 on usb) and tried your way of configure it but it still doesn't work ...   :Crying or Very sad: 

I've got some "iwpriv : unknown parameter "set"" or something like this.

I find an other way to use iwpriv but an other problem appear in setting "mypasskey" : iwpriv complain that it may be 64 char long (and of course it wasn't). I don't want to change "mypasskey" on all other clients and think I may have to crypt my passkey (which is an ascii passkey) but don't know how to do.

Can someone help me ?

 *HotBBQ wrote:*   

> Thanks overkll and UberLord! Your hard work is greatly appreciated.

 ++   :Very Happy: 

----------

## HotBBQ

Not sure if this is relevant or not, but I was unable to get this driver to work unless I deleted a wireless configuration file.  The file in question gets created any time you emerge rt2500.

```
/etc/Wireless/RT2500STA/RT2500STA.dat
```

Once I deleted this file everything worked for me as I posted earlier.  Try looking for your specific version, too.

----------

## yoyo

This file is provided by rt2500 ebuild/module only. I only have rt2570.ko and docs files.

What I do is exactly this :

```
1 - iwpriv rausb0 auth 3

2 - iwconfig rausb0 essid "myessid"

3 - iwpriv rausb0 wpapsk 12345678

4 - iwconfig rausb0 essid "myessid"
```

But after point 3 it complain that "The command wpapsk needs exactly 64 argument(s) ..."

----------

## HotBBQ

Maybe try formatting the commands differently?  Try using the format in my net file.  In case it wasn't obvious, I'm only guessing here.   :Cool: 

```
iwpriv rausb0 set WPAPSK="mypasskey"
```

----------

## yoyo

That's what I tried first ... and got warnings about the "set" parameter unknown by iwpriv ...

----------

## Allochtoon

I followed the things in the first post. This is what i get. I have another wireless card which is working plugged in aswell.

```
barbadelhi marco # /etc/init.d/net.ra0 start

 * Starting ra0

 *   Loading networking modules for ra0

 *     modules: macchanger wpa_supplicant essidnet iptunnel ifconfig bridge dhcpcd apipa

 *       wpa_supplicant provides wireless

 *       ifconfig provides interface

 *       dhcpcd provides dhcp

 *   Running preup function

 *     Loading WLAN profile 'home'

 *   Starting wpa_supplicant on ra0 ...

 *   wpa_supplicant_ra0 does not define a driver

ioctl[PRISM2_IOCTL_HOSTAPD]: Operation not supported

Failed to set encryption.

ioctl[PRISM2_IOCTL_HOSTAPD]: Operation not supported

Failed to set encryption.

ioctl[PRISM2_IOCTL_HOSTAPD]: Operation not supported

Failed to set encryption.

ioctl[PRISM2_IOCTL_HOSTAPD]: Operation not supported

Failed to set encryption.

 *     Waiting for association                                            [ ok ]

 *     timed out  
```

And my /etc/conf.d/net:

```
config_wlan0=( "dhcp" )

mode_wlan0="managed"

modules=( "wpa_supplicant" )

wpa_supplicant_wlan0="-Dwext"

wpa_timeout_wlan0=60

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

}

```

Note the:  wpa_supplicant_ra0 does not define a driver 

Should i just upgrade to the new baselayout, and can that break my system?

----------

## UberLord

 *Allochtoon wrote:*   

> I followed the things in the first post. This is what i get. I have another wireless card which is working plugged in aswell.

 

rt2500 does support WPA, but not wpa_supplicant

----------

## UberLord

 *yoyo wrote:*   

> This file is provided by rt2500 ebuild/module only. I only have rt2570.ko and docs files.
> 
> What I do is exactly this :
> 
> ```
> ...

 

OK, so the config you want is

```
iwpriv_rausb0=( "wpapsk 12345" )
```

12345 probably has to be a 64-bit HEX key generated from the PSK/ESSID.

I'd check the rt2x00 forums for more information on this though

----------

## overkll

yayo, which driver are you using?  Are you using the rt2x00 ebuild?  You may want to try the driver specific for the rt2570 chipset.  I don't think it is in portage.  You'll need to download it from serialmonkey's website and compile manually.  I'd also check the forums there.

----------

## ssvb

I'm also having problems trying to make rt2570 work (dlink dwl-g122 rev. b). The sympthoms are the same as yoyo describes. Also compiling and using rt2570-cvs-daily.tar.gz locks up keyboard on inserting usb device. Maybe there are some kernel compilation options that are not compatible with this driver? At least I have SMP and preemption disabled.

----------

## overkll

I thought I remember an issue regarding problems with hardware detection with some of the newer ralink usb chipsets.  Yep, check this post.  Could it be you have an rt73?

----------

## Hossie

Today I installed Gentoo on my laptop because I found this thread and hoped my WLAN would work now.

This is what I do:

```
ifconfig ra0 up

iwconfig ra0 mode managed

iwconfig ra0 essid "Hossies Netz"

iwpriv ra0 set AuthMode=WPAPSK

iwpriv ra0 set EncrypType=TKIP

iwpriv ra0 set WPAPSK=xyz

dhcpcd -R -N -d ra0
```

DHCP tells me:

```
Info, MAC address: xyz

Debug, broadcasting DHCP_DISCOVER

Error, timed out waiting for a valid DHCP server response
```

It just dont work.

With the script from the startpost I get:

```
/etc/wireless/_: unknown interface: No such device
```

 :Confused: 

Edit: Ok I found the error in the script from the startpost, but same problem: DHCP wont get an answer.

----------

## yoyo

Fist, I would apologize for rpelying so late.

 *UberLord wrote:*   

> OK, so the config you want is
> 
> ```
> iwpriv_rausb0=( "wpapsk 12345" )
> ```
> ...

 I tried this without success. But I'm not sure to have used the good way of generating this 64-bit HEX key. This is how I proceed : 

```
# emerge net-wireless/wpa_supplicant

# wpa_passphrase myessid mypassphrase

network={

        ssid="myessid"

        #psk="mypassphrase"

        psk=2a264c5e1a4313cfd4d2d262882cb4587d02235411bd234987a12bf0b150821a

}
```

And I used this pre-shared key (without success). I have to say that this key was not generated on the computer in which the usb wifi key is plugged. May be it has some importance maybe not. Does someone know that plesae ?

@overkll : rt2570 module is in portage tree :

```
eix rt2570

* net-wireless/rt2570

     Available versions:  1.1.0_beta1

     Installed:           1.1.0_beta1

     Homepage:            http://rt2x00.serialmonkey.com

     Description:         Driver for the RaLink RT2570 USB wireless chipset
```

  :Wink: 

@ssvb : I've got some keyboard locks up too. But It was when I unplugged my usb key (always) and sometimes when I restart my net.rausb0 (and in this case always when halting net.rausb0). I would say that magic sys keys still work.

@overkll : thanks for pointing this way. I will check that my usb key is a rt2570 nor a rt73.

@ALL : I have to precise that I didn't use any dhcp (it is cut off on my router) and that I use a static way to configure my wireless network (in this case the computer will never move from my appartment).

And thanks a lot !

----------

## yoyo

 *yoyo wrote:*   

> @overkll : thanks for pointing this way. I will check that my usb key is a rt2570 nor a rt73.

 It seems it's a rt2570. I tried with rt2x00-9999 (rt2x00-2.0.0_beta3 compile breaks) and wpa_supplicant without success.

But I'm on the edge and will try everything possible (ralink website'modules). So if you've got some ideas I'm ready to try its ...

Enjoy !

----------

## overkll

 *yoyo wrote:*   

>  *yoyo wrote:*   @overkll : thanks for pointing this way. I will check that my usb key is a rt2570 nor a rt73. It seems it's a rt2570. I tried with rt2x00-9999 (rt2x00-2.0.0_beta3 compile breaks) and wpa_supplicant without success.
> 
> But I'm on the edge and will try everything possible (ralink website'modules). So if you've got some ideas I'm ready to try its ...
> 
> Enjoy !

 

Bummer.  IMHO, the hardware detection problem makes it very difficult to know for sure.  

I'm curious.  Have you tried the QT based gui utility RaConfig (USE= qt) ?  If you want to try it, make sure to delete the " .DAT " file.  The utility will create a new one.  You'll also need to make sure not to have any wireless specific variables in /etc/conf.d/net or /etc/conf.d/wireless.  This is what I use as I find it to be the most reliable and consistent method.  YMMV.

Have you tried disabling encryption on your AP then trying to connect without encryption?

As far as the passphrase is concerned, AFAIK WPA-PSK passphrases must be 8-63 characters.  64 is too long.  The apg proggy is good for generating passphrases.  Its in portage.

```
# apg -m63 -n1

ligTiojHoviktyufdashicwuztUfkuptAlsyuripulyosShakanigCeumKidjec
```

----------

## yoyo

 *overkll wrote:*   

> I'm curious.  Have you tried the QT based gui utility RaConfig (USE= qt) ?  If you want to try it, make sure to delete the " .DAT " file.  The utility will create a new one.

 Unfortunately this RaConfig wasn't build with latest rt2500/rt2570 yet (while "qt" USEflag is enabled).

 *overkll wrote:*   

> You'll also need to make sure not to have any wireless specific variables in /etc/conf.d/net or /etc/conf.d/wireless.  This is what I use as I find it to be the most reliable and consistent method.  YMMV.

 Here they are :

```
#/etc/conf.d/net

config_ra0=( "192.168.0.X netmask 255.255.255.0 broadcast 192.168.0.255" )

routes_ra0=(

   "default via 192.168.0.250"

)

modules=( "!iwconfig" "!wpa_supplicant" )

#/etc/conf.d/wireless

mode_rausb0="managed"

channel_rausb0="11"

iwconfig_ra0=( "192.168.0.X netmask 255.255.255.0 broadcast 192.168.0.255" )

preup () {

        iwconfig rausb0 mode managed 

        iwconfig rausb0 auth 2

        iwconfig rausb0 enc 3

        iwconfig rausb0 essid "myessid"

        iwpriv rausb0 wpapsk mypresharedkey-build-with-apg

        iwconfig rausb0 essid "myessid"

        return 0

}
```

As I can see now it is not really clean   :Confused:  . Static IP is set two times (with ifconfig and iwconfig if I understand well) and more curious iwconfig module is unloaded ...   :Shocked: 

 *overkll wrote:*   

> Have you tried disabling encryption on your AP then trying to connect without encryption?

 I'll try it asap.

 *overkll wrote:*   

> As far as the passphrase is concerned, AFAIK WPA-PSK passphrases must be 8-63 characters.  64 is too long.  The apg proggy is good for generating passphrases.

 Thanks for this tip, I didn't know this really cool soft.

----------

## Hossie

This is such a stupid driver. I think Ill smash the stupid card soon. I compiled X and rt2500 with qt now. RaConfig2500 can connect to open APs without problems now. My AP with WPA still doesnt work. I tried "WPA/WPA2 PSK", "WPA2/PSK" (doesnt work at all), "b/g mixed" and "g only". RaConfig says you are connected, the LED fires up, and a green handshake icons appears. dhcpcd still fails.  :Evil or Very Mad: 

----------

## Hossie

It just dont work with the opensource driver. Follow the really easy steps from the ndiswrapper tutorial and you will have a working wlan-card in 10min. I have installed Debian Etch now (Gentoo just takes too long to install), and got the card working in 10min (with self-compiled ndiswrapper 1.17 and wpasupplicant from Etch) WITH WPA/TKIP!!!

I still cant believe it how easy it was.  :Very Happy: 

----------

## yoyo

@hossie : I don't understand why you couldn't connect to your AP with wpa/tkip with native linux rt2500 module while I've got no problem for this (with rt2500, not rt2570  :Wink:  ).

It may comes from your AP response time. I've read when I search on my rt2570 problem that some people as to add a sleep in their startup scripts to let their AP associate.

You may look at (start at middle post, upper part is to install driver on ubuntu) : http://61.222.76.235/phpbb2/viewtopic.php?t=1237 (ralink linux support forum).

Enjoy !

----------

## yoyo

 *yoyo wrote:*   

>  *overkll wrote:*   Have you tried disabling encryption on your AP then trying to connect without encryption? I'll try it asap.

 It works like a charm ...   :Confused: 

I filter connexions by MAC address but if I really want a secured wifi with wpa-psk. But I'm out of idea now ...   :Sad: 

----------

## UberLord

 *yoyo wrote:*   

> but if I really want a secured wifi with wpa-psk. But I'm out of idea now ...  

 

So do what I do - run an open, insecure wifi but use openvpn to secure traffic.

----------

## yoyo

 *UberLord wrote:*   

>  *yoyo wrote:*   but if I really want a secured wifi with wpa-psk. But I'm out of idea now ...   
> 
> So do what I do - run an open, insecure wifi but use openvpn to secure traffic.

 I could not choose this option cause I *know* that rt2570 support wpa encrytion and I *want* my card to do it.   :Rolling Eyes: 

And when (not if  :Wink:  ) it works I'll give a feedback here.

Enjoy !

----------

## UberLord

openvpn encryption > wpa psk/tkip   :Wink: 

But enjoy your quest for working WPA anyway  :Smile: 

----------

## yoyo

 *UberLord wrote:*   

> openvpn encryption > wpa psk/tkip   

 I don't know openvpn (features and how it works) but I don't wan't one more deamon running on my little headless server so I want to use maximums hardwares capabilities.

 *UberLord wrote:*   

> But enjoy your quest for working WPA anyway 

 Thanks.   :Wink: 

----------

## UberLord

 *yoyo wrote:*   

> But I don't wan't one more deamon running on my little headless server so I want to use maximums hardwares capabilities.

 

Sometimes the encryption is done in software instead of hardware ........ not many linux drivers actually support hardware encrption for WPA.

----------

## mcuddy

The Howto worked great... almost

My belkin network card (rt2500) rarely worked under win, but it now works well under Linux! Thanks!! The only problem is: when I furst boot up, the net.ra0 script doesn't grab an IP via dhcp. I must run /etc/init.d/net.ra0 restart (or start) to get the IP.

Initial ifconfig:

# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0C:41:23:37:53  

          inet addr:192.168.2.3  Bcast:192.168.2.255  Mask:255.255.255.0

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:10 errors:0 dropped:0 overruns:0 frame:0

          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:1231 (1.2 Kb)  TX bytes:1118 (1.0 Kb)

          Interrupt:11 Base address:0x4000 

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

ra0       Link encap:Ethernet  HWaddr 00:11:50:65:BA:F5  

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:25 errors:0 dropped:0 overruns:0 frame:0

          TX packets:124 errors:0 dropped:0 overruns:0 carrier:0

          collisions:1 txqueuelen:1000 

          RX bytes:3242 (3.1 Kb)  TX bytes:8255 (8.0 Kb)

          Interrupt:10 

# /etc/init.d/net.ra0 restart

 * Starting ra0

 *   Running preup function

 *     Loading WLAN profile 'home'

 *   Bringing up ra0

 *     dhcp

 *       Running dhcpcd ...                                               [ ok ]

 *       ra0 received address 192.168.2.4

# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0C:41:23:37:53  

          inet addr:192.168.2.3  Bcast:192.168.2.255  Mask:255.255.255.0

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1701 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1167 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:1705858 (1.6 Mb)  TX bytes:218006 (212.8 Kb)

          Interrupt:11 Base address:0x4000 

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

ra0       Link encap:Ethernet  HWaddr 00:11:50:65:BA:F5  

          inet addr:192.168.2.4  Bcast:192.168.2.255  Mask:255.255.255.0

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:112 errors:0 dropped:0 overruns:0 frame:0

          TX packets:498 errors:0 dropped:0 overruns:0 carrier:0

          collisions:5 txqueuelen:1000 

          RX bytes:15428 (15.0 Kb)  TX bytes:34451 (33.6 Kb)

          Interrupt:10 

Any idea how to avoid or automate this process?  (if it's not just me, it could be added to this wonderful howto).

----------

## UberLord

 *mcuddy wrote:*   

> The only problem is: when I furst boot up, the net.ra0 script doesn't grab an IP via dhcp. I must run /etc/init.d/net.ra0 restart (or start) to get the IP.

 

What part fails? scanning, associating or dhcp?

----------

## mcuddy

not sure: how do I tell (I'm not very familiar with log files)? I assumed it was dhcp, but under win, scanning was what always failed. Today, when I did an ifconfig after bootup, there was no mention of the ra0 device at all. It showd up after I restarted the service. It seemed the service never started.  Any ideas?

----------

## dspgen

just used this to setup:

ASUS WL-107G IEEE802.11g Wireless Cardbus Adapter

net-wireless/rt2500-1.1.0_beta4

sys-apps/ethtool-4

ASUS WL-500G Premium IEEE 802.3/3u, IEEE 802.11b/g Wireless Router

Configured as AP/bridge

WPA-PSK/AES

worked great

----------

## mcuddy

Sory, but much of this is new to me. I'm assuming that those lines are part of a configuration file somewhere. If so, what file and where? If not, how do I set those settings?

----------

## kenyon

 *UberLord wrote:*   

> Sample config
> 
> ```
> iwpriv_ESSID=(
> 
> ...

 

No, modules_ra0=("!iwconfig") is needed.  Without that, my rt2500 doesn't initialize properly -- it all looks OK, except it appears to be sending a constant stream of data to nowhere (monitoring traffic using gkrellm2), and network access doesn't work.  Using baselayout-1.12.9-r2.

What I did was delete /etc/Wireless/RT2500STA/RT2500STA.dat then modprobe -r rt2500 so that we're starting from a clean slate.  Then modprobe rt2500, then ifconfig ra0 up.  Then run RaConfig2500 and create a profile and activate it and check on the status tab that you have a radio connection to the access point.  RaConfig2500 creates a proper /etc/Wireless/RT2500STA/RT2500STA.dat for you.  I'm using WPA and TKIP, so my dat file looks like this:

```
[Default]

CountryRegion=0

ProfileID=PROF001

SSID=myssid

NetworkType=Infra

PreambleType=Auto

RTSThreshold=2312

FragThreshold=2312

AuthMode=WPAPSK

EncrypType=TKIP

WPAPSK=mypassphrase

Channel=0

PSMode=CAM
```

Then my /etc/conf.d/net contains only this (I'm using a static IP address):

```
modules_ra0=("!iwconfig")

config_ra0=("192.168.0.50 netmask 255.255.255.0")

routes_ra0=("default gw 192.168.0.1")
```

Then /etc/init.d/net.ra0 start works.

Baselayout with the iwconfig module does something that kills the rt2500 device.

BTW, I'm sure an insecure wireless network with openvpn is better, but then you need a Linux box connected via wired Ethernet to the access point, right? I happen to have that now, but it's a really slow Linux box, and it's someone's desktop, so it's prone to being rebooted.

----------

## Kasumi_Ninja

Which kernel options should I enable and where can I find them? Gentoo Manual mentions:

```
 You have to have CONFIG_PACKET enabled in your kernel for wpa_supplicant to work. 
```

And the realink rt2570 ebuild mentiones:

```
* Checking for suitable kernel configuration options...

 *   CONFIG_WIRELESS_EXT:        is not set when it should be.

 *   SMP Processors and Kernels are currently not supported
```

----------

## Kasumi_Ninja

Thanks to the excellent book 'the Linux kernel in a nutshell'  I found some of the options (but no wpa   :Crying or Very sad: ):

```

  │ │                                     <M>   Generic IEEE 802.11 Networking Stack                                                                 │ │

  │ │                                     [ ]     Enable full debugging output (NEW)                                                                 │ │

  │ │                                     ---     IEEE 802.11 WEP encryption (802.1x)                                                                │ │

  │ │                                     <M>     IEEE 802.11i CCMP support                                                                          │ │

  │ │                                     <M>     Software MAC add-on to the IEEE 802.11 networking stack                                            │ │

  │ │                                     [ ]       Enable full debugging output (NEW)                                                               │ │

  │ │                                                                                                                                                │ │
```

Got it! I need first to enable 

```
  Wireless LAN (non-hamradio)  --->
```

Before I get more options:

```

  │ │                                     < >   Bluetooth subsystem support  --->                                                                    │ │

  │ │                                     <M>   Generic IEEE 802.11 Networking Stack                                                                 │ │

  │ │                                     [ ]     Enable full debugging output (NEW)                                                                 │ │

  │ │                                     ---     IEEE 802.11 WEP encryption (802.1x)                                                                │ │

  │ │                                     <M>     IEEE 802.11i CCMP support                                                                          │ │

  │ │                                     <M>     IEEE 802.11i TKIP encryption                                                                       │ │

  │ │                                     <M>     Software MAC add-on to the IEEE 802.11 networking stack                                            │ │

  │ │                                     [ ]       Enable full debugging output (NEW)                                                               │ │

  │ │                                                                                                                                                │ │

  │ │                                                                                                                                                │ │

  │ │                                                                                                     
```

----------

