# How to prefer an AP?

## dj_olsen

Hello,

I tried several settings but my laptop always connects to my neighbours access point.

Can anyone give me a detailed description on how to make my Intel 2200bg prefer my own AP, please?

Thanks a lot!

----------

## toxicnaan

 *dj_olsen wrote:*   

> Hello,
> 
> I tried several settings but my laptop always connects to my neighbours access point.
> 
> Can anyone give me a detailed description on how to make my Intel 2200bg prefer my own AP, please?
> ...

 

set your ssid with iwconfig.

----------

## dj_olsen

Thanks.

```
iwconfig eth1 essid "AP"
```

works. When does it have to be executed? And how to make it run at startup? I don't want to enter this command every time after booting.

----------

## jakubc

hi,

what you need is to look at /etc/conf.d/wireless.example, here it shows you how to setup any number of things for any number of AP's you might be connecting to...

but if you only need the essid, then in /etc/conf.d/net add:

```

modules=( "iwconfig" )

```

and in  /etc/conf.d/wireless add:

```

essid_eth1="YOUR_ESSID"

preferred_aps=("YOUR_ESSID")

```

then put eth1 into the default runlevel:

```

rc-update add net.eth1 default

```

and you should be set.

please note, that for this you need baselayout version 1.11.? i.e. the masked one:-)  here is a HOWTO for getting the baselayout.

hope this helps:-)

----------

## dj_olsen

Hi, 

thanks for your tips. But they don't work. Nothing works... I'm getting sick of Gentoo!

What I want is: Making my computer logon to my access point. With encryption of course, WEP128 or better WPA. Trying WEP128 first.

What I have: Acer Travelmate 8003 with Intel 2200bg.

My computer's configuration:

```

sys-apps/baselayout-1.11.11-r3

net-wireless/ipw2200-1.0.3
```

```
acer ~ # lsmod

Module                  Size  Used by

ub                     19996  0

pcmcia                 26640  6

yenta_socket           23816  4

rsrc_nonstatic         11520  1 yenta_socket

pcmcia_core            52384  3 pcmcia,yenta_socket,rsrc_nonstatic

snd_intel8x0           34560  2

snd_ac97_codec         79352  1 snd_intel8x0

nls_cp437               6208  1

nls_iso8859_1           4544  2

ntfs                  188368  1

ieee80211_crypt_tkip   11524  0

ipw2200               162888  0

firmware_class         11136  1 ipw2200

ieee80211              42788  1 ipw2200

ieee80211_crypt         7048  3 ieee80211_crypt_tkip,ipw2200,ieee80211

tg3                    91780  0

eth1394                22664  0
```

/etc/conf.d/wireless

```
essid_eth2="AP1"

mode_eth2="managed"

adhoc_essid_eth2="AP1"

channel_eth0="6"

iwconfig_eth2="essid AP1"

key_AP1="55393193738332723131363015 enc open"

preferredonly="AP1"

blacklist_aps=( "WLAN" )
```

/etc/conf.d/net

```
iface_eth0="dhcp"

iface_eth1="dhcp"

modules=( "iwconfig" )

iface_eth2="dhcp"

blacklist_aps=( "WLAN" )
```

What I did is:

To make sure that my settings are used:

```
acer ~ # rc-update del net.eth2 default

 * net.eth2 removed from the following runlevels: default

 * rc-update complete.

acer ~ # rc-update add net.eth2 default

 * net.eth2 added to runlevel default

 * rc-update complete.
```

Then I press the WiFi-key on my computer.

```
acer ~ # iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

eth1      no wireless extensions.

eth2      IEEE 802.11g  ESSID:"WLAN"

          Mode:Managed  Frequency:2.462 GHz  Access Point: 00:30:F1:EB:C8:0A

          Bit Rate=54 Mb/s   Tx-Power=20 dBm

          RTS thr:off   Fragment thr:off

          Encryption key:off

          Power Management:off

          Link Quality=80/100  Signal level=-49 dBm  Noise level=-87 dBm

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

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

And there is my neighbours network again!  :Crying or Very sad: 

After 

```
acer ~ # /etc/init.d/net.eth2 start 
```

 I cannot access the internet anymore because dhcpcd changes my /etc/resolv.conf.

What am I doing wrong? Please do not refer me to other threads or guides - I read everything. Either it's incomplete or too old. But it never works!

----------

## UberLord

 *dj_olsen wrote:*   

> 
> 
> /etc/conf.d/wireless
> 
> ```
> ...

 

