# wpa Pre-Shared-Key with wmp54g and ipw2200 to wrt54g HOWTO

## olibob

Hi,

This is my first post on any gentoo forum. I'm using gentoo for a week now and I think I'm gonna stay with it for a while, this is exactly what I was looking for  :Wink: 

So, yes I bought nice wireless toys for Christmas and I needed to set it all up, so here is my experience.

My hardware:

----------------

- linksys router: WRT54G

- linksys PCI card: WMP54G

- laptop integrated wireless mini PCI card: Intel 2200BG

Software requierement:

----------------------------

- ndiswrapper (can be emerged, just go whith the latest and you should be fine)

- wireless-tools (can be emerged, just go whith the latest and you should be fine)

- dhcpcd (can be emerged, just go whith the latest and you should be fine)

- wpa_supplicant-0.2.6 (http://hostap.epitest.fi/)

- a working Intel 2200BG driver (this one works: http://www.powernotebooks.com/Support/intel_2200_wlan.zip)

- a working wmp54g driver (this one works: ftp://ftp.linksys.com/pub/network/WMP54Gv4_20040415.exe)

Configuration:

-----------------

I consider that you mastered the gentoo installation and/or that you have a running system.

1/ install ndiswrapper

-------------------------

```
emerge ndiswrapper

emerge wireless-tools
```

You should be fine with the current releases.

2a/ Intel 2200BG driver installation:

-----------------------------------------

Unzip the above mentioned archive, cd into it and do the following:

```
ndiswrapper -i PROW2200/WINXP/w22n51.INF
```

2b/ WMP54G driver installation:

-------------------------------------

Unzip the above mentioned archive, cd into it and do the following:

```
ndiswrapper -i Drivers/WMP54Gv2/bcmwl5.inf
```

3/ Check 1

------------

Verify that the drivers are installed correctly installed:

On my laptop:

```
ndiswrapper -l

Installed ndis drivers:

w22n51  driver present, hardware present

```

On my PC:

```
ndiswrapper -l

Installed ndis drivers:

bcmwl5  hardware present

```

If you get this, it means the driver was accepted by ndiswrapper, not that it will work properly  :Wink:  But in this cas, I can tell you that it IS working. Well, at least for me  :Wink: 

4/ Load the driver:

----------------------

```
modprobe ndiswrapper
```

5/ Is wlan0 there?

Check with:

```
iwconfig
```

YES => continue

NO => have a nice couple hours troubleshooting  :Wink: 

A good way to check if the driver is working is to scann to see if you discover your AP.

```
iwlist wlan0 scan

wlan0     Scan completed :

          Cell 01 - Address: 00:0F:66:D9:F1:C7

                    ESSID:"robbyairnet"

                    Protocol:IEEE 802.11b

                    Mode:Managed

                    Frequency:2.462 GHz (Channel 11)

                    Quality:0/100  Signal level:-64 dBm  Noise level:-256 dBm

                    Encryption key:on

                    Bit Rate:1 Mb/s

                    Bit Rate:2 Mb/s

                    Bit Rate:5.5 Mb/s

                    Bit Rate:11 Mb/s

                    Bit Rate:18 Mb/s

                    Bit Rate:24 Mb/s

                    Bit Rate:36 Mb/s

                    Bit Rate:54 Mb/s

                    Bit Rate:6 Mb/s

                    Bit Rate:9 Mb/s

                    Bit Rate:12 Mb/s

                    Bit Rate:48 Mb/s

                    Extra:bcn_int=100

                    Extra:atim=0

                    Extra:wpa_ie=dd160050f20101000050f20201000050f20201000050f202

```

That looks good to me!   :Cool: 

6/ WPA-PSK :how-to?

OK, here we go!

First, here is what I did on the wireless router:

- I activated MAC-address filtering (you do not need this for this example, it's just a second security precaution)

- I activated WPA-PSK and entered a passphrase.

I didn't have a good experience from the wpa_supplicant ebuild so I advise you to download it from the above mentioned url instead of emerging it! You've been warned!

* Untar the downloaded archive and cd into it.

* Create a .config file with your desired options.

Here is mine:

```
cat .config

CONFIG_DRIVER_NDISWRAPPER=y

CONFIG_WIRELESS_EXTENSION=y

CONFIG_IEEE8021X_EAPOL=y

CONFIG_EAP_MD5=y

CONFIG_EAP_MSCHAPV2=y

CONFIG_EAP_TLS=y

CONFIG_EAP_PEAP=y

CONFIG_EAP_TTLS=y

CONFIG_EAP_GTC=y

CONFIG_EAP_OTP=y

CONFIG_EAP_SIM=y

CONFIG_EAP_AKA=y

CONFIG_EAP_PSK=y

CONFIG_EAP_LEAP=y

```

* build it>

```
make
```

* copy the binaries to /usr/sbin.

```
cp wpa_supplicant wpa_cli wpa_passphrase /usr/sbin
```

* Ready.

Usage:

---------

1/ Create /etc/wpa_supplicant.conf and adapt it to your network settings.

-------------------------------------------------------------------------------------

Here is mine:

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

eapol_version=1

ap_scan=1

network={

        ssid="robbyairnet"

        proto=WPA

        key_mgmt=WPA-PSK

        pairwise=CCMP TKIP

        group=CCMP TKIP WEP104 WEP40

        psk="YourPassPhrasseHere!!!"

        priority=2

}

```

2/ Test if you can authenticate and connect:

--------------------------------------------------

To debug your wpa access (stop it with a ctrl-c)

```

/usr/sbin/wpa_supplicant -w -c/etc/wpa_supplicant.conf -iwlan0 -d

```

If you succed connecting to your AP with the above command (trust me, you will, if you didn't screw up somewhere!), rather than going step by step through the whole process, here is a script I created to automate everything. It's pretty straight forward!

!!!!!Don't use it before the above command is successfull, it'll be of no use unless the previous step works!!!!!

```

#!/sbin/runscript

start() {

        ebegin "Bringing up wlan0"

        /sbin/ifconfig wlan0 up

        eend $?

        ebegin "Starting wpa_supplicant"

        if [ ! -f /etc/wpa_supplicant.conf ]; then

                eerror "Configuration file /etc/wpa_supplicant.conf not found"

                return 1

        fi

        /usr/sbin/wpa_supplicant -Bw -c/etc/wpa_supplicant.conf -iwlan0

        /bin/pidof wpa_supplicant >> /var/run/wpa_supplicant.pid

        eend $?

        # gives time to wpa_supplicant to authenticate and establish a wireless connection

        # ugly, but yet working (TODO: make this the proper way man!!! :-o)

        ebegin "Waiting for authentication"

        sleep 5

        eend $?

        ebegin "Getting ip address (dhcpcd)"

        /sbin/dhcpcd wlan0

        eend $?

}

stop() {

        ebegin "Shutting down wlan0"

        kill -TERM `cat /var/run/dhcpcd-wlan0.pid`

        eend $?

        ebegin "Stopping wpa_supplicant"

        kill -TERM `cat /var/run/wpa_supplicant.pid`

        rm /var/run/wpa_supplicant.pid

        eend $?

}

```

Create /etc/init.d/wpa_supplicant and past the above code in that fille.

Then:

```
rc-update add wpa_supplicant default

/etc/init.d/wpa_supplicant start

 * Bringing up wlan0 ...                                      [ ok ]

 * Starting wpa_supplicant ...                                [ ok ]

 * Waiting for authentication ...                             [ ok ]

 * Getting ip address (dhcpcd) ...                            [ ok ]

ifconfig

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:6 errors:0 dropped:0 overruns:0 frame:0

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

          collisions:0 txqueuelen:0

          RX bytes:300 (300.0 b)  TX bytes:300 (300.0 b)

wlan0     Link encap:Ethernet  HWaddr 00:0E:35:4A:CD:EF

          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:424 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:39915 (38.9 Kb)  TX bytes:2026 (1.9 Kb)

          Interrupt:10 Memory:d0208000-d0208fff

ping -c3 www.gentoo.org

PING www.gentoo.org (65.19.163.231) 56(84) bytes of data.

64 bytes from wren.gentoo.org (65.19.163.231): icmp_seq=1 ttl=52 time=198 ms

64 bytes from wren.gentoo.org (65.19.163.231): icmp_seq=2 ttl=52 time=198 ms

64 bytes from wren.gentoo.org (65.19.163.231): icmp_seq=3 ttl=52 time=201 ms

--- www.gentoo.org ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 1999ms

rtt min/avg/max/mdev = 198.523/199.657/201.654/1.507 ms

```

And here you go!  :Cool: 

 Both my 2200BG and WMP54G connect to my WRT54G router through WPA-SPK and MAC-Address filtering.

My AP is secured and YES, it works as well under linux, who needs windows guys???  :Twisted Evil: 

Voila, I hope this will help those who wnat to go the WPA-PSK way.

Cheers,

Olibob

----------

## Zyne

I have been trying to get this WPA-enabled wireless network going, but I've been too lazy since I also have a wired connection atm...

Thanks for the howto and welcome to the forums  :Smile: 

edit: well it's still not working for me with ESSID broadcasting disabled  :Sad: 

from the moment I enabled the ESSID broadcast, everything works fine, but when I disable it, the signal goes away  :Sad: 

```

Setting scan request: 5 sec 0 usec

Starting AP scan (broadcast SSID)

Scan timeout - try to get results

Received 0 bytes of scan results (0 BSSes)

Scan results: 0

Selecting BSS from priority group 2

```

edit2: forgot to mention: same router (wrt54G) and same card (wmp54g)

----------

## olibob

mmm, good to know, I didn't even try without broadcasting my ESSID.

I won't now  :Wink: 

Olibob

----------

## liber!

For the ipw2200 card you can just emerge ipw2200, it makes a module for your kernel...

Greets,

Nathan

----------

## kiker

hey man I don't have "wlan0", what can i do to get it?,

plz help.

Any help will be apreciated

----------

## Zyne

 *kiker wrote:*   

> hey man I don't have "wlan0", what can i do to get it?,
> 
> plz help.
> 
> Any help will be apreciated

 

you should just modprobe ndiswrapper...

if you installed the drivers and ndiswrapper correctly, wlan0 should show up when you do iwconfig. if it doesn't, you probably haven't installed the drivers correctly...

btw: I'm assuming you also have a linksys wmp54g, and are using ndiswrapper...

----------

## kiker

i think i install it correctly, cos i get this:

```
 ndiswrapper -l

Installed ndis drivers:

inffile]        hardware NOT present

net8180 hardware present

```

 and i modprobe it, and wlan0 didn't show up. And i have no idea what is " linksys wmp54g", but i have follow the intructions in a hole bunch of pages, and i always get to the same trouble, no wlan0.

any idea?

----------

## gaim

linksys is a company which makes routers, switches, wireless etc...

wmp54g is a model of a wireless card.

My advice to you kiker is to find out what your card is and whether or not it is supported.

you might also want to try the wiki:

http://gentoo-wiki.com/HOWTO_Wireless_Configuration_and_Startup

----------

## thomasa88

Anyone got ipw2200 + WRT54G without ESSID broadcast working? Im planning to buy a WRT54G and I dont want any "friendly visits"  :Razz: 

----------

## servo888

And don't forget in your /etc/conf.d/net

```

modules=( "wpa_supplicant" )

wpa_supplicant_wlan0="-Dndiswrapper"

```

----------

