# Set up wpa_supplicant at boot

## Spidey

So, my wireless is working if I login as root, turn on the wifi card (iwconfig eth1 txpower on), start wpa_supplicant (/etc/init.d/wpa_supplicant start)  and then start dhcpcd eth1, to get a working IP.

I think I've got dhcpcd to run automatically, but I can't setup it to run on boot time and get a connection.

I think the startup script is using wireless-tools to connect. I've got that too for iwconfig and iwlist, but I need to connect to a WPA2 AP, so wireless-tools won't be enough. I don't like the idea of uninstalling wireless-tool so Gentoo fallback to wpa_supplicant, I just want to configure my notebook so it selects the right program to manage my device.

```
$ cat /etc/conf.d/net

config_eth0=( "dhcp noop" )

dns_domain_lo="SpideyHomeNetwork"

config_eth1=( "dhcp noop" )
```

See, I've tried modules=( "wpa_supplicant" ) with no success. What am I doing wrong?

Also, strangely I don't have a /etc/conf.d/net.example file, anyone know why? Any chance etc-update deleted it?

----------

## d2_racing

Hi, you need this inside your /etc/conf.d/net :

```

#WPA_SUPPLICANT

modules=( "wpa_supplicant" )

wpa_supplicant_eth1="-Dwext"

config_eth1=( "dhcp" )

```

Also, make sure that you have this :

```

# cd /etc/init.d

# ln -s net.lo net.eth1

# rc-update add net.eth1 default

```

Can you post this :

```

# lspci -n

```

----------

## Spidey

```
# /etc/init.d/net.eth1 start

net.eth1        | * Caching service dependencies ...                                                                                                                          [ ok ]

net.eth1        | * Bringing up interface eth1

net.eth1        | *   Configuring wireless network for eth1

net.eth1        | *   Scanning for access points

net.eth1        | *     Found "SpideyHomeNetwork" at 00:0D:0B:91:00:02, managed, encrypted

net.eth1        | *     Found "deltarzc" at 00:16:B6:A7:8A:68, managed, encrypted

net.eth1        | *   WEP key is not set for "SpideyHomeNetwork"

net.eth1        | *   WEP key is not set for "deltarzc"

net.eth1        | *   Couldn't associate with any access points on eth1

net.eth1        | *   Failed to configure wireless for eth1

net.eth1        | * ERROR: net.eth1 failed to start
```

```
# lspci -n

00:00.0 0600: 8086:2590 (rev 04)

00:02.0 0300: 8086:2592 (rev 04)

00:02.1 0380: 8086:2792 (rev 04)

00:1b.0 0403: 8086:2668 (rev 04)

00:1c.0 0604: 8086:2660 (rev 04)

00:1c.1 0604: 8086:2662 (rev 04)

00:1c.2 0604: 8086:2664 (rev 04)

00:1d.0 0c03: 8086:2658 (rev 04)

00:1d.1 0c03: 8086:2659 (rev 04)

00:1d.2 0c03: 8086:265a (rev 04)

00:1d.3 0c03: 8086:265b (rev 04)

00:1d.7 0c03: 8086:265c (rev 04)

00:1e.0 0604: 8086:2448 (rev d4)

00:1f.0 0601: 8086:2641 (rev 04)

00:1f.1 0101: 8086:266f (rev 04)

00:1f.3 0c05: 8086:266a (rev 04)

06:01.0 0607: 104c:ac56

06:04.0 0280: 8086:4220 (rev 05)

06:08.0 0200: 10ec:8139 (rev 10)

# lspci

00:00.0 Host bridge: Intel Corporation Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller (rev 04)

00:02.0 VGA compatible controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 04)

00:02.1 Display controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 04)

00:1b.0 Audio device: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) High Definition Audio Controller (rev 04)

00:1c.0 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 1 (rev 04)

00:1c.1 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 2 (rev 04)

00:1c.2 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 3 (rev 04)

00:1d.0 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1 (rev 04)

00:1d.1 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #2 (rev 04)

00:1d.2 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #3 (rev 04)

00:1d.3 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #4 (rev 04)

00:1d.7 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller (rev 04)

00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev d4)

00:1f.0 ISA bridge: Intel Corporation 82801FBM (ICH6M) LPC Interface Bridge (rev 04)

00:1f.1 IDE interface: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) IDE Controller (rev 04)

00:1f.3 SMBus: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) SMBus Controller (rev 04)

06:01.0 CardBus bridge: Texas Instruments PCI1510 PC card Cardbus Controller

06:04.0 Network controller: Intel Corporation PRO/Wireless 2200BG [Calexico2] Network Connection (rev 05)

06:08.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)
```

