# wpa_supplicant and eth1 start order problem?

## pumpichank

Hi all, I've had Gentoo nicely installed on my Dell 300m notebook for over a year.  This machine has an ipw2100 and that has been working fine for a long time.  I connect to two different ssids regularly (work and home networks) using WEP, and I've also been successful connecting to open access points.

Now, work is switching to WPA so I need to configure eth1 to connect either to WPA-PSK when it associates with my work ssid, and WEP when it associates with my home ssid.  I can't seem to get the former to work automatically when the machine boots.  However, if I run wpa_supplicant manually, and then restart net.eth1, everything appears to work (hard to tell, but it sure looks like its associating with our new WPA ap and not the old WEP ap).

So I've done a "rc-update add wpa_supplicant default" but it looks like wpa_supplicant gets started after net.eth1.  When net.eth1 starts up it can't talk to wpa_supplicant and so it associates with the old WEP ap.  After the machine's all booted up, I have to stop net.eth1 and wpa_supplicant, then start wpa_supplicant manually and then net.eth1 manually, and it seems to associate with the WPA ap.

I'm sure I've screwed up something in the transition from my old set up to the new wpa_supplicant based config, but I can't figure out what.  Help is greatly appreciated!  I'll be happy to post any config files that you want to see.

----------

## TheRAt

Did you include the following into your /etc/conf.d/net?

```
modules=( "wpa_supplicant" )
```

Take a look at the Wireless Configuration and Startup howto at the Gentoo Wiki

----------

## pumpichank

Yep, I definitely have that line in my net file.  Doesn't seem to make a difference.

More information: on my WEP network, I have to stop wpa_supplicant and restart net.eth1 to get connected, but on my WPA network, I have to restart wpa_supplicant and then restart net.eth1 to get it to work.  It looks like none of this can work automatically at boot time, nor can it re-associate automatically when I move to a different network.

----------

## UberLord

You don't need the wpa_supplicant init script anymore as the net.xxx init scripts now control wpa_supplicant

----------

## pumpichank

Thanks for the suggestion -- I'm still not quite there.

So I turned off the wpa_supplicant init script, verified /etc/conf.d/net against the HOWTO and restarted.  However, on boot I get this error message: WEP key is not set for "XXX" - not connecting

Also, when the initial scan is done on boot time, wpa_supplicant finds the XXX network, but it thinks it requires WEP -- it doesn't though!  Okay, so if i then subsequently take down eth1, and run wpa_supplicant manually with:

wpa_supplicant -Dipw -ieth1 -c/etc/wpa_supplicant.conf

and then restart eth1, it finds the XXX network, correctly identifies it as WEP disabled, and properly associates with it.  I've verified that my /etc/conf.d/net file has:

```

modules=( "wpa_supplicant" )

wpa_supplicant_eth="-Dipw"

```

my /etc/conf.d/wpa_supplicant file has:

```

INTERFACES="eth1"

ARGS="-w -dd" # or w/o -dd; it doesn't matter

ARGS_eth1="-Dipw"

```

my /etc/wpa_supplicant.conf file has

```

network={

    ssid="XXX"

    key_mgmt=WPA-PSK

    proto=WPA

    group=TKIP

    psk=<big hex string>

}

```

What's going on?  Is it possible that when started by /etc/init.d/net.eth1 it's not finding the right wpa_supplicant.conf file?

----------

## UberLord

Sounds like it's not using wpa_supplicant as you don't see wpa_supplicant "scanning" with our init scripts

Try this

```
modules=( "wpa_supplicant" "!iwconfig" )
```

----------

## possumjc

pumpichank,

I was having a similar issue. I had checked all the conf files and everything was correct. I could manually connect by running wpa_supplicant from the command line. What I discovered is that my /etc/init.d/net.wlan0 file was an old version. I removed the file and created a symlink to /etc/init.d/net.lo and WPA started right up for wlan0 on boot and worked great. Hope this helps.

Regards,

Joel

----------

## pumpichank

Thanks for the suggestion Joel (and sorry to take so long to respond -- I was on vacation).  I tried as you suggested and unfortunately, I'm now getting the following error:

Failed to connect to wpa_supplicant - wpa_ctrl_open: no such file or directory

but which file or directory can't it find?  Certainly /var/run/wpa_supplicant exists.

----------

## possumjc

Does your wpa_supplicant.conf have any other options in it other than what was posted above? Perhaps you could post the whole file. There may be a problem with it.

Regards,

Joel

----------

## pumpichank

Here's my /etc/wpa_supplicant.conf file, sans sensitive information:

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

eapol_version=1

ap_scan=1

fast_reauth=1

network={

   ssid="XXX"

   key_mgmt=WPA-PSK

   proto=WPA

   group=TKIP

   #psk="xxx"

   psk=xxx

   priority=5

}

network={

   ssid="YYY"

   key_mgmt=NONE

   wep_key0=yyy

   priority=7

}

# All others

network={

       key_mgmt=NONE

       priority=1

}

