# wlan0 trying to connect to wrong ap [SOLVED]

## sumpi

hi @ all! 

After days of testing and trying, it works!

I changed the configuration of my linksys wrt 54 gl to send the ESSID.

I changed the configuration of my wpa_supplicant.conf to the following:

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=users

#ap_scan=2

update_config=1

network={

        ssid="router@home"

        scan_ssid=1

        psk="secretPWD"

        key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE

        pairwise=CCMP TKIP

        group=CCMP TKIP WEP104 WEP40

}

```

Due to the fact, that I live in a very old house with very thick walls, i had to walk around to see, if I get a connection. After playing with the antennas of the ap, it seems to work, as I am online using wlan0 right now!

Thanks to KTA for his patience and all his hints! In fact, the last message of him pointed me to the right connection!

To make it easier for others to get the clue, I leave the original post below!

Once again THANKS!!!

Bye,

Sumpi

here is the original messages:

hi all!

I am trying for months to get my wlan working correctly. I have a fujitsu siemens Amilo Pro v3520 laptop. The wireless card is onboard and is a 

04:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG Network Connection (rev 02)

I tried to use wpa_supplicant with the following config:

/etc/conf.d/net

```

config_eth0=( "dhclient" )

modules_wlan0=( "wpa_supplicant" )

#wpa_supplicant_wlan0="-Dipw -c /etc/wpa_supplicant/wpa_supplicant.conf"

wpa_supplicant_wlan0="-g -Dwext -c /etc/wpa_supplicant/wpa_supplicant.conf"

wpa_timeout_wlan0=60

```

and /etc/wpa_supplicant/wpa_supplicant.conf

```

ap_scan=2

network={

        ssid="router@home"

        scan_ssid=1

        auth_alg=OPEN

        key_mgmt=WPA-PSK

        psk="secretpwd"

}

```

I also tryed NetworkManager without success.

So what happens during start of /etc/init.d/net.wlan0 is the following as shown in /var/log/messages:

```

Jan 20 11:00:00 serialmurderer wlan0: Initial auth_alg=0

Jan 20 11:00:00 serialmurderer wlan0: authenticate with AP 00:0f:b5:56:bf:52

Jan 20 11:00:00 serialmurderer wlan0: RX authentication from 00:0f:b5:56:bf:52 (alg=0 transaction=2 status=0)

Jan 20 11:00:00 serialmurderer wlan0: authenticated

Jan 20 11:00:00 serialmurderer wlan0: associate with AP 00:0f:b5:56:bf:52

Jan 20 11:00:00 serialmurderer wlan0: invalid aid value 0; bits 15:14 not set

Jan 20 11:00:00 serialmurderer wlan0: RX AssocResp from 00:0f:b5:56:bf:52 (capab=0x5 status=12 aid=0)

Jan 20 11:00:00 serialmurderer wlan0: AP denied association (code=12)

Jan 20 11:00:00 serialmurderer wlan0: Initial auth_alg=0

Jan 20 11:00:00 serialmurderer wlan0: authenticate with AP 00:0f:b5:56:bf:52

Jan 20 11:00:00 serialmurderer wlan0: RX authentication from 00:0f:b5:56:bf:52 (alg=0 transaction=2 status=0)

Jan 20 11:00:00 serialmurderer wlan0: authenticated

Jan 20 11:00:00 serialmurderer wlan0: associate with AP 00:0f:b5:56:bf:52

Jan 20 11:00:00 serialmurderer wlan0: invalid aid value 0; bits 15:14 not set

Jan 20 11:00:00 serialmurderer wlan0: RX AssocResp from 00:0f:b5:56:bf:52 (capab=0x5 status=12 aid=0)

Jan 20 11:00:00 serialmurderer wlan0: AP denied association (code=12)

Jan 20 11:00:00 serialmurderer iwl3945: iwl-3945-rs not selected as rate control algo!

Jan 20 11:00:00 serialmurderer wlan0: associate with AP 00:0f:b5:56:bf:52

Jan 20 11:00:00 serialmurderer wlan0: invalid aid value 0; bits 15:14 not set

Jan 20 11:00:00 serialmurderer wlan0: RX AssocResp from 00:0f:b5:56:bf:52 (capab=0x5 status=12 aid=0)

Jan 20 11:00:00 serialmurderer wlan0: AP denied association (code=12)

Jan 20 11:00:00 serialmurderer iwl3945: iwl-3945-rs not selected as rate control algo!

Jan 20 11:00:01 serialmurderer wlan0: associate with AP 00:0f:b5:56:bf:52

Jan 20 11:00:01 serialmurderer wlan0: invalid aid value 0; bits 15:14 not set

Jan 20 11:00:01 serialmurderer wlan0: RX AssocResp from 00:0f:b5:56:bf:52 (capab=0x5 status=12 aid=0)

