# Problem configuring /etc/conf.d/net for wireless

## rguimera

Hi,

I have a problem configuring /etc/conf.d/net for using wireless.

Here is the problem. If I run:

```
ifconfig wlan0 192.168.1.242 netmask 255.255.255.0

iwconfig wlan0 essid my_essid key my_hex_key

dhcpcd wlan0
```

I get my network up and running, with no problem.

Now, my /etc/conf.d/net looks like this:

```
modules=( "iwconfig" )

config_my_essid=( "dhcp" )

key_my_essid="my_hex_key enc open"

preferred_aps=( "my_essid" )
```

When I start net.wlan0 I get the following:

```
 * Starting wlan0

 *   Configuring wireless network for wlan0

 *     wlan0 connected to ESSID "my_essid" at 00:22:22:DF:22:A1

 *     in managed mode on channel 1 (WEP disabled)

 *   Bringing up wlan0

 *     dhcp

 *       Running dhcpcd ...

err, wlan0: timed out

warn, wlan0: using IPV4LL address 169.254.234.32                                             [ ok ]

 *       wlan0 received address 169.254.234.32/16
```

and, of course, the network won't work. Can anyone help?

By the way, I am using gentoo-sources-2.6.24-r3 and a USB Netgear wireless adapter that works with ndiswrapper-1.50.

Thanks in advance.

----------

## toor_

I have had a lot of luck using this HOWTO.  Try it out, as I see your settings are a bit different than what is on here.  If thats not your cup of tea, can you post all your network settings so I can examine it for other errors?

-toor

----------

## rguimera

Thanks for the reply toor_

As I mentioned, doing the manual set-up as suggested in the HOWTO works just fine. Then the HOWTO goes into using wpa_supplicant, which won't work for me (for WEP, although it works for WPA networks). I thought using iwconfig in /etc/conf.d/net would be simpler (given that the manual setup works), but it doesn't seem to be the case   :Sad: 

If someone thinks that it would be easier to solve the problem using wpa_supplicant, please feel free to jump in. The output of

```
wpa_supplicant -Dwext -iwlan0 -dd -c/etc/wpa_supplicant/wpa_supplicant.conf
```

seems normal and suggests that the connection has completed

```
CTRL-EVENT-CONNECTED - Connection to 00:16:01:df:0a:a9 completed (auth) [id=0 id_str=]

wpa_driver_wext_set_operstate: operstate 0->1 (UP)

WEXT: Operstate: linkmode=-1, operstate=6

Cancelling scan request

RTM_NEWLINK: operstate=1 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])

RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
```

but

```
dhcpcd wlan0
```

times out again.

What other network settings would help you diagnose what is going on?

----------

## DarKRaveR

 *rguimera wrote:*   

> Hi,
> 
> I have a problem configuring /etc/conf.d/net for using wireless.
> 
> Here is the problem. If I run:
> ...

 

Well, do you really get an IP from dhcp, because you setup one statically in the first place, what happens if dhcp fails? I assume it is kept ...

 *Quote:*   

> 
> 
> Now, my /etc/conf.d/net looks like this:
> 
> ```
> ...

 

Are you sure your DHCP is working as expected ?

Could you run 'dhcpcd -d wlan0' in the manual case and see what dhcpcd actually does?

----------

## rguimera

 *Quote:*   

> Could you run 'dhcpcd -d wlan0' in the manual case and see what dhcpcd actually does?

 

Here is what happens if I use the manual setup:

```
gorg ~ # ifconfig wlan0 up

gorg ~ # iwconfig wlan0 essid my_essid key my_hex_key

gorg ~ # dhcpcd -d wlan0

info, wlan0: dhcpcd 3.2.3 starting

info, wlan0: hardware address = 00:1b:2f:32:4a:aa

info, wlan0: DUID = 00:01:00:01:0e:c5:95:49:00:00:e2:59:e8:92

info, wlan0: broadcasting for a lease

debug, wlan0: sending DHCP_DISCOVER with xid 0x2d63c025

debug, wlan0: waiting for 20 seconds

debug, wlan0: got a packet with xid 0x2d63c025

info, wlan0: offered 192.168.11.5 from 192.168.11.1

debug, wlan0: sending DHCP_REQUEST with xid 0x2d63c025

debug, wlan0: waiting for 20 seconds

debug, wlan0: got a packet with xid 0x2d63c025

info, wlan0: checking 192.168.11.5 is available on attached networks

debug, wlan0: sending ARP probe #1

debug, wlan0: sending ARP probe #2

debug, wlan0: sending ARP probe #3

debug, wlan0: sending ARP claim #1

debug, wlan0: sending ARP claim #2

info, wlan0: leased 192.168.11.5 for 172800 seconds

info, wlan0: no renewal time supplied, assuming 86400 seconds

