# iwconfig essid problem

## Gruguuru

Hello,

I have a problem with iwconfig. I want to set my essid. I tried doing it in the console and it didn't work (no error, but typing iwconfig returned wlan0 with ESSID=""). I did it several times and it didn't work. Then I started X, and it worked! I was able to set my ESSID from an xterm by typing the exact same command. Of course, it also can't connect to the AP on booting (using the script that I found on this forum).

I can't scan because the ESSID is not broadcasted (and I don't want to broadcast it). I thought specifying the ESSID manually would work (and it does in X). I'm not using WEP either. What did I do wrong?

----------

## codergeek42

Have you tried 

```
# /sbin/iwconfig wlan0 essid YourNetworkName
```

?

----------

## Gruguuru

There's no iwconfig in my /sbin, only in /usr/sbin (that's the one that's run when i type iwconfig)

----------

## helfrez

I believe wut coderg meant was have u tried it with the full syntax

iwconfig wlan0 essid YourAPName

you need to add the AP name after the essid call..In addition to that u man need the "enc" option for encrpytion... Lets say you acces points name is AccessPoint1 and your wep key is 1234567890...you command would be:

iwconfig wlan0 essid AccessPoint1 enc 1234567890

Hope this helps...

----------

## Gruguuru

As I said, I don't use WEP, so no encryption key. And yes, the command that I typed was:

```
iwconfig wlan0 essid <myapname>
```

I'm pretty sure it's the right command since it worked when I was in X (I know that X is probably not the reason why it worked, there's something else that I don't see).

----------

## UberLord

 *Gruguuru wrote:*   

> 
> 
> I can't scan because the ESSID is not broadcasted (and I don't want to broadcast it)

 

Actually, you can scan even if the ESSID is not being broadcast - the MAC address of the AP is always broadcast.

My scripts allow MAC->ESSID mapping, so effectively if the know which MAC address is which AP then scanning works  :Smile: 

Some drivers don't allow ESSID being set when the interface is up which may be your problem. Try my scripts out - they may help you!

Good luck  :Smile: 

----------

## Gruguuru

I am actually using your scripts, which are great. I tried what you said (MAC -> ESSID mapping) but it says wlan0 doesn't support scanning (it does in Windows, but I'm using NDISwrapper so I don't know).

Still no luck with setting the ESSID. There's a '-' in the ESSID, could that be a problem?

----------

## UberLord

 *Gruguuru wrote:*   

> 
> 
> Still no luck with setting the ESSID. There's a '-' in the ESSID, could that be a problem?

 

It might be.

Show me your /etc/conf.d/wireless

----------

## Gruguuru

Removing the dash in the ESSID didn't work either.

Here's my /etc/conf.d/wireless:

```

# /etc/conf.d/wireless:

# Global wireless config file for net.* rc-scripts

##############################################################################

# HINTS

##############################################################################

# Remember to change eth0 to your wireless interface which may be

# eth0, eth1, wlan0, ath0 - you get the idea. If you're not sure

# you can type "iwconfig" at the command prompt and it will tell you which

# interfaces are wireless.

# Say that your wireless interface is ath0 - the line

#   #essid_eth0="any"

# becomes

#   #essid_ath0="any"

# 

# Remember to change ESSID to your ESSID.

# Say that your ESSID is My NET - the line

#   #key_ESSID="s:passkey"

# becomes

#   #key_My_NET="s:passkey"

# Notice that the space has changed to an underscore.

# 

# Clear? Good. Now configure your wireless network below

#########################################################

##############################################################################

# SETTINGS

##############################################################################

# Hard code an ESSID to an interface

# This needs to be done when the driver doesn't support scanning

# Set to "any" to connect to any ESSID

# This may work for drivers that don't support scanning but you need automatic

# AP association

#essid_eth0="any"

essid_wlan0="gnolu-gulu"

# Set the mode of the interface (ad-hoc or managed). Managed is default

# If it's ad-hoc you also need to specify the channel below

#mode_eth0="Managed"

mode_wlan0="Managed"

# If managed mode fails, drop to ad-hoc mode with the below ESSID?

# If this is set, then remember to configure wireless options such as ifconfig

# for the specified ESSID. Channel can be set (1-14), but defaults to 3 if

# not set.

# 

# The below is taken verbatim from the BSD wavelan documentation found at

# http://www.netbsd.org/Documentation/network/wavelan.html

# There are 14 channels possible; We are told that channels 1-11 are legal for

# North America, channels 1-13 for most of Europe, channels 10-13 for France,

# and only channel 14 for Japan. If in doubt, please refer to the documentation

# that came with your card or access point. Make sure that the channel you

# select is the same channel your access point (or the other card in an ad-hoc

# network) is on. The default for cards sold in North America and most of Europe

# is 3; the default for cards sold in France is 11, and the default for cards

# sold in Japan is 14.

#adhoc_essid_eth0="WLAN"

#adhoc_channel_eth0="3"

# Setup any other config commands. This is basically the iwconfig argument

# without the iwconfig $iface

#iwconfig_eth0=""

#iwconfig_wlan0="192.168.1.103 broadcast 192.168.0.255 netmask 255.255.255.0"

# Set private driver ioctls. This is basically the iwpriv argument without

# the iwpriv $iface

#iwpriv_eth0=""

# We can define various timeouts here.

#sleep_scan_eth0="1"

#sleep_associate_eth0="5"

# Some driver/card combinations need to scan in Ad-Hoc mode

# After scanning, the mode is reset to the one defined above

#scan_mode_eth0="Ad-Hoc"

# Below you can define private ioctls to run before and after scanning

# Format is the same as the iwpriv_eth0 above

# This is needed for the HostAP drivers

#iwpriv_scan_pre_eth0="host_roaming 2"

#iwpriv_scan_post_eth0="host_roaming 0"

# Define a WEP key per ESSID

# IMPORTANT: any characters that are NOT in a_z A_Z 0_9 should be

# replaced with the _ character.

# For example #123 becomes _123

# The below examples use ESSID - change it to yours.

# You can't use "any" for an ESSID here

#key_ESSID="open 1234-1234-1234-1234-1234-1234-56"

# or you can use strings. Passphrase IS NOT supported

#key_ESSID="open s:foobar"

# You can also override the interface settings here - even provide

# a nameserver/domain per ESSID

#ifconfig_ESSID="192.168.1.110"

#dhcpcd_ESSID="-t 5"

#inet6_ESSID=""

#routes_ESSID=""

#gateway_ESSID="192.168.0.1"

#nameserver_ESSID="192.168.0.1"

#domain_ESSID="some.domain"

# LEAP users will want to use the preassociate setting to specify

# an authentication script

#preassociate_ESSID="/run/this/script"

# Map a MAC address to an ESSID

# This is used when the Access Point is not broadcasting it's ESSID

# WARNING: This will override the ESSID being broadcast due to some

# Access Points sending an ESSID even when they have been configured

# not too!

# Change 001122334455 to the MAC address and ESSID to the ESSID

# it should map to

# Some characters may need to be escaped, such as " with \"

#essid_001122334455="ESSID"

#essid_00904B13CC4F="gnolu-gulu"

# This lists the preferred ESSIDs to connect to in order

# ESSID's can contain any characters here as they must match the broadcast

# ESSID exactly. Some characters may need to be escaped, such as " with \"

# Surround each ESSID with the " character and seperate them with a space

# If the first ESSID isn't found then it moves onto the next

# If this isn't defined then it connects to the first one found

#preferred_aps=("ESSID 1" "ESSID 2")

```

----------

## UberLord

Looks OK to me

what does the command

```
iwconfig wlan0 essid gnolu-gulu

iwconfig wlan0
```

 produce?

----------

## Gruguuru

Like I said in my first post, it has a very weird behaviour. Here's the exact steps I took after rebooting the computer and the output given:

1. Login as root