Jan 20 11:00:01 serialmurderer wlan0: AP denied association (code=12)

Jan 20 11:00:01 serialmurderer iwl3945: iwl-3945-rs not selected as rate control algo!

Jan 20 11:00:01 serialmurderer wlan0: association with AP 00:0f:b5:56:bf:52 timed out

Jan 20 11:00:01 serialmurderer wlan0: Initial auth_alg=0

Jan 20 11:00:01 serialmurderer wlan0: authenticate with AP 00:0f:b5:56:bf:52

Jan 20 11:00:01 serialmurderer wlan0: authentication frame received from 00:0f:b5:56:bf:52, but not in authenticate state - ignored

```

The strange thing is, that the AP, which is shown in messages has a different MAC-Adr than the router is use at my home network.

My router is configured as follows:

Mode: WPA-PSK

WPA Algo: AES

PSK: secretpwd

and has these MAC-Addresses:

out: 00:1A:70:FC:D7:C9

lan: 00:1A:70:FC:D7:C8

wlan: 00:1A:70:FC:D7:CA

But as shown in the excerpt of my messages, the laptop tries to connect to an ap with mac addr. 00:0f:b5:56:bf:52 as shown in line: 

Jan 20 11:00:00 serialmurderer wlan0: authenticate with AP 00:0f:b5:56:bf:52

So how can I configure my laptop to only connect to the correct ap?

Thanks for any hints in advance!

Bye,

Sumpi

----------

## K T A

Well, I do not have my laptop with me right now- but I had a similar problem once. I used to connect to two different AP's and till today I have to set

```
ap_scan=2
```

 for one and 

```
ap_scan=1
```

 for the other... Give it a try...

KTA

----------

## sumpi

i changed my config for wpa_supplicant:

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=users

#ap_scan=2

update_config=1

network={

        ssid="sumpiWLan"

        scan_ssid=1

        proto=WPA

        psk="12WLan34Access56@home78"

        key_mgmt=WPA-PSK

        pairwise=TKIP

        auth_alg=OPEN

}

```

But the laptop still tries to connect to the wrong ap. I also had a look at the man page for wpa_supplicant.conf. But there seems to be no possibility to set the correct ap. The strange thing is: in windows, the laptop connects to the preferred ap without any problems. So maybe the strength of the signal is too low for linux? Is there a possibility to change the signal strength of my card or do something similar?

Anyway thanks!

----------

## K T A

You can set the correct AP by hand to find out if it connects at all. Use wpa_cli -> select network # or so, don't have the exact syntax in my head right now. Just try wpa_cli and tell me what happens  :Smile: 

KTA

----------

## sumpi

i tried your tip, but with the same result. My laptop still tries to connect to the wrong ap.

btw, the syntax is 

wpa_cli select_network ESSID

the system ansers:

```

Selected interface 'wlan0'

OK

```

I see nothing in messages and nothing else happens. So I tried to run dhclient.

this is the output:

```

Jan 20 17:28:45 serialmurderer dhclient: Internet Systems Consortium DHCP Client V3.1.0-Gentoo

Jan 20 17:28:45 serialmurderer dhclient: Copyright 2004-2007 Internet Systems Consortium.

Jan 20 17:28:45 serialmurderer dhclient: All rights reserved.

Jan 20 17:28:45 serialmurderer dhclient: For info, please visit http://www.isc.org/sw/dhcp/

Jan 20 17:28:45 serialmurderer dhclient:

Jan 20 17:28:45 serialmurderer dhclient: wmaster0: unknown hardware address type 801

Jan 20 17:28:49 serialmurderer dhclient: wmaster0: unknown hardware address type 801

Jan 20 17:28:49 serialmurderer dhclient: Listening on LPF/wlan0/00:18:de:10:ab:ea

Jan 20 17:28:49 serialmurderer dhclient: Sending on   LPF/wlan0/00:18:de:10:ab:ea

Jan 20 17:28:49 serialmurderer dhclient: Listening on LPF/wmaster0/

Jan 20 17:28:49 serialmurderer dhclient: Sending on   LPF/wmaster0/

Jan 20 17:28:49 serialmurderer dhclient: Listening on LPF/eth0/00:0a:e4:ba:10:c9

Jan 20 17:28:49 serialmurderer dhclient: Sending on   LPF/eth0/00:0a:e4:ba:10:c9

Jan 20 17:28:49 serialmurderer dhclient: Sending on   Socket/fallback

Jan 20 17:28:49 serialmurderer dhclient: option_space_encapsulate: option space agent does not exist, but is configured.

Jan 20 17:28:49 serialmurderer dhclient: DHCPDISCOVER on wmaster0 to 255.255.255.255 port 67 interval 5

Jan 20 17:28:50 serialmurderer dhclient: option_space_encapsulate: option space agent does not exist, but is configured.

Jan 20 17:28:50 serialmurderer dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67

Jan 20 17:28:50 serialmurderer dhclient: DHCPACK from 192.168.32.254

Jan 20 17:28:50 serialmurderer dhclient: bound to 192.168.32.200 -- renewal in 6974 seconds.

Jan 20 17:28:51 serialmurderer dhclient: option_space_encapsulate: option space agent does not exist, but is configured.

Jan 20 17:28:51 serialmurderer dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3

Jan 20 17:28:54 serialmurderer dhclient: DHCPDISCOVER on wmaster0 to 255.255.255.255 port 67 interval 9

Jan 20 17:28:54 serialmurderer dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5

Jan 20 17:28:59 serialmurderer dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8

Jan 20 17:29:03 serialmurderer dhclient: DHCPDISCOVER on wmaster0 to 255.255.255.255 port 67 interval 9

Jan 20 17:29:07 serialmurderer dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11

Jan 20 17:29:12 serialmurderer dhclient: DHCPDISCOVER on wmaster0 to 255.255.255.255 port 67 interval 16

Jan 20 17:29:18 serialmurderer dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 14

Jan 20 17:29:28 serialmurderer dhclient: DHCPDISCOVER on wmaster0 to 255.255.255.255 port 67 interval 18

Jan 20 17:29:32 serialmurderer dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7

Jan 20 17:29:39 serialmurderer dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 13

Jan 20 17:29:46 serialmurderer dhclient: DHCPDISCOVER on wmaster0 to 255.255.255.255 port 67 interval 4

Jan 20 17:29:50 serialmurderer dhclient: No DHCPOFFERS received.

Jan 20 17:29:50 serialmurderer dhclient: No working leases in persistent database - sleeping.

Jan 20 17:29:52 serialmurderer dhclient: No DHCPOFFERS received.

Jan 20 17:29:52 serialmurderer dhclient: No working leases in persistent database - sleeping.

```

So I do not get an ipaddr. and it seems, that the system is not trying to connect to the ap...

anything else, i should check?

Thanks,

Sumpi

----------

## K T A

Try this:

enter the wpa_cli shell

run

```
scan

scan_results

list_networks

select_network (number in list after list_networks - NOT essid)

status
```

KTALast edited by K T A on Mon Jan 21, 2008 2:23 pm; edited 1 time in total

----------

## sumpi

i am not at home right now, but I will give it a try later on...

Thanks for the hint!

Bye,

Sumpi

----------

## sumpi

k, this is, what happens:

```

sumpi # wpa_cli

wpa_cli v0.5.7

Copyright (c) 2004-2006, Jouni Malinen <jkmaline@cc.hut.fi> and contributors

This program is free software. You can distribute it and/or modify it

under the terms of the GNU General Public License version 2.

Alternatively, this software may be distributed under the terms of the

BSD license. See README and COPYING for more details.

Selected interface 'wlan0'

Interactive mode

> scan

OK

> scan_results

bssid / frequency / signal level / flags / ssid

00:1a:70:fc:d7:ca       2462    182     [WPA-PSK-CCMP]

00:0f:b5:56:bf:52       2462    174             Hinterreiter

> list_networks

network id / ssid / bssid / flags

0       sumpiWLan       any

> select_network 0

OK

> status

wpa_state=SCANNING

>
```

so the first network shown in scan_result is the ap i want to connect to.

what should I do next!

Thanks,

Sumpi

----------

## sumpi

it worked for about 2 minutes   :Crying or Very sad: 

I connected via wlan0 after setting my router to sending the essid, but after disconnecting my network cable, it seems that my wlan0 device lost its configuration...

So I retried using wpa_cli - shell. But now I can find my network using scan and scan_results

The strange thing is, that if I boot windows, everything works as expected.

This is weird!

Bye,

Sumpi

----------

## K T A

So, it works via the wpa_cli shell? I remember reading about wlan0 disconnecting when one removes another networkcable... look around in the forum. I may provide you my laptop configuration but you have to wait until tomorrow...

KTA

----------

## sumpi

 *K T A wrote:*   

> So, it works via the wpa_cli shell? I remember reading about wlan0 disconnecting when one removes another networkcable... look around in the forum. I may provide you my laptop configuration but you have to wait until tomorrow...
> 
> KTA

 

Right now, everything works fine. After getting it to work in the shell as you said, I tried to reconfigure my wpa_supplicant.conf. As stated in my topmost post, I reconfigured my wpa_supplicant.conf. I also changed the router to send the ESSID. Now it works, no matter if the ethernet card is connected or not.

Once again thanks for all your hints!

Bye,

Sumpi

----------