I will refer you to wireless.example and net.example in /etc/conf.d which are correct and current

You have obviously either not read them, or not understood them.

You also have no idea about wireless managed mode either

As I'm in a good mood today, I've redone your configs

/etc/conf.d/net

```

modules=( "iwconfig" )

config_eth0=( "dhcp" )

config_eth1=( "dhcp" )

config_eth2=( "dhcp" )

# Ensure that dhcpcd on eth2 does not change resolv.conf or the gateway

# So that internet still works

dhcpcd_eth2="-R -G" 

```

/etc/conf.d/wireless

```

key_AP1="55393193738332723131363015 enc open"

preferred_aps=( "AP1" )

blacklist_aps=( "WLAN" )

```

----------

## dj_olsen

Hi Uberlord,

Thanks, but

```
...

config_eth0=( "dhcp" )

config_eth1=( "dhcp" )

config_eth2=( "dhcp" )

... 
```

 does not work: Error message when doing

```
acer ~ # /etc/init.d/net.eth2 start

 * Please make sure that /etc/conf.d/net has $ifconfig_eth2 set

 * (or $iface_eth2 for old-style configuration)
```

So I used

```
...

iface_eth0="dhcp"

iface_eth1="dhcp"

iface_eth2="dhcp"

...
```

 Or am I wrong with this? Because it still doesn't work, still connecting to my neighbours AP.

----------

## UberLord

You need baselayout-1.11.12-r3 - which is masked ~ARCH

----------

## dj_olsen

After updating to baselayout-1.11.12-r3 there is no change: Same error and behaviour as before.Last edited by dj_olsen on Fri May 27, 2005 4:01 am; edited 1 time in total

----------

## psbaker

I'm struggling with this same problem. I'm a Gentoo newbie (refugee from Fedora), and things have gone swimmingly till now. I had no /etc/conf.d/wireless.example for some reason. I found it posted on one of these forums and *thought* I had understood it; but nothing I entered in my "wireless" file seemed to make any difference: I still connected to a neighbor's router. Using iwconfig works, but . . .

The relevant wiki entry seems to me rather sketchy, and wireless.example, though it seems clear enough, is for some reason not helping. Uberlord's instructions also seem clear, but they do not work for me. I am trying to understand the advice to install baselayout-1.11.12-r. I've got a baselayout package, to be sure: but it's version 1.9.4-r6. Portage claims it is current.

What am I missing?

----------

## BigBaaadBob

 *psbaker wrote:*   

>  I am trying to understand the advice to install baselayout-1.11.12-r. I've got a baselayout package, to be sure: but it's version 1.9.4-r6. Portage claims it is current.
> 
> What am I missing?

 

The more irascible of folks would say you are missing "man 5 portage".  But I'm not irascible, so...

When you run into these situations you need first verify what the status of the package is.  I use this command for that:

```
# etcat versions baselayout

[ Results for search key           : baselayout ]

[ Candidate applications found : 11 ]

 Only printing found installed programs.

*  sys-apps/baselayout :

        [  I] 1.9.4-r6 (0)

        [M  ] 1.9.4-r7 (0)

        [M~ ] 1.11.9-r1 (0)

        [M~ ] 1.11.10-r7 (0)

        [M~ ] 1.11.11 (0)

        [M~ ] 1.11.11-r1 (0)

        [M~ ] 1.11.11-r2 (0)

        [M~ ] 1.11.11-r3 (0)

        [M~ ] 1.11.12-r1 (0)

        [M~ ] 1.12.0_alpha2 (0)

        [M~ ] 1.12.0_alpha2-r1 (0)

#
```

So, with this status of the portage collection, 1.9.4-r6 is the latest stable version of baselayout.

To emerge something that isn't marked stable you need to go to /etc/portage and edit package.keywords, adding a line like this:

```
sys-apps/baselayout ~x86
```

