# [SOLVED] wpa_supplicant+dhcpcd and init.d/

## Moshanator

I am running handbook-installed Gentoo on a Compaq nx6325 (amd64) with a wifi chip that uses the b43 driver.

I have no net.* scripts enabled for startup except for net.lo.

Here is how I connect manually to wireless internet:

# wpa_supplicant -Dwext -c/etc/wpa_supplicant.conf -iwlan0 -B

# dhcpcd wlan0

Question: How do I make the net.* scripts do that?

Relevant info:

/etc/wpa_supplicant.conf (is actually a symlink to /etc/wpa_supplicant/wpa_supplicant.conf, because portage said so)

```
ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=0

ap_scan=1      # wpa_supplicant -Dwext -c/etc/wpa_supplicant.conf -iwlan0 -B

      # dhcpcd wlan0

network={

  ssid="SpeedTouch******"

  psk="very secret passphrase"

  priority=5

}
```

/etc/conf.d/net (Sometimes I use a wired connection when no wireless is available)

```
config_eth0=("dhcp")

config_wlan0=("dhcp")

# ifplugd would try to bring up wlan0 but wpa_supplicant already did that so they conflict eachother

modules_wlan0=("!ifplugd")
```

If I have missed a vital bit of RTFM, point me in the right direction.

----------

## albright

I think you would at least need these lines in /etc/conf.d/net

```
modules=( "wpa_supplicant" )

wpa_supplicant_wlan0="-Dwext"
```

in addition to what you have (never seen that "conflict" line

before - what does it do BTW?)

----------

## Moshanator

tl;dr: I don't want to use ifplugd for wlan0

I added that conflict comment.  Let me demonstrate:

# wpa_supplicant -Dwext -c/etc/wpa_supplicant.conf -iwlan0

CTRL-EVENT-SCAN-RESULTS

Trying to associate with 00:14:7f:25:8d:** (SSID='Speedtouch******' freq=2412 MHz)

Associated with 00:14:7f:25:8d:**

WPA: Key negotiation completed with 00:14:7f:25:8d:**

CTRL-EVENT-CONNECTED - Connection to 00:14:7f:25:8d:** completed (auth) [id=0 id_str=]

Now that wpa_supplicant is done, I switch to tty2 and run:# ifplugd --no-daemon --api-mode=wlan --iface=wlan0

...

Link beat detected.

Executing '/etc/ifplugd/ifplugd.action wlan0 up'

client: ctrl_iface exists and seems to be in use - cannot override it

client: Delete '/var/run/wpa_supplicant/wlan0' manually if it is not used anymore

client: Failed to initialize control interface '/var/run/wpa_supplicant'

client: You may have another wpa_supplicant process already running or the file was

...

and in tty1, wpa_supplicant says network is down

in tty2, ifplugd says link beat is lost and takes wlan0 down, thus sabotaging wpa_supplicant. The fiasco continues.

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

```
config_eth0=("dhcp")

config_wlan0=("dhcp")

modules_wlan0=("wpa_supplicant")

wpa_supplicant_wlan0="-Dwext -c/etc/wpa_supplicant.conf -iwlan0"

ifplugd_wlan0="--api-mode=wlan"
```

However, with the /etc/conf.d/net file described in the OP they do not conflict. I think this has to do with ifplugd calling wpa_supplicant (as instructed from conf.d/net), though one is already running.

----------

## Moshanator

Back to topic:

With the suggested lines my conf.d/net now looks like this:

```
config_eth0=("dhcp")

config_wlan0=("dhcp")

modules_wlan0=("!ifplugd" "wpa_supplicant")

wpa_supplicant_wlan0="-Dwext -c/etc/wpa_supplicant.conf -iwlan0"
```

And here is what it does:

# /etc/init.d/net.wlan0 start --verbose

...

modules: apipa arping ccwgroup macchanger macnet rename wpa_supplicant essidnet iptunnel ifconfig system dhcpcd ip6to4

  wpa_supplicant provides wireless

  ifconfig provides interface

  dhcpcd provides dhcp

Configuring wlan0 for MAC address 00:14:A5:F5:A1:B3 ...

wpa_supplicant only works on wireless interfaces

unless the -D wired option is specified

...

wlan0: dhcpcd 4.0.15 starting

wlan0: waiting for carrier

wlan0: timed out

Looks like wpa_supplicant doesn't get the -Dwext option?

----------

## albright

are you using openrc by any chance; if so see

this thread: https://forums.gentoo.org/viewtopic-t-824918-highlight-.html

----------

## Moshanator

# emerge --info | grep sys-

sys-apps/baselayout:  1.12.13

sys-apps/sandbox: 1.6-r2

sys-devel/autoconf: 2.63-r1

sys-devel/automake: 1.10.3

sys-devel/binutils: 2.18-r3

sys-devel/gcc: 4.3.4

sys-devel/gcc-config: 1.4.1

sys-devel/libtool 2.2.6b

# uname -r

2.6.34-rc5-git2

No, I'm not using openrc. Should I?

And that link you posted, it's talking about net.wlan0 failing to find wpa_supplicant. I don't think it's the issue here, because net.wlan0 is complaining about parameters, not the binary itself. Will check though.

----------

## albright

I think the line:

wpa_supplicant_wlan0="-Dwext -c/etc/wpa_supplicant.conf -iwlan0"

should be simply

wpa_supplicant="-Dwext"

But also is wpa_supplicant.conf really in /etc/ and not

/etc/wpa_supplicant/ (where it belongs).

The problem seems to be that /etc/conf.d/net is not starting

wpa_supplicant. This happened to me because of a misconfiguration

of openrc, but that is not your problem.

----------

## Moshanator

I checked and /sbin/wpa_supplicant is a symlink to /usr/sbin/wpa_supplicant. Also, there is no such directory as /lib/rc or /lib64/rc. Locating the binary is definitely not an issue for net.wlan0.

wpa_supplicant.conf is in /etc/wpa_supplicant/, but there is a symlink to it in /etc/. I am a lazy typer.

As for the wpa_supplicant line, I changed it to:

wpa_supplicant_wlan0="-Dwext"

which changed nothing.

Then I changed it towpa_supplicant="-Dwext"

and, in addition to the "wpa_supplicant only works on wireless interfaces", it said:wpa_supplicant_wlan0 does not define a driver

So net.wlan0 does see the -Dwext option, otherwise she wouldn't complain about it missing. The option works when manually invoking wpa_supplicant. Why isn't net.wlan0 happy with it then?

----------

## albright

you don't have net.lo as a boot service? Maybe it

needs to be started ??

wpa_supplicant_wlan0 tells the system which interface

needs wpa_supplicant - otherwise I think it tries to use

is on all network interfaces ...

(you won't have /lib/rc unless you use openrc, which you

don't and I would not advise at this point)

----------

## Moshanator

net.lo is started on boot as it should be, I never disabled it. First post was misleading, will edit that right now.

----------

## d2_racing

For the record, with OpenRC, you can flush about 90% of your network config, because the new /etc/init.d/wpa_supplicant handle your wifi card  :Razz: 

----------

## Moshanator

I had little to lose, so I emerged openrc, followed the migration guide and did everything etc-update told me to. There is still no wpa_supplicant init script (AFAIK it doesn't ship with the default openrc ebuild), but the new baselayout manages to start wpa_supplicant, wpa_cli and dhcpcd successfully.

Thanks for the suggestions.

----------

## albright

 *Quote:*   

> the new baselayout manages to start wpa_supplicant, wpa_cli and dhcpcd successfully. 

 

Good work!

----------

## d2_racing

Nice  :Razz: 

----------