```
# ls -l /etc/init.d/ | grep net

lrwxrwxrwx 1 root root     6 Fev 10 09:16 net.eth0 -> net.lo

lrwxrwxrwx 1 root root     6 Fev 10 09:16 net.eth1 -> net.lo

-rwxr-xr-x 1 root root 15143 Jan 23 02:32 net.lo

-rwxr-xr-x 1 root root  2031 Jan 23 02:32 netmount

-rwxr-xr-x 1 root root  6203 Jan 23 02:32 network
```

```
# cat /etc/conf.d/net

dns_domain_lo="SpideyHomeNetwork"

modules=( "wpa_supplicant" )

wpa_supplicant_eth1="-Dwext"

config_eth1=( "dhcp" )
```

Also, I don't know why but I don't have /etc/conf.d/net.example. I guess it's not related, but I don't have /etc/conf,d/clock either, never had it btw.

----------

## d2_racing

Ok, can you post this :

```

# iwlist scan

# dmesg | tail

# cat /etc/wpa_supplicant/wpa_supplicant.conf

```

----------

## Spidey

dmesg just threw me some firmware errors. I re-run iwscan and the errors did not repeat, so I guess the errors were from somewhere in the past, can't say exactly when, anyways.

```
# iwlist scan

lo        Interface doesn't support scanning.

eth0      Interface doesn't support scanning.

eth1      Scan completed :

          Cell 01 - Address: 00:0D:0B:91:00:02

                    ESSID:"SpideyHomeNetwork" 

                    Protocol:IEEE 802.11bg    

                    Mode:Master               

                    Frequency:2.412 GHz (Channel 1)

                    Encryption key:on              

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

                              11 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s

                              48 Mb/s; 54 Mb/s                           

                    Quality=84/100  Signal level=-46 dBm                 

                    IE: IEEE 802.11i/WPA2 Version 1                      

                        Group Cipher : CCMP                              

                        Pairwise Ciphers (1) : CCMP                      

                        Authentication Suites (1) : PSK                  

                    Extra: Last beacon: 61ms ago                         

# dmesg | tail

[drm] TV-14: set mode NTSC 480i 0         

[drm] DAC-6: set mode 640x480 0           

[drm] DAC-6: set mode 640x480 0           

[drm] TV-14: set mode NTSC 480i 0         

[drm] TV-14: set mode NTSC 480i 0         

lib80211_crypt: registered algorithm 'CCMP'

[drm] LVDS-8: set mode 1280x800 1d         

ipw2200: Firmware error detected.  Restarting.

ipw2200: Firmware error detected.  Restarting.

[drm] LVDS-8: set mode 1280x800 1d            

# iwlist scan    

lo        Interface doesn't support scanning.

eth0      Interface doesn't support scanning.

eth1      Scan completed :

          Cell 01 - Address: 00:0D:0B:91:00:02

                    ESSID:"SpideyHomeNetwork"

                    Protocol:IEEE 802.11bg

                    Mode:Master

                    Frequency:2.412 GHz (Channel 1)

                    Encryption key:on

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

                              11 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s

                              48 Mb/s; 54 Mb/s

                    Quality=85/100  Signal level=-50 dBm

                    IE: IEEE 802.11i/WPA2 Version 1

                        Group Cipher : CCMP

                        Pairwise Ciphers (1) : CCMP

                        Authentication Suites (1) : PSK

                    Extra: Last beacon: 18ms ago

# dmesg | tail

[drm] TV-14: set mode NTSC 480i 0

[drm] DAC-6: set mode 640x480 0

[drm] DAC-6: set mode 640x480 0

[drm] TV-14: set mode NTSC 480i 0

[drm] TV-14: set mode NTSC 480i 0

lib80211_crypt: registered algorithm 'CCMP'

[drm] LVDS-8: set mode 1280x800 1d

ipw2200: Firmware error detected.  Restarting.

ipw2200: Firmware error detected.  Restarting.

[drm] LVDS-8: set mode 1280x800 1d

# cat /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant

update_config=1

network={

        ssid="abababababbabababa"

        psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        proto=RSN

        key_mgmt=WPA-PSK

        pairwise=CCMP

        auth_alg=OPEN

        disabled=1

        id_str="abcababcbabcacabcabac"

}

network={

        ssid="123123123"

        psk="544342312314125124213"

        proto=RSN

        key_mgmt=WPA-PSK

        pairwise=TKIP

        auth_alg=OPEN

}
```