info, wlan0: no rebind time supplied, assuming 151200 seconds

info, wlan0: adding IP address 192.168.11.5/24

info, wlan0: adding default route via 192.168.11.1 metric 0

info, wlan0: adding route to 169.254.0.0/16 metric 0

debug, wlan0: writing /etc/resolv.conf

debug, wlan0: writing /var/lib/dhcpcd/dhcpcd-wlan0.info

debug, wlan0: forking to background

info, wlan0: exiting
```

Here is what happensif I use the net.wlan0 script with wireless-tools (with the configuration I posted yesterday):

```
gorg ~ # /etc/init.d/net.wlan0 start

 * Starting wlan0

 *   Configuring wireless network for wlan0

 *     wlan0 connected to ESSID "my_essid" at 00:16:01:DF:0A:A9

 *     in managed mode on channel 1 (WEP disabled)

 *   Bringing up wlan0

 *     dhcp

 *       Running dhcpcd ...

err, wlan0: timed out

warn, wlan0: using IPV4LL address 169.254.82.110                                      [ ok ]

 *       wlan0 received address 169.254.82.110/16

gorg ~ # ps -xu |grep dhcpcd

Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html

root     12406  0.0  0.0   1748   320 ?        Ss   10:38   0:00 /sbin/dhcpcd -h gorg -m 2000 wlan0

root     12439  0.0  0.1   1688   496 pts/0    R+   10:38   0:00 grep --colour=auto dhcpcd

gorg ~ # kill 12406

gorg ~ # dhcpcd -d wlan0

info, wlan0: dhcpcd 3.2.3 starting

info, wlan0: hardware address = 00:1b:2f:32:4a:aa

info, wlan0: DUID = 00:01:00:01:0e:c5:95:49:00:00:e2:59:e8:92

info, wlan0: broadcasting for a lease

debug, wlan0: sending DHCP_DISCOVER with xid 0x3a5991bb

debug, wlan0: waiting for 20 seconds

debug, wlan0: sending DHCP_DISCOVER with xid 0x3a5991bb

debug, wlan0: sending DHCP_DISCOVER with xid 0x3a5991bb

debug, wlan0: sending DHCP_DISCOVER with xid 0x3a5991bb

debug, wlan0: sending DHCP_DISCOVER with xid 0x3a5991bb

debug, wlan0: sending DHCP_DISCOVER with xid 0x3a5991bb

debug, wlan0: sending DHCP_DISCOVER with xid 0x3a5991bb

err, wlan0: timed out

info, wlan0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-wlan0.info'

debug, wlan0: sending ARP probe #1

debug, wlan0: sending ARP probe #2

debug, wlan0: sending ARP probe #3

debug, wlan0: sending ARP claim #1

debug, wlan0: sending ARP claim #2

warn, wlan0: using IPV4LL address 169.254.82.110

info, wlan0: adding IP address 169.254.82.110/16

debug, wlan0: no dns information to write

debug, wlan0: forking to background

info, wlan0: exiting
```

And finally, here is what happens if I use the net.wlan0 script with wpa_supplicant:

```
gorg ~ # /etc/init.d/net.wlan0 start

 * Starting wlan0

 *   Starting wpa_supplicant on wlan0 ...                                                                             [ ok ]

 *   Starting wpa_cli on wlan0 ...                                                                                    [ ok ]

 *     Backgrounding ...

gorg ~ # ps -xu |grep dhcpcd

Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html

root     18938  0.0  0.1   1748   684 ?        S    11:03   0:00 /sbin/dhcpcd -h gorg -m 2000 wlan0

root     18940  0.0  0.1   1688   500 pts/0    R+   11:03   0:00 grep --colour=auto dhcpcd

gorg ~ # kill 18938

gorg ~ # dhcpcd -d wlan0

info, wlan0: dhcpcd 3.2.3 starting

info, wlan0: hardware address = 00:1b:2f:32:4a:aa

info, wlan0: DUID = 00:01:00:01:0e:c5:95:49:00:00:e2:59:e8:92

info, wlan0: broadcasting for a lease

debug, wlan0: sending DHCP_DISCOVER with xid 0x1bdb3ec5

debug, wlan0: waiting for 20 seconds

debug, wlan0: sending DHCP_DISCOVER with xid 0x1bdb3ec5

debug, wlan0: sending DHCP_DISCOVER with xid 0x1bdb3ec5

debug, wlan0: sending DHCP_DISCOVER with xid 0x1bdb3ec5

debug, wlan0: sending DHCP_DISCOVER with xid 0x1bdb3ec5

debug, wlan0: sending DHCP_DISCOVER with xid 0x1bdb3ec5

debug, wlan0: sending DHCP_DISCOVER with xid 0x1bdb3ec5

err, wlan0: timed out

info, wlan0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-wlan0.info'