2. iwconfig wlan0 essid gnolu-gulu

    iwconfig wlan0

```

wlan0     IEEE 802.11g  ESSID:""  

          Mode:Managed  Frequency:2.462GHz  Access Point: FF:FF:FF:FF:FF:FF  

          Bit Rate:54Mb/s   Tx-Power:24 dBm   

          RTS thr:2347 B   Fragment thr:2346 B   

          Encryption key:off

          Power Management:off

          Link Quality:100/100  Signal level:-10 dBm  Noise level:-256 dBm

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

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

```

3. Logout

4. Login as a regular user

5. startx

6. Open an xterm

7. su

8. iwconfig wlan0 essid gnolu-gulu

    iwconfig wlan0

```

wlan0     IEEE 802.11g  ESSID:"gnolu-gulu"  

          Mode:Managed  Frequency:2.437GHz  Access Point: 00:90:4B:13:CC:4F  

          Bit Rate:54Mb/s   Tx-Power:13 dBm   

          RTS thr:2347 B   Fragment thr:2346 B   

          Encryption key:off

          Power Management:off

          Link Quality:100/100  Signal level:-45 dBm  Noise level:-256 dBm

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

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

```

So it does connect after all, but what should I do to make it work right from the beginning?

----------

## UberLord

Do you get wlan0 starting up at boot?

Do you get the same effect with 

```
/etc/init.d/net.wlan0 restart
```

 in a console and in X?

BTW - I just release a new ebuild

Probably won't fix your problem here, but you never know!

----------

## Gruguuru

 *UberLord wrote:*   

> Do you get wlan0 starting up at boot?
> 
> Do you get the same effect with 
> 
> ```
> ...

 

No. In the console:

```

* Running preup function

*   Configuring wireless network for wlan0

*   Connecting to "gnolu-gulu" (WEP disabled)...           [!!]

* wlan0 requires an ESSID to be set to operate in Ad-Hoc mode

 * Failed to configure wireless for wlan0

 * preup wlan0 failed

```

In X:

```

 * Running preup function

 *   Configuring wireless network for wlan0

 *   Connecting to "gnolu-gulu" (WEP disabled)...                         [ ok ]

 *     wlan0 connected to "gnolugulu" in managed mode

 *     on channel 06 (WEP disabled)

 * Bringing wlan0 up (192.168.1.103)...                                   [ ok ]

```

I'll try your new ebuild now

Edit: As you expected, the new ebuild didn't fix my problem.

Edit2: To answer your first question, at boot I get the same error as in the console.

----------

## UberLord

If you quit X and restart wlan0 do you get the same error?

----------

## Gruguuru

No, it works if i quit X. The whole thing seems really bizarre to me. Do you think you know what's going on?

----------

## UberLord

How about if you reboot and leave things for 10 mins or so, come back and try starting wlan0 without starting X.

Same error still?

----------

## Gruguuru

 *UberLord wrote:*   

> How about if you reboot and leave things for 10 mins or so, come back and try starting wlan0 without starting X.
> 
> Same error still?

 

Yes

----------

## UberLord

Any error's in dmesg?

This is very bizarre - why should booting X cause your wireless to start working?

Also, could you check the top of the file /etc/init.d/wireless.sh and check the version number? Should be 0.4.6 as I fixed that ad-hoc error you posted a while ago....

----------

## Gruguuru

I don't know either how X can "fix" my wireless... 

I do have the right version of your script (0.4.6), the ad-hoc error appeared because I still had version 0.4.4 at that time.

dmesg seems right, except for these two lines (but I don't think they have anything to do with that problem):

```

atkbd.c: Spurious ACK on isa0060/serio0. Some program, like XFree86, might be trying access hardware directly.

atkbd.c: Spurious ACK on isa0060/serio0. Some program, like XFree86, might be trying access hardware directly.

```

If you want I'll post the output of dmesg in its entirety.

----------

## UberLord

OK, without booting X I want you to do the following commands

```
iwconfig wlan0 essid gnolu-gulu