Edited away my hostname/username and the wireless ssids/psks.

----------

## d2_racing

Look, I'm using a wpa2 ccmp like you :

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=wheel

ap_scan=0

#update_config=1

network={

   ssid="your_ssid"

   psk="your_passphrase"

   proto=WPA2

   key_mgmt=WPA-PSK

   pairwise=CCMP

   group=CCMP

   priority=5

}

```

Can you try this one and post the result ?

----------

## Spidey

I'll try next time I boot my laptop.

Just to make things clear, I never added disabled=1 into my main WPA2 configuration in wpa_supplicant.conf, it's probably the work of wpa_gui after connecting to the other SSID, maybe to make sure it reconnects to the right AP if suddenly the connection drops.

I'll try your settings, but I don't think the problem is in wpa_supplicant, but rather at boot time.

You see, while booting, eth1 scans for available networks, lists all, including mine, but then complains that no WEP key was set for it. But wait a minute, of course there is no WEP key configured, I use WPA2!

Another interesting bit of information, I had this netmount init script running at the default runlevel. I never added it, I guess this is default so netmounts or /etc/fstab can succeed. Since I don't have any, I removed it, because it was calling net.* as dependencies.

The fact is, as I can infer, that the Gentoo init system is very good for servers and desktops, but for laptops I'll need a little tweak to make things work properly. I don't want to remove net.eth0 from /etc/init.d since the init script is perfect to setup eth0 when I plug the cable in, without requiring network daemons polling for hotplug events. The same apply to eth1, I want the init script to scan for access points and connect to any listed in my wpa_supplicant.conf file. If no AP matching the configuration file were found, then do nothing.

So, the question is: should I just delete net.eth0 from /etc/init.d since I'm not using it for the intended purpose?

The other question is: how to make /etc/init.d/net.eth1 recognize my wpa_supplicant configuration without unmerging wireless-tools and connect to a configured AP and then run dhcpcd or set up static configs?

The last question: why my wireless card is recognized by udev as eth1 and not wlan0?

----------

## d2_racing

 *Spidey wrote:*   

> The last question: why my wireless card is recognized by udev as eth1 and not wlan0?

 

Simple, your wireless card is pretty old and it's not part of the new standard about the wireless, almost every intel, atheros wireless card use the wlan0 interface.

Also, I'm not sure, but Broadcom still use eth1 I think, so basically it's not a bug, it's only a feature  :Razz: 

----------

## Spidey

Woah, we're doing some progress! Now just /etc/init.d/wpa_supplicant is capable to setup eth1. But I think I shouldn't add it to any runlevel, but let net.eth1 handle it, shouldn't I?

I'll reboot to see if it already does.

edit: Ok, not so fast. dhcpcd didn't start automatically this time, last time it should had be up already and I forgot about it. I still need iwconfig to turn eth1 on (txpower on), then start wpa_supplicant. At least I got rid of wpa_gui.

Could you post your rc-update, d2? You can remove the extra daemons, just keep the basics and the relevant (network related) ones.

----------

## d2_racing

```

           alsasound | boot

            bootmisc | boot

             checkfs | boot

           checkroot | boot

               clock | boot

         consolefont | boot

               cupsd |      default

                hald |      default

            hostname | boot

             keymaps | boot

               local |      default nonetwork

          localmount | boot

             modules | boot

            net.eth0 |      default

              net.lo | boot

            netmount |      default

           rmnologin | boot

           syslog-ng |      default

             urandom | boot

          vixie-cron |      default

                 xdm |      default

```

That's my desktop, if on my laptop, I only have net.lo at boot level.

----------