debug, wlan0: sending ARP probe #1

debug, wlan0: sending ARP probe #2

debug, wlan0: sending ARP probe #3

debug, wlan0: sending ARP claim #1

debug, wlan0: sending ARP claim #2

warn, wlan0: using IPV4LL address 169.254.82.110

info, wlan0: adding IP address 169.254.82.110/16

debug, wlan0: no dns information to write

debug, wlan0: forking to background

info, wlan0: exiting
```

This is what my wpa_supplicant.conf looks like:

```
ctrl_interface=/var/run/wpa_supplicant

network={

   ssid="my_essid"

   key_mgmt=NONE

   wep_key0=my_he_key

   priority=10

}
```

----------

## DarKRaveR

Okay, for somewhat reason the dhcp does not replay in the non manual case. Do you have the ability to check the dhcp servers log, ie, can you check if the DHCPDISCOVER reachs the server on interface level, on software level?

Most uch cases are related if something with the wlan does not work out (key) and the problem is not recognized ... btw, in th eautomatic mode there is something about WEP being off ... can you check on that?

----------

## rguimera

 *Quote:*   

> Most cases are related if something with the wlan does not work out (key) and the problem is not recognized ... btw, in the automatic mode there is something about WEP being off ... can you check on that?

 

Thanks, DarKRaveR. I think this is exactly the problem. I keep getting

```
 * Starting wlan0

 *   Configuring wireless network for wlan0

 *     wlan0 connected to ESSID "my_essid" at 00:16:01:DF:0A:A9

 *     in managed mode on channel 1 (WEP disabled)
```

even though my conf.d/net has the key set up. Why isn't it being read?

Here is the verbose version of what I get when I start net.wlan0

```
gorg ~ # /etc/init.d/net.wlan0 start --verbose

 * Starting wlan0

 *   Loading networking modules for wlan0

 *     modules: apipa arping ccwgroup macchanger macnet rename ifplugd iwconfig essidnet iptunnel ifconfig system dhcpcd ip6to4

 *       ifplugd provides plug

 *       iwconfig provides wireless

 *       ifconfig provides interface

 *       dhcpcd provides dhcp

 *   Configuring wlan0 for MAC address 00:1B:2F:32:4A:AA ...                                                                               [ ok ]

 *   ifplugd does not work on wireless interfaces

 *   Configuring wireless network for wlan0

 *   Scanning for access points

 *     Found "wozniak" at 00:1E:8C:2E:A4:D0 (managed, encrypted)

 *     Found "linksys" at 00:13:10:79:B5:5E (managed, encrypted)

 *     Found "AMATA" at 00:1B:FC:3A:0F:93 (managed, encrypted)

 *     Found "my_essid" at 00:16:01:DF:0A:A9 (managed, encrypted)

 *     Found "2WIRE581" at 00:1A:C4:DE:1B:91 (managed, encrypted)

 *     Found "Linksysxx" at 00:14:BF:09:60:FA (managed, encrypted)

 *     Found "susan" at 00:18:4D:38:BD:05 (managed, encrypted)

 *     Found "Customer ID" at 00:16:B6:6C:EB:9A (managed, encrypted)

 *     Found "linksys" at 00:13:10:FC:FF:BD (managed)

 *     Found "2WIRE409" at 00:1B:5B:84:6E:11 (managed, encrypted)

 *     Found "Kenny G" at 00:1E:52:78:15:18 (managed, encrypted)

 *     Found "bothin" at 00:1E:8C:3E:8A:E6 (managed, encrypted)

 *     Found "ronald" at 00:1A:92:D3:33:56 (managed, encrypted)

 *   Connecting to "my_essid" in managed mode (WEP enabled - open) ...                                                                        [ ok ]

 *     wlan0 connected to ESSID "my_essid" at 00:16:01:DF:0A:A9

 *     in managed mode on channel 1 (WEP disabled)

 *   Configuring wlan0 for ESSID "my_essid" ...                                                                                               [ ok ]

 *   Bringing up wlan0

 *     dhcp

 *       Running dhcpcd ...

err, wlan0: timed out

warn, wlan0: using IPV4LL address 169.254.233.84                                                                                           [ ok ]

 *       wlan0 received address 169.254.233.84/16
