# [SOLVED]Trying to connect via wireless fails on obtaining IP

## moult

I decided to try again to get my wireless working. My wireless card is 0b:00.0 Network controller: Atheros Communications Inc. Device 002a (rev 01) and the driver for this is ath9k. I enabled it in the the kernel, recompiled, followed this guide (http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=4) and rebooted. Nothing showed up in wicd-client - a quick search online showed that apparently you had to enable the wifi via a hardware button before it booted up - after doing this my wicd-client now shows networks to connect to.

So of course I try to connect (to an unsecured source, so it's not a problem of wireless-tools and WPA compatibility) - however it fails at the "Obtaining IP Address" stage with "Connection failed: unable to get IP address". Checking out /var/log/messages this is the error I find:

```
Nov 24 19:52:50 epicbox dhcpcd[6500]: eth0: dhcpcd not running

Nov 24 19:52:50 epicbox kernel: [ 1139.034091] tg3 0000:08:00.0: PME# enabled

Nov 24 19:52:50 epicbox kernel: [ 1139.034122] tg3 0000:08:00.0: wake-up capability enabled by ACPI

Nov 24 19:52:50 epicbox kernel: [ 1139.058695] tg3 0000:08:00.0: wake-up capability disabled by ACPI

Nov 24 19:52:50 epicbox kernel: [ 1139.058707] tg3 0000:08:00.0: PME# disabled

Nov 24 19:52:50 epicbox kernel: [ 1139.069617] tg3 0000:08:00.0: irq 28 for MSI/MSI-X

Nov 24 19:52:50 epicbox kernel: [ 1139.202094] ADDRCONF(NETDEV_UP): eth0: link is not ready

Nov 24 19:52:50 epicbox dhcpcd[6508]: wlan0: dhcpcd not running

Nov 24 19:52:50 epicbox kernel: [ 1139.286193] ADDRCONF(NETDEV_UP): wlan0: link is not ready

Nov 24 19:52:50 epicbox dhcpcd[6517]: wlan0: dhcpcd 4.0.13 starting

Nov 24 19:52:50 epicbox dhcpcd[6517]: wlan0: waiting for carrier

Nov 24 19:52:52 epicbox kernel: [ 1140.876581] tg3: eth0: Link is up at 100 Mbps, full duplex.

Nov 24 19:52:52 epicbox kernel: [ 1140.876581] tg3: eth0: Flow control is on for TX and on for RX.

Nov 24 19:52:52 epicbox kernel: [ 1140.876581] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

Nov 24 19:53:03 epicbox kernel: [ 1151.794047] eth0: no IPv6 routers present

Nov 24 19:53:20 epicbox dhcpcd[6517]: wlan0: timed out
```

I really don't quite know how to debug this. This is my setup and as much relevant information I think I can provide:

in /etc/conf.d/net:

```
modules=( "iwconfig" )

essid_wlan0="any"
```

cat /proc/net/wireless

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

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

 wlan0: 0000    0     0     0        0      0      0      0      0        0
```

ifconfig

```
wlan0     Link encap:Ethernet  HWaddr 00:17:c4:3b:6d:94

          UP BROADCAST MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
```

iwconfig

```
wlan0     IEEE 802.11bgn  ESSID:""

          Mode:Managed  Frequency:2.412 GHz  Access Point: Not-Associated

          Tx-Power=20 dBm

          Retry  long limit:7   RTS thr:off   Fragment thr:off

          Encryption key:off

          Power Management:on

          Link Quality:0  Signal level:0  Noise level:0

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

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

iwlist scanning

```
wlan0     Scan completed :

          Cell 01 - Address: 00:1A:C1:15:74:9C

                    Channel:11                

                    Frequency:2.462 GHz (Channel 11)

                    Quality=22/70  Signal level=-88 dBm  

                    Encryption key:on                    

                    ESSID:"3Com Private Connection"      

                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 22 Mb/s

                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s 

                              36 Mb/s; 48 Mb/s; 54 Mb/s                 

                    Mode:Master                                         

                    Extra:tsf=00000030d4f1726e                          

                    Extra: Last beacon: 474ms ago                       

                    IE: Unknown: 001733436F6D205072697661746520436F6E6E656374696F6E

                    IE: Unknown: 010582848B962C                                    

                    IE: Unknown: 03010B                                            

                    IE: Unknown: 2A0107                                            

                    IE: Unknown: 32080C1218243048606C                              

          Cell 02 - Address: 00:16:B6:1E:36:92                                     

                    Channel:11                                                     

                    Frequency:2.462 GHz (Channel 11)                               

                    Quality=22/70  Signal level=-88 dBm                            

                    Encryption key:on                                              

                    ESSID:"Bernard"                                                

                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s           

                              24 Mb/s; 36 Mb/s; 54 Mb/s                            

                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s                     

                    Mode:Master                                                    

                    Extra:tsf=00000015fbe7d371                                     

                    Extra: Last beacon: 476ms ago                                  

                    IE: Unknown: 00074265726E617264                                

                    IE: Unknown: 010882848B962430486C                              

                    IE: Unknown: 03010B

                    IE: Unknown: 2A0104

                    IE: Unknown: 2F0104

                    IE: Unknown: 32040C121860

                    IE: Unknown: DD06001018020014

          Cell 03 - Address: 00:12:0E:7D:51:BB

                    Channel:6

                    Frequency:2.437 GHz (Channel 6)

                    Quality=18/70  Signal level=-92 dBm

                    Encryption key:on

                    ESSID:"aztech"

                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 22 Mb/s

                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s

                              36 Mb/s; 48 Mb/s; 54 Mb/s

                    Mode:Master

                    Extra:tsf=00000005fbb3a1e2

                    Extra: Last beacon: 802ms ago

                    IE: Unknown: 0006617A74656368

                    IE: Unknown: 010582848B962C

                    IE: Unknown: 030106

                    IE: Unknown: 050402030000

                    IE: Unknown: 2A0107

                    IE: Unknown: 32080C1218243048606C
```

Any ideas?

P.S. I also read that perhaps WPA_supplicant is a better choice than wireless-tools. Can it also do random searching for any network, or will connections have to be preconfigured via the text config file (because that's all the guide talks about really)?

----------

## disi

The card and the driver is fine but not associated to any access point. 

You mentioned you use wicd on your desktop?

All you need to do is usually (I hope the name is correct):

```
# /etc/init.d/wicd-client start
```

and then use the GUI client "wicd-client" to connect to the networks.

If you have no Desktop you should use wpa_supplicant...

----------

## moult

Starting /etc/init.d/wicd doesn't help. I am already using wicd-client to connect/scan networks.

Also tried changing to modules=( "wpa_supplicant" ) (yes, I have wpa_supplicant emerged) in /etc/conf.d/net but that didn't help.

----------

## disi

Try this, please

create a file like wpa.cfg with the following content:

```
network={

ssid="myssid"

key_mgmt=WPA-PSK

psk="myverysecretpassphrase"

}
```

run wpa_supplicant:

```
# wpa_supplicant -B -c wpa.conf -i wlan0
```

get an IP address:

```
# dhcpcd wlan0
```

did that work and iwconfig shows the configured wlan0 and ifconfig an IP?

----------

## moult

Unfortunately no, it still results in a wlan0 timeout.

----------

## disi

To narrow it down to the dhcp, you could assign an ip address.

After you started wpa_supplicant, check iwconfig and look at Link Quality (should show something like 80/100). If this shows up, the wireless connection is fine.

Then assign an IP (regarding your network):

```
# ifconfig wlan0 192.168.1.45/24
```

Then add the default gateway (your router or something):

```
# route add default gw 192.168.1.254
```

Try to ping the gateway...

To fix a dhcp problem you could try a different client, e.g. dhclient instead of dhcpcd   :Idea: 

----------

## moult

I think I should reiterate my position.

I am in a location with no convenient wireless connection. There are a couple but all encrypted. I have no wireless router of my own. To try and get wireless working I am using a program on my phone which uses my phone's 3G connection and uses the phone's wifi capabilities to turn it into an ad-hoc connection.

With wicd-client it detects this as an unsecured network. Therefore the stuff put in the wpa.cfg is likely to be irrelevant as it talks about passphrases, WPA, etc.

When you say "start wpa_supplicant" - what do you mean? Do you mean running the wpa_supplicant command with the wpa.cfg? If so, then of course without a wpa.cfg that is relevant to the network (what should I put in the file for an unsecured network?) it will result in a link quality of 0 in iwconfig.

How would I connect to such an unsecured network?

----------

## disi

Sorry about that.

There is an example in /etc/wpa_supplicant/wpa_supplicant.conf

like this:

```
network={

         ssid=""

         key_mgmt=NONE

}

```

You could put in the ssid that you found unsecure, in that case as well...

----------

## moult

Ok I used that config and changed the ESSID to the name of the one that is insecure. I ran the wpa_supplicant command and it doesn't give any errors. Running iwconfig after that shows the new ESSID however the link quality is still 0.

----------

## disi

This means, that the problem is with the wireless...

If you look throught the documentation for wireless there is one example:

```
# IBSS/ad-hoc network with WPA-None/TKIP

network={

  ssid="test adhoc"

  mode=1

  proto=WPA

  key_mgmt=WPA-NONE

  pairwise=NONE

  group=TKIP

  psk="secret passphrase"

}
```

Maybe if you leave out all the encryption stuff... mode=1 uses ad-hoc.

----------

## moult

OK I decided to start from scratch as it seems to be getting worse, not better. (I did try mode=1 as you suggested to no effect).

I'm using wireless-tools. I won't be using anything other than WEP or plain old unsecured. I have wireless-tools installed and so I put this in my /etc/conf.d/net

```
modules=( "iwconfig" )

associate_order=( "any" )
```

ifconfig has wlan0 listed, and iwconfig has this, with Link quality:0 and no ESSID:

```
wlan0     IEEE 802.11bgn  ESSID:""

          Mode:Managed  Frequency:2.412 GHz  Access Point: Not-Associated

          Tx-Power=20 dBm

          Retry  long limit:7   RTS thr:off   Fragment thr:off

          Encryption key:off

          Power Management:on

          Link Quality:0  Signal level:0  Noise level:0

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

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

I then try iwlist scanning - as you can see it detects my unsecured network, named "Adhoc". I have tested connecting to this network with other devices so I know it's not a problem with the network.

```
epicbox ~ # iwlist scanning

lo        Interface doesn't support scanning.

eth0      Interface doesn't support scanning.

sit0      Interface doesn't support scanning.

wmaster0  Interface doesn't support scanning.

wlan0     Scan completed :

          Cell 01 - Address: 62:48:EE:A2:70:4E

                    Channel:1

                    Frequency:2.412 GHz (Channel 1)

                    Quality=70/70  Signal level=-39 dBm

                    Encryption key:off

                    ESSID:"Adhoc"

                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s

                              9 Mb/s; 12 Mb/s; 18 Mb/s

                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s

                    Mode:Ad-Hoc

                    Extra:tsf=00000000b9a3fec0

                    Extra: Last beacon: 1021ms ago

                    IE: Unknown: 00054164686F63

                    IE: Unknown: 010882840B160C121824

                    IE: Unknown: 030101

                    IE: Unknown: 06020000

                    IE: Unknown: 32043048606C
```

I open up wicd-client and it also lists "Adhoc" under wireless networks. tailing /var/log/messages shows that it times out when waiting for a carrier.

```
Nov 26 11:51:34 epicbox dhcpcd[6654]: eth0: sending signal 1 to pid 6274

Nov 26 11:51:34 epicbox dhcpcd[6654]: eth0: waiting for pid 6274 to exit

Nov 26 11:51:34 epicbox dhcpcd[6274]: eth0: received SIGHUP, releasing lease

Nov 26 11:51:34 epicbox kernel: [  663.239059] tg3 0000:08:00.0: PME# enabled

Nov 26 11:51:34 epicbox kernel: [  663.243543] tg3 0000:08:00.0: wake-up capability enabled by ACPI

Nov 26 11:51:34 epicbox kernel: [  663.269795] tg3 0000:08:00.0: wake-up capability disabled by ACPI

Nov 26 11:51:34 epicbox kernel: [  663.269808] tg3 0000:08:00.0: PME# disabled

Nov 26 11:51:34 epicbox kernel: [  663.280385] tg3 0000:08:00.0: irq 28 for MSI/MSI-X

Nov 26 11:51:34 epicbox kernel: [  663.412333] ADDRCONF(NETDEV_UP): eth0: link is not ready

Nov 26 11:51:34 epicbox dhcpcd[6698]: wlan0: dhcpcd not running

Nov 26 11:51:34 epicbox kernel: [  663.502925] ADDRCONF(NETDEV_UP): wlan0: link is not ready

Nov 26 11:51:34 epicbox dhcpcd[6707]: wlan0: dhcpcd 4.0.13 starting

Nov 26 11:51:35 epicbox dhcpcd[6707]: wlan0: waiting for carrier

Nov 26 11:51:36 epicbox kernel: [  664.982277] tg3: eth0: Link is up at 100 Mbps, full duplex.

Nov 26 11:51:36 epicbox kernel: [  664.982277] tg3: eth0: Flow control is on for TX and on for RX.

Nov 26 11:51:36 epicbox kernel: [  664.982277] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

Nov 26 11:51:47 epicbox kernel: [  675.952041] eth0: no IPv6 routers present

Nov 26 11:52:05 epicbox dhcpcd[6707]: wlan0: timed out
```

lsmod shows that my wireless driver ath9k is loaded:

```
epicbox ~ # lsmod | grep ath9k

ath9k                 243552  0
```

Trying to start up net.wlan0...

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

 * Caching service dependencies ...                                                                             [ ok ]

 * Service net.wlan0 starting

 wlan0 does not support scanning

 You either need to set a preferred_aps list in /etc/conf.d/wireless

    preferred_aps=( "ESSID1" "ESSID2" )

    and set associate_order_wlan0="forcepreferred"

    or set associate_order_wlan0="forcepreferredonly"

 or hardcode the ESSID to "any" and let the driver find an Access Point

    essid_wlan0="any"

 or configure defaulting to Ad-Hoc when Managed fails

    adhoc_essid_wlan0="WLAN"

 or hardcode the ESSID against the interface (not recommended)

    essid_wlan0="ESSID"

 Failed to configure wireless for wlan0                                                                         [ !! ]

 * ERROR:  net.wlan0 failed to start
```

At this point, I notice that the wifi light on my computer turns off, and now iwlist scanning says:

```
wlan0     Interface doesn't support scanning : Network is down
```

I do rmmod ath9k and modprobe ath9k, then add essid_wlan0="any" 

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

 * Service net.wlan0 starting                                                                                      

 Failed to configure wireless for wlan0                                                                         [ !! ]

 * ERROR:  net.wlan0 failed to start
```

With this error in /var/log/messages:

```
Nov 26 11:58:42 epicbox kernel: [ 1091.363887] ADDRCONF(NETDEV_UP): wlan0: link is not ready

Nov 26 11:58:53 epicbox rc-scripts: Failed to configure wireless for wlan0

Nov 26 11:58:53 epicbox rc-scripts: ERROR:  net.wlan0 failed to start
```

Repeating this when iwlist scanning does detect returns the same result.

Any ideas?

----------

## Mistwolf

This may or may not help:

either use net.wlan0 or wicd, not both.  They conflict on my system if both are started.

In other words, if you want to use wicd, stop net.wlan0 first.  If you want to use net.wlan0, stop/kill wicd first.

Hope this helps.

----------

## moult

Hmm - I'd like to say that was the solution but it isn't.

I want to double check my drivers. Here is my lspci -nn:

```
epicbox ~ # lspci -nn

00:00.0 RAM memory [0500]: nVidia Corporation MCP78S [GeForce 8200] Memory Controller [10de:0754] (rev a2)

00:01.0 ISA bridge [0601]: nVidia Corporation Device [10de:075e] (rev a2)

00:01.1 SMBus [0c05]: nVidia Corporation MCP78S [GeForce 8200] SMBus [10de:0752] (rev a1)

00:01.3 Co-processor [0b40]: nVidia Corporation MCP78S [GeForce 8200] Co-Processor [10de:0753] (rev a2)

00:01.4 RAM memory [0500]: nVidia Corporation MCP78S [GeForce 8200] Memory Controller [10de:0568] (rev a1)

00:02.0 USB Controller [0c03]: nVidia Corporation MCP78S [GeForce 8200] OHCI USB 1.1 Controller [10de:077b] (rev a1)

00:02.1 USB Controller [0c03]: nVidia Corporation MCP78S [GeForce 8200] EHCI USB 2.0 Controller [10de:077c] (rev a1)

00:04.0 USB Controller [0c03]: nVidia Corporation MCP78S [GeForce 8200] OHCI USB 1.1 Controller [10de:077d] (rev a1)

00:04.1 USB Controller [0c03]: nVidia Corporation MCP78S [GeForce 8200] EHCI USB 2.0 Controller [10de:077e] (rev a1)

00:07.0 Audio device [0403]: nVidia Corporation Device [10de:0774] (rev a1)

00:08.0 PCI bridge [0604]: nVidia Corporation MCP78S [GeForce 8200] PCI Bridge [10de:075a] (rev a1)

00:09.0 SATA controller [0106]: nVidia Corporation Device [10de:0ad5] (rev a2)

00:0b.0 PCI bridge [0604]: nVidia Corporation MCP78S [GeForce 8200] PCI Express Bridge [10de:0569] (rev a1)

00:13.0 PCI bridge [0604]: nVidia Corporation Device [10de:077a] (rev a1)

00:14.0 PCI bridge [0604]: nVidia Corporation Device [10de:077a] (rev a1)

00:15.0 PCI bridge [0604]: nVidia Corporation Device [10de:077a] (rev a1)

00:18.0 Host bridge [0600]: Advanced Micro Devices [AMD] Family 11h HyperTransport Configuration [1022:1300] (rev 40)

00:18.1 Host bridge [0600]: Advanced Micro Devices [AMD] Family 11h Address Map [1022:1301]

00:18.2 Host bridge [0600]: Advanced Micro Devices [AMD] Family 11h DRAM Controller [1022:1302]

00:18.3 Host bridge [0600]: Advanced Micro Devices [AMD] Family 11h Miscellaneous Control [1022:1303]

00:18.4 Host bridge [0600]: Advanced Micro Devices [AMD] Family 11h Link Control [1022:1304]

02:00.0 VGA compatible controller [0300]: nVidia Corporation GeForce 9100M G [10de:0844] (rev a2)

08:00.0 Ethernet controller [0200]: Broadcom Corporation NetXtreme BCM5764M Gigabit Ethernet PCIe [14e4:1684] (rev 10)

0b:00.0 Network controller [0280]: Atheros Communications Inc. Device [168c:002a] (rev 01)
```

and I've got CONFIG_ATH9K compiled in the kernel as a module. Is there anything else I'm missing?

Oh, and what is this madwifi thing I keep on hearing about - can it help my problem?

----------

## moult

Bumpity because I've made no progress and the problem remains the same.

----------

## d2_racing

Ok, did you install WICD ?

If yes, can you post this :

```

# rc-update show

# cat /etc/init.d/wicd

```

----------

## moult

Yes, I am only using wicd now.

```
epicbox ~ # rc-update show

                acpid |                  default                      

                 swap |                          boot                 

            syslog-ng |                  default

        device-mapper |                          boot

             mount-ro |         shutdown

                 root |                          boot

               net.lo |                          boot

                dmesg | sysinit

               procfs |                          boot

                 udev | sysinit

             bootmisc |                          boot

            savecache |         shutdown

            alsasound |                  default

    hibernate-cleanup |                          boot

                 mtab |                          boot

              modules |                          boot

                 wicd |                  default

                local |                  default      nonetwork

                 fsck |                          boot

          staticroute |                          boot

             hostname |                          boot

          consolefont |                          boot

         termencoding |                          boot

            killprocs |         shutdown

              keymaps |                          boot

              hwclock |                          boot

                  xdm |                  default

           localmount |                          boot

           vixie-cron |                  default

              urandom |                          boot

                 hald |                  default

                devfs | sysinit

             netmount |                  default

               sysctl |                          boot
```

and:

```
epicbox ~ # cat /etc/init.d/wicd

#!/sbin/runscript

# Copyright 1999-2006 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

opts="start stop restart"

WICD_DAEMON=/usr/sbin/wicd

WICD_PIDFILE=/var/run/wicd/wicd.pid

depend() {

        need dbus

}

start() {

        ebegin "Starting wicd daemon"

        "${WICD_DAEMON}" >/dev/null 2>&1

        eend $?

}

stop() {

        ebegin "Stopping wicd daemon"

        start-stop-daemon --stop --pidfile "${WICD_PIDFILE}"

        eend $?

}
```

----------

## d2_racing

Ok, try this :

```

# rc-update del wicd default

# rc-update add wicd boot

```

```

# nano /etc/init.d/wicd

```

You should have this :

```

depend() { 

        need dbus 

        need hald

} 

```

After that, reboot your box.

----------

## moult

Thanks! That solved it!

However I'm curious as to why I had to do those things to get it working?

----------

## d2_racing

Hald need to be there if you want that WICD works.

And since WICD is at the boot level, then you have a working network after the boot process.

----------

## moult

Then why is it that this isn't already in the init script by default? Why must I add it manually?

----------

## d2_racing

I don't know, maybe we should open a bugzilla for that, but maybe some people doesn't use hal and that's why it's not there. I don't know.

----------

## moult

Reported as bug and it seems as though (from the first comment) it would be a good idea to have it  :Smile: 

https://bugs.gentoo.org/show_bug.cgi?id=299206

----------

## d2_racing

Nice  :Razz: 

----------