which will allow the most current version of baselayout to be emerged (if it isn't hard-masked).  If you do this you'll see:

```
# etcat versions baselayout

[ Results for search key           : baselayout ]

[ Candidate applications found : 11 ]

 Only printing found installed programs.

*  sys-apps/baselayout :

        [  I] 1.9.4-r6 (0)

        [M  ] 1.9.4-r7 (0)

        [ ~ ] 1.11.9-r1 (0)

        [ ~ ] 1.11.10-r7 (0)

        [ ~ ] 1.11.11 (0)

        [ ~ ] 1.11.11-r1 (0)

        [ ~ ] 1.11.11-r2 (0)

        [ ~ ] 1.11.11-r3 (0)

        [ ~ ] 1.11.12-r1 (0)

        [M~ ] 1.12.0_alpha2 (0)

        [M~ ] 1.12.0_alpha2-r1 (0)

#

```

 Notice how th 1.12.0 versions are still masked (they are hard-masked) as is 1.9.4-r7.  But, this may not be what you want because this will cause 1.11.12-r1 to get merged, whereas all you might want is the latest 1.11.11.  In that case, try adding this line to the package.mask file:

```

>=sys-apps/baselayout-1.11.12
```

 which gives you this result:

```
# etcat versions baselayout

[ Results for search key           : baselayout ]

[ Candidate applications found : 11 ]

 Only printing found installed programs.

*  sys-apps/baselayout :

        [  I] 1.9.4-r6 (0)

        [M  ] 1.9.4-r7 (0)

        [ ~ ] 1.11.9-r1 (0)

        [ ~ ] 1.11.10-r7 (0)

        [ ~ ] 1.11.11 (0)

        [ ~ ] 1.11.11-r1 (0)

        [ ~ ] 1.11.11-r2 (0)

        [ ~ ] 1.11.11-r3 (0)

        [M~ ] 1.11.12-r1 (0)

        [M~ ] 1.12.0_alpha2 (0)

        [M~ ] 1.12.0_alpha2-r1 (0)

#
```

Just remember, when you do this you are taking version control in your own hands.  You've removed the guards from the saw.

----------

## psbaker

Okay, I should have figured that out. But now dj_olsen seems to be saying that updating the baselayout package isn't the solution anyway.

In the meantime, this page

http://www.gentoo.org/doc/en/handbook/draft/handbook-x86.xml?part=4&chap=4

seems admirably clear, but following its instructions has gotten me nowhere.

Time for bed: in the morning I'll try wpa supplicant, which provides better security anyway.

If all else fails, I guess I could just have my own DSL service turned off and live off my neighbor's unencrypted wlan.

----------

## freelx

 *BigBadBob wrote:*   

> When you run into these situations you need first verify what the status of the package is.  I use this command for that:
> 
> ```
> # etcat versions baselayout
> 
> ...

 

nb:

```
freelx # etcat --help | head -n 4

etcat (0.3.1) - Portage Information Extractor - By: Alastair Tse

NOTICE: This tool will be phased out at some point in

        the future, please use equery instead.

        Bugs are still fixed, but new features won't be added.
```

So:

```
mu ~ # equery list -o -p baselayout

[ Searching for package 'baselayout' in all categories among: ]

 * installed packages

[I--] [  ] sys-apps/baselayout-1.11.12-r2 (0)

 * Portage tree (/usr/portage)

[-P-] [M ] sys-apps/baselayout-1.9.4-r7 (0)

[-P-] [M~] sys-apps/baselayout-1.12.0_alpha2 (0)

[-P-] [  ] sys-apps/baselayout-1.9.4-r6 (0)

[-P-] [ ~] sys-apps/baselayout-1.11.11-r2 (0)

[-P-] [M~] sys-apps/baselayout-1.12.0_alpha2-r1 (0)

[-P-] [ ~] sys-apps/baselayout-1.11.10-r7 (0)

[-P-] [ ~] sys-apps/baselayout-1.11.9-r1 (0)

[-P-] [ ~] sys-apps/baselayout-1.11.11-r1 (0)

[-P-] [ ~] sys-apps/baselayout-1.11.11-r3 (0)

[-P-] [ ~] sys-apps/baselayout-1.11.11 (0)

[-P-] [ ~] sys-apps/baselayout-1.11.12-r1 (0)

[-P-] [ ~] sys-apps/baselayout-1.11.12-r3 (0)

[-P-] [M ] sys-apps/baselayout-darwin-1.11.11 (0)

[-P-] [M-] sys-apps/baselayout-lite-1.0_pre2 (0)

[-P-] [M-] sys-apps/baselayout-lite-1.0_pre1 (0)

[-P-] [ ~] sys-apps/baselayout-vserver-1.0 (0)

 * overlay tree (/usr/local/portage)
```

Or, faster:

```
emerge --sync

emerge eix

update-eix
```

then you can:

```
freelx # eix -e baselayout

* sys-apps/baselayout

     Available versions:  1.9.4-r6 !1.9.4-r7 ~1.11.9-r1 ~1.11.10-r7 ~1.11.11 ~1.11.11-r1 ~1.11.11-r2 ~1.11.11-r3 ~1.11.12-r1 ~1.11.12-r2 [M]1.12.0_alpha2 [M]1.12.0_alpha2-r1

     Installed:           1.11.12-r2

     Homepage:            http://www.gentoo.org/

     Description:         Base layout for Gentoo Linux (incl. initscripts and sysvinit)

Found 1 matches
```

When you use eix in the future -- if it has been awhile since your last update-eix --  just remember to "emerge --sync && update-eix" to index the latest tree.Last edited by freelx on Fri May 27, 2005 2:14 am; edited 2 times in total

----------

## BigBaaadBob

freelx: Yes.  Old habits die hard!   :Laughing: 

----------

## freelx

 *BigBadBob wrote:*   

> freelx: Yes.  Old habits die hard!  

 

Indeed, I too relied on etcat until recently.  It took me long time to realize that "equery l -o -p" is what replaces "etcat -v" ... it's not very obvious.

----------

## dj_olsen

 *psbaker wrote:*   

> If all else fails, I guess I could just have my own DSL service turned off and live off my neighbor's unencrypted wlan.

 

Lucky you! My neightbours don't have DSL, just their router for internal communication. I even can see their router configuration (and they use it, I did hide their router's ESSID, but they changed it back) ... no DSL access data stored there. A dead end!  :Crying or Very sad: 

----------

## psbaker

Actually that neighbor is far enough away that my connection was rather iffy: nytimes.com took forever to load. So I've got to go on paying for DSL.  :Sad: 

Convinced that I was failing to understand something, I turned off all encryption and authentication in my router and turned on ssid broadcasting. When I tried again with the simplest possible config file the connection worked /* sigh of relief */. Then started turning things on one by one. (This is what I should have done before bugging the people in this forum). Turns out the bit I didn't understand was what to do when the router was set not to broadcast the ssid.

I'm still studying this--but for the time being I have a sort-of secure wlan at home.

----------

## BigBaaadBob

 *freelx wrote:*   

> Indeed, I too relied on etcat until recently.  It took me long time to realize that "equery l -o -p" is what replaces "etcat -v" ... it's not very obvious.

 

Of course, it isn't an exact replacement.  The etcat version looks exactly for the package "baselayout" whereas the equery version looks for any package name that begins with "baselayout" and I don't see anyway to force it to do otherwise.   :Mad: 

And, he said grumpily, why is it that portage utilities don't handle options like any good little unix program should, as in "-op" means the same as "-o -p" if "-o" doesn't take an argument?  Grump!  Grump!

----------

## psbaker

Actually I can't use WEP encryption either: right now my only security is authentication by MAC address. Is anyone still reading this thread?

----------

## BigBaaadBob

 *psbaker wrote:*   

> Actually I can't use WEP encryption either: right now my only security is authentication by MAC address. Is anyone still reading this thread?

 

I am.  And I do wireless on my laptop using wpa_supplicant which works pretty much everywhere I've tried it (WEP, WPA, or whatever)...

----------

## psbaker

Thanks, BigBadBob. I've upgraded baselayout as per the instructions on the wiki and will try further this evening. Will report back. I am also interested in getting wpa going too, since that is used at work.

----------

## BigBaaadBob

Just a little more info.   I'm not using the newer baselayout (still using the 1.9.4-r6 version).  Also I'm using driverloader because ndiswrapper didn't work with my wifi card when I got it (a LinkSys WPC54G).   This setup has always worked fine out of the box.  When using open WAPs I just use driverloader directly and if necessary, tell it which AP to associate with using iwconfig.  When using WEP or WPA I use wpa_supplicant.

However, since upgrading to a 2.6.11 kernel, driverloader is hanging. They tell me I need to avoid the "preempt the big kernel lock" setting which I don't really want to do, and besides I tried it and it still hung.  So I'm likely to try ndiswrapper again, since it now supports my card.

----------

## psbaker

Not doing too well: I haven't managed to get either WEP or WPA working. Here is /etc/conf.d/net, showing the various things I've tried:

```

# eth0 is the wire: I'm not using it right now.

#iface_eth0="dhcp"

#dhcpcd_eth0="..."

# If I try to substitute the "config" line for the "iface" line, I get

# an error message telling me to define $ifconfig. If I then include a

# line reading ifconfig_eth1="" I still get the error message.

iface_eth1="dhcp"

#config_eth1="dhcp"

#key_anselm="7D30-D848-8924-50DB-A2D0-2E07-E4"

modules=( "iwconfig" )

dhcpcd_eth1="-t 20"

#I haven't been able to make wpa work at all.

#modules=( "wpa_supplicant" )

#wpa_supplicant_eth1="-Dmadwifi"

#wpa_timeout_eth1="20"

#preferred_aps=( "anselm" )

#associate_order="preferredonly"

# Left over from net.example. What is it for?

gateway="/"

```

And here is /etc/conf.d/wireless:

```

key_anselm="7D30-D848-8924-50DB-A2D0-2E07-E4 enc open"

preferred_aps=( "anselm" )

associate_order="preferredonly"

```

And here is /etc/wpa_supplicant.conf:

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

ap_scan=1

network={

        ssid="anselm"

        scan_ssid=1

        key_mgmt=WPA-PSK

        psk="my-secret-passwd"

}

```

I am running baselayout 1.11.12-r1, but the result is the same as with the earlier version. My card is an ipw2200; the router is a Linksys WRT54G. No hardware issues, I think: this has been working perfectly under Fedora, and also in Gentoo when manually configured with iwconfig.

Diagnoses very welcome. It would also be a great help to see examples of actual files that are actually working for people.

----------

## psbaker

I don't think anyone is reading this thread anymore, but for the record: I give up. I've used up far more time trying to make the initscript work than I will ever use starting my wireless connection myself via a script.

----------

## cgmd

BigBadBob wrote... *Quote:*   

> I do wireless on my laptop using wpa_supplicant which works pretty much everywhere I've tried it (WEP, WPA, or whatever)...

 

I, too, have a  Linksys WPC54G card. I'm running 2.6.11, and ndiwrapper is handling the driver. May I ask what version of wpa_supplicant is working for you, and how you might have it configured? I'm unable to connect using WPA with my Linksys WRT54G router.  :Sad: 

Thanks...

----------

## BigBaaadBob

 *cgmd wrote:*   

> I, too, have a  Linksys WPC54G card. I'm running 2.6.11, and ndiwrapper is handling the driver. May I ask what version of wpa_supplicant is working for you, and how you might have it configured? I'm unable to connect using WPA with my Linksys WRT54G router.

 

I'm connecting to a LinkSys WAP54G.  Using sys-apps/baselayout-1.9.4-r6, sys-kernel/gentoo-sources-2.6.11-r8, net-wireless/ndiswrapper-1.1-r1, and net-wireless/wpa_supplicant-0.4.0.  I followed the instructions in the ndiswrapper wiki more or less directly and it works just fine.

My wpa_supplicant.conf is pretty much standard stuff (deleting all the comments and changing ssid and keys):

```
ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=wheel

eapol_version=1

ap_scan=1

network={

   ssid="my ssid"

   psk="my psk"

}
```

And my /etc/conf.d/wpa_supplicant says:

```
INTERFACES="wlan0"

ARGS_wlan0="-Dndiswrapper"
```

I have ndiswrapper in my /etc/modules.autoload.d/kernel-2.6 file.  When I insert the card I

```
/etc/init.d/wpa_supplicant start
```

 and the interface comes up.  Of course, I've done all the normal stuff in /etc/init.d by symlinking net.wlan0 to net.eth0, and making sure my /etc/conf.d/net is correct.  All that information can be found elsewhere.

----------