```

Any clues? What else can I look at? (I will try to get the info in the dhcp server log, but this will be kind of difficult because right now I don't have access to it).

----------

## DarKRaveR

 *rguimera wrote:*   

>  *Quote:*   Most cases are related if something with the wlan does not work out (key) and the problem is not recognized ... btw, in the automatic mode there is something about WEP being off ... can you check on that? 
> 
> Thanks, DarKRaveR. I think this is exactly the problem. I keep getting
> 
> [code]gorg ~ # /etc/init.d/net.wlan0 start --verbose
> ...

 

What worries me is the fact that it says my_essid is managed, encrypted, then connects WEP enabled - open, then reports disabled ... are you sure you set up the right key in the right format? (btw, is it WEP or WPA on the access point?).

Aside from what gets printed out by the scripts, you could do iwconfig wlan0 after the failure and see what is reported (Which AP was chosen, what mode etc.), to verify if it really selected the wrong mode (open instead of wep or whatever).

BTW: Pretty crowded area you got there   :Wink:  .

----------

## rguimera

 *Quote:*   

> What worries me is the fact that it says my_essid is managed, encrypted, then connects WEP enabled - open, then reports disabled ... are you sure you set up the right key in the right format? (btw, is it WEP or WPA on the access point?).

 

I've tried with the WEP key in several formats, mainly xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xx (lower case and capital) and without hyphens:

```
key_my_essid="xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xx enc open"
```

Either of these combinations works when I set things up manually, but not within the script. It is kind of interesting that there doesn't seem to be any difference in behavior between setting the right password and setting a wrong one.

 *Quote:*   

> Aside from what gets printed out by the scripts, you could do iwconfig wlan0 after the failure and see what is reported (Which AP was chosen, what mode etc.), to verify if it really selected the wrong mode (open instead of wep or whatever).

 

This is what I get after the failure:

```
gorg ~ # iwconfig wlan0

wlan0     IEEE 802.11g  ESSID:"my_essid"  

          Mode:Managed  Frequency:2.412 GHz  Access Point: 00:16:01:DF:0A:A9   

          Bit Rate=54 Mb/s   Tx-Power:20 dBm   Sensitivity=0/3  

          RTS thr:off   Fragment thr:off

          Encryption key:off

          Power Management:off

          Link Quality:42/100  Signal level:-69 dBm  Noise level:-96 dBm

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

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

gorg ~ # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1B:2F:32:4A:AA  

          inet addr:169.254.24.116  Bcast:169.254.255.255  Mask:255.255.0.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:5660 errors:0 dropped:0 overruns:0 frame:0

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

          collisions:0 txqueuelen:1000 

          RX bytes:6062100 (5.7 Mb)  TX bytes:974508 (951.6 Kb)
```

That is, it is associating to the right AP but as if there was no key, and therefore fails to get an IP and falls back to 169.254.24.116.

Instead, here is what I get after the manual setup:

```
gorg ~ # iwconfig wlan0

wlan0     IEEE 802.11g  ESSID:"my_essid"  

          Mode:Managed  Frequency:2.412 GHz  Access Point: 00:16:01:DF:0A:A9   

          Bit Rate=36 Mb/s   Tx-Power:20 dBm   Sensitivity=0/3  

          RTS thr:off   Fragment thr:off

          Encryption key:xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xx   Security mode:restricted

          Power Management:off

          Link Quality:43/100  Signal level:-68 dBm  Noise level:-96 dBm

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

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

gorg ~ # ifconfig wlan0

wlan0     Link encap:Ethernet  HWaddr 00:1B:2F:32:4A:AA  

          inet addr:192.168.11.5  Bcast:192.168.11.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:5675 errors:0 dropped:0 overruns:0 frame:0

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

          collisions:0 txqueuelen:1000 

          RX bytes:6066676 (5.7 Mb)  TX bytes:995756 (972.4 Kb)
```

 *Quote:*   

> BTW: Pretty crowded area you got there.

 

It's called apartment building  with small units  :Wink: . Anyway, most of the signals are borderline with the noise level   :Sad:  .

Thanks again for the help.

----------

## DarKRaveR

Did you make sure your key in the wireless config follows the scheme of iwconfig: xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xx ? (Just for the sake of completeness).

Now obviously it all comes down to the key. It works manually, okay, the net scritp obviously sees you configured a key and says it will use it. The only thing I can think of is a problem in how the key setup is mangled and put into an iwconfig call (you could check the script in the worst case to find out what is happening).

----------

## rguimera

 *Quote:*   

> Did you make sure your key in the wireless config follows the scheme of iwconfig: xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xx ? (Just for the sake of completeness).

 

Yes. I've tried like this and without hyphens. In any case, if I try an incorrect format (let's say, if I forget one character) I get a totally different output, so I believe this part is fine.

 *Quote:*   

> Now obviously it all comes down to the key. It works manually, okay, the net scritp obviously sees you configured a key and says it will use it. The only thing I can think of is a problem in how the key setup is mangled and put into an iwconfig call (you could check the script in the worst case to find out what is happening).

 

That's a good idea. I will take a look and report back.

----------

## DarKRaveR

I took a fast look, the script basicly pases essid_key directly t iwconfig, without any obvious modifications. but it does chek the P by analyzing the output of iwscan.

From what I could see, it should give at least a warning, if you configured a ke but the AP reports differently - The whole thing is very mystiours.

----------