iwconfig iwlan0

sleep 10

iwconfig iwlan0

sleep 10

iwconfig iwlan0

sleep 10

iwconfig iwlan0

sleep 10

iwconfig iwlan0

sleep 10

cat /proc/net/wireless

```

and post the results please.

----------

## Gruguuru

Sorry, I'm away from my Linux box for the weekend (going back home  :Smile: ). I'll do this on Sunday evening. Thank you for your help.

----------

## Gruguuru

 *UberLord wrote:*   

> OK, without booting X I want you to do the following commands
> 
> ```
> iwconfig wlan0 essid gnolu-gulu
> 
> ...

 

Ok, here you go. Sorry for the wait. Instead of iwconfig iwlan0 you meant iwconfig wlan0 right?

Here's the output:

```

wlan0     IEEE 802.11g  ESSID:""

          Mode:Managed  Frequency:2.462GHz  Access Point: FF:FF:FF:FF:FF:FF

          Bit Rate:54Mb/s   Tx-Power:24 dBm

          RTS thr:2347 B   Fragment thr:2346 B

          Encryption key:off

          Power Management:off

          Link Quality:100/100  Signal level:-10 dBm  Noise level:-256 dBm

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

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

wlan0     IEEE 802.11g  ESSID:""

          Mode:Managed  Frequency:2.462GHz  Access Point: FF:FF:FF:FF:FF:FF

          Bit Rate:54Mb/s   Tx-Power:24 dBm

          RTS thr:2347 B   Fragment thr:2346 B

          Encryption key:off

          Power Management:off

          Link Quality:100/100  Signal level:-10 dBm  Noise level:-256 dBm

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

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

wlan0     IEEE 802.11g  ESSID:""

          Mode:Managed  Frequency:2.462GHz  Access Point: FF:FF:FF:FF:FF:FF

          Bit Rate:54Mb/s   Tx-Power:24 dBm

          RTS thr:2347 B   Fragment thr:2346 B

          Encryption key:off

          Power Management:off

          Link Quality:100/100  Signal level:-10 dBm  Noise level:-256 dBm

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

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

wlan0     IEEE 802.11g  ESSID:""

          Mode:Managed  Frequency:2.462GHz  Access Point: FF:FF:FF:FF:FF:FF

          Bit Rate:54Mb/s   Tx-Power:24 dBm

          RTS thr:2347 B   Fragment thr:2346 B

          Encryption key:off

          Power Management:off

          Link Quality:100/100  Signal level:-10 dBm  Noise level:-256 dBm

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

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

wlan0     IEEE 802.11g  ESSID:""

          Mode:Managed  Frequency:2.462GHz  Access Point: FF:FF:FF:FF:FF:FF

          Bit Rate:54Mb/s   Tx-Power:24 dBm

          RTS thr:2347 B   Fragment thr:2346 B

          Encryption key:off

          Power Management:off

          Link Quality:100/100  Signal level:-10 dBm  Noise level:-256 dBm

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

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

Inter-| sta-|   Quality        |   Discarded packets               | Missed | WE

 face | tus | link level noise |  nwid  crypt   frag  retry   misc | beacon | 16

 wlan0: 0000  100   246     0        0      0      0      0  51250        0

```

----------

## UberLord

Well, that's totally nuts and I'm all out of ideas  :Sad: 

I suggest taking your problem to a forum/mailing list specifically for the driver of your card.

----------

## Gruguuru

Ok, thanks for trying to help... I'm going to try the last CVS version of NDISwrapper, maybe they've fixed something. If it doesn't work, I'll ask on their mailing list.

----------

## emmCee

i have the same problem with my setup, however unlike Gruguuru mentioned to me, it wasn't fixed by unpluging (or disabling) the onboard ethernet.

it works fine as long as the iwconfig is executed from X. outside X it doesn't seem to work at all.

for the record my card is the belkin F5D7000 (i think). it uses the broadcom chipset 94306, which is supported by ndiswrapper.

gav

----------

