# rt2500: when using wpa

## a_stranger

I have got rt2500 working and the wpa working by running this lines:

ifconfig ra0 up

iwconfig ra0 channel 0

iwpriv ra0 set SSID=Gallien

iwpriv ra0 set NetworkType=Infra

iwpriv ra0 set AuthMode=WPAPSK

iwpriv ra0 set EncrypType=TKIP

iwpriv ra0 set WPAPSK=passphrase

dhcpcd ra0 

but when I restart the computer I lose the wpa and I haft to run the lines again. What should I do to

----------

## BradN

As a quick solution, you could put the lines in your /etc/conf.d/local.start file, otherwise you would have to edit a net.ethx file in /etc/init.d/ and add the lines to an appropriate location in there (except for the dhcpcd line, as that can be handled by the startup script).

----------

## maca

I have these lines in a copy of net.eth0 that i called net.ra0 

I have statically assigned the IP so its in the section to do with !=DHCP in the script ....

If anyone has a nicer way of doing it .. Id love to hear it ... I have a RT2500 card, but this all seems to work fine ... I reboot/restart it and it all comes up good and proper !

                iwconfig ${IFACE} mode Managed

                /sbin/ifconfig ${IFACE} mtu 1450 >/dev/null

                iwpriv ra0 set SSID=home

                iwpriv ra0 set AuthMode=WPAPSK

                iwpriv ra0 set EncrypType=TKIP

                iwpriv ra0 set WPAPSK=****PASSPHRASE***** <----replace with your passphrase

The only thing Im lacking is that ... I cant seem to see any report from the system that I am running the WPA encryption even though I must be cause I still talk to the router ....

is there a switch on iwpriv or something to report what is going on, on the interface ... iwconfig and ifconfig doesnt really show me much.

the only thing that shows me there is encription on is iwlist scan ..... but that only shows the network ... not what is configured locally ??

----------

## dandelion

Silly me... I thought we had to use wpa_supplicant for wpa... Anyway, wpa_supplicant bundles so nicely with gentoo's initscripts... Perhaps Uberlord should add some iwpriv magic to the wireless scripts then? Or am I missing something?

----------

## xepk

Although this should be possible using the iwpriv_ra0 arguments in your /etc/conf.d/net, I never got that working.  Here's how I do WPA + rt2500:

I first use a script called pre.ra0 that I have added to the boot runlevel, that looks like this: 

```
#!/sbin/runscript

start() {

einfo "Checking for local WPA network"

ifconfig ra0 up

sleep 7s

if [ "`iwlist ra0 scanning | grep -i MY_ESSID`" != "" ]; then

einfo "WPA network found, Starting ra0 pre-up WPA commands"

cp /etc/conf.d/net.ra0.noiw /etc/conf.d/net

iwconfig ra0 channel MY_CHANNEL

iwpriv ra0 set SSID=MY_ESSID

iwpriv ra0 set NetworkType=Infra

iwpriv ra0 set AuthMode=WPAPSK

iwpriv ra0 set EncrypType=TKIP

iwpriv ra0 set WPAPSK=MY_PSK

else

einfo "Local WPA network not found, replacing /etc/conf.d/net with generic"

cp /etc/conf.d/net.ra0.generic /etc/conf.d/net

fi

}
```

Of course replacing MY_ESSID, MY_CHANNEL, and MY_PSK with the appropriate values for your router.

As you can see this scans for my WPA network at home and, if found, executes the necessary iwpriv commands and replaces my net configuration file with this one, which tells gentoo not to mess with the wireless settings: (/etc/conf.d/net.ra0.noiw) 

```
modules_ra0=("!iwconfig" "dhcpcd")

iface_ra0="dhcp"
```

If my WPA network is not found, the pre.ra0 script replaces the net config file with a generic config file (/etc/conf.d/net.ra0.generic) set to scan for an AP, useful for when I'm near public APs.

----------

## maca

So you have to reboot in order to restart your network connection ? .... or manually run an extra script ... surely this is what /etc/init.d/net.ra0 or similar is meant for ..... I can see what you doing but restarting you network connection should be as similar as a wired connection as possible, this is just my opinion but given what has been said so far Im happiest with my solution .... in fact your script could be exectuted as part of my init.d scripts and that way It would be run automatically running it out of boot seperately from init seems a but crasy rc-update should be all you need to do to get it in a run-level and out .... 

Again this is just my opinion

----------

## quiver

Well I don't have a solution, but I do have the reason for why the iwpriv command in the /etc/conf.d/net.ra0 scripts doesn't work...  After some discussion with Uberlord, it seems there are two issues, of which one is the real problem.  The first issue is that each line of iwpriv_ra0= in the script overwrites the previous, as it's read by bash.  You can only have one - of each - argument, no more... So in fact if you had;

iwpriv_ra0=set SSID=Gallien

iwpriv_ra0=set NetworkType=Infra

iwpriv_ra0=set AuthMode=WPAPSK

iwpriv_ra0=set EncrypType=TKIP

iwpriv_ra0=set WPAPSK=passphrase

then it'd keep overwriting and the only line the driver would acknowledge is the last, so it wouldn't know the AuthMode, EncrypType etc, and the connection would fail.

The solution, it would seem is to place all the parameters on the same line, like you can with iwconfig (eg iwconfig ra0 channel 5 essid blah etc etc)...  Yet despite the fact that iwconfig, iwpriv, iwlist etc are all supposedly written by the same person, iwpriv only accepts one parameter per line, contrary to the other tools in the package.  So you can't stack them all either  :Neutral: 

So that's the two issues, and the real underlying problem.  I'm told the rt2x00 driver will work with the wpa_supplicant shortly, so that's where the developers priorities are...  I'll be using xepk's groovy lil script in the meantime, though I'll certainly be keeping up to date on the progress with the rt2500/rt2x00 driver, as disabling SMP to get the rt2500 driver to work was a very sorry loss  :Sad: 

----------

## maca

I have been using the commands I posted since before July this year, I can reboot and the network is initialised out of the run level. You are saying it wont work but it does ... I dont know what to say ... Im using WPA-psk encription on my network and it runs fine .....

----------

## quiver

Maca, your script, if I'm not mistaken, is an init.d script, like xepk's, that's why you can add it to a runlevel and it works.  So yes, it does work, but as you say;

 *Quote:*   

> I can see what you doing but restarting you network connection should be as similar as a wired connection as possible

 

Which would be to have iwpriv_ra0= parameters in the conf.d end of things  :Smile: 

----------