```

Thanks!

----------

## pumpichank

Here's a follow up FTR to let you know where I am.

First, I had some weirdness in my /etc/init.d/net.lo file.  It apparently had gotten a very old copy of this, so the machine got quite hosed when net.eth1 symlinked to it.  I copied a net.lo file from another working Gentoo box, fixed the link and that helped.  So now both net.eth0 and net.eth1 point to net.lo.

Second, my /etc/conf.d/net script had some presumably old cruft from the wireless-tools days.  There was a comment that says: "Hook wireless into /etc/init.d/net.eth0" followed by a preup() and predown() function.  It also sourced /etc/init.d/wireless.sh.  I commented all that out.

Things are much closer now, but I've only tested connections at work.  I still cannot get associated to the work AP on boot (the boot message just says it's trying to bring up eth1, then "timed out").  However if I /etc/init.d/net.eth1 restart I get associated to the correct AP and everything appears to work fine.

I'm going to try the home network later and see if I can still associate with it.

Well, this isn't perfect -- it'd be great if everything worked on boot -- but it's not too bad, since I usually have to restart eth1 anyway when I move the notebook between networks (it doesn't auto-re-associate, which I believe is a known missing feature).

Oh yeah, I side-tracked into trying wpa_supplicant 0.4.3-r1 but that caused other problems (ioctl errors) so I downgraded back to the stable 0.3.8-r1 version.

----------

## pumpichank

Okay, one more data-point.  When I posted my last follow up, I still had my hardwired net.eth0 interface enabled.  When I rc-update del'd net.eth0 and rebooted, nothing worked.  wpa_supplicant never associated and nothing would get it to, including running wpa_supplicant manually and restarting net.eth1 several times.

So I re-enabled net.eth0, unplugging the ethernet cable and -- even though it fails to get a dhcp lease after about a 10 minute hang -- net.eth1 then tries and it successfully associates, gets a lease, and works perfectly!

Why would net.eth1 be dependent on net.eth0 starting up, even though the latter fails?

----------

## TheRAt

I wonder, if you still have old cruft in your /etc/conf.d/net file, do you run dispatch-conf or etc-update ater emerging updates? You may have other files with old configuration settings, which might need to be updated.

EDIT: also make sure that /etc/init.d/net.eth0 and /etc/init.d/net.eth1 are symlinks to /etc/init.d/net.lo.. eg.

```
lrwxrwxrwx  1 root root    6 Aug  3 22:42 net.eth0 -> net.lo*

-rwxr-xr-x  1 root root  24K Aug  3 22:44 net.lo*

lrwxrwxrwx  1 root root    6 Aug  2 16:50 net.eth1 -> net.lo*
```

Here is all I have in my /etc/conf.d/net, which works attaching to wireless access at 3 different sites on startup:

```
# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

dhcpcd_eth0="nontp"

modules=( "wpa_supplicant" )

wpa_supplicant_wlan0="-D ndiswrapper"

wpa_timeout_wlan0=20

dhcpcd_wlan0="nontp"
```

If you use static IP addresses, you can take a look at /etc/conf.d/net.example file for examples of how it is set up.

----------

## pumpichank

 *TheRAt wrote:*   

> I wonder, if you still have old cruft in your /etc/conf.d/net file, do you run dispatch-conf or etc-update ater emerging updates? You may have other files with old configuration settings, which might need to be updated.
> 
> 

 

Thanks for all your suggestions TheRAt.    Yes, I'm pretty religious about running etc-update after emerging in updates!

 *TheRAt wrote:*   

> 
> 
> EDIT: also make sure that /etc/init.d/net.eth0 and /etc/init.d/net.eth1 are symlinks to /etc/init.d/net.lo.. eg.
> 
> ```
> ...

 

Yep, I've definitely fixed this as there were several breakages here (see my earlier reply in this thread).

 *TheRAt wrote:*   

> 
> 
> Here is all I have in my /etc/conf.d/net, which works attaching to wireless access at 3 different sites on startup:
> 
> ```
> ...

 

It was definitely past time that I re-read net.example and wireless.example, as it's been probably 16 months or so so I first set this stuff up, and a lot has changed (or so it seems).  I really appreciate all the pointers and help!

----------

## .:deadhead:.

 *UberLord wrote:*   

> You don't need the wpa_supplicant init script anymore as the net.xxx init scripts now control wpa_supplicant

  :Twisted Evil:   :Very Happy:   :Twisted Evil:   :Very Happy:  Please upgrade AS SOON AS POSSIBLE the official guide! 

After 1 day hacking 'round I finally found this post and my pain has ended  :Very Happy:  It's real that nowhere is written to add it to default, but since I am a old time user, I don't pretend gentoo have to tell me what to do every time...  :Wink: 

Anyway: now everything works!

----------

## UberLord

 *.:deadhead:. wrote:*   

>  *UberLord wrote:*   You don't need the wpa_supplicant init script anymore as the net.xxx init scripts now control wpa_supplicant     Please upgrade AS SOON AS POSSIBLE the official guide! 
> 
> 

 

What official guide?

----------

## pumpichank

Just as another followup (maybe, hopefully my last on this thread  :Wink: , I've now gotten everything to work almost exactly the way I want.  I switch my home network to WPA, set up the keys in wpa_supplicant.conf and raised the timeout.  Now I can boot onto both networks, or restart net.eth1 to get reassociated with either.

My last remaining nit is that I had to turn on ssid broadcast on my home net.  Otherwise I think I'd have to use scan_ssid=1 and that just caused ioctl erors.  I see today that all new wireless related emerges are available (ieee80211, ipw2100, hostap-driver, wpa_supplicant).  I'm a little nervous to go futzing with things now that it's mostly working, but I might get brave and try to update those packages.  I'd like to get on 2.6.12 kernel also, but I couldn't with the last ipw2100 package that was available.

Thanks all, for your help.

----------

## UberLord

 *pumpichank wrote:*   

> My last remaining nit is that I had to turn on ssid broadcast on my home net.

 

That's not exactly a security issue when you're using WPA - as WPA kinda needs ssid broadcasting for the most part  :Wink: 

----------

## pumpichank

Okay, cool!  I had the same problem with WEP, but I don't care anymore since it's better to be WPA'ing anyway.  :Smile: 

----------

