# What is supposed to start wpa_supplicant?

## ewaller

I am migrating a WEP based system to a WPA based system.  

I have followed the wireless guide and have searched most of the topics related to wpa_supplicant here in the forums. To encourage the use of wpa_supplicant, I include the line :

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

  in my /etc/conf.d/net file 

 I have also tried this without the _eth1.  When I run it,  It appears that /etc/init.d/net.eth1 (my ipw2200 wireless) does not invoke wpa_supplicant.  wpa_supplicant  is definitely not running after the script terminates (with a fail)

If I manully invoke 

```
 sudo   wpa_supplicant -B -ieth1 -c/etc/wpa_supplicant/wpa_supplicant.conf
```

,

 and then run the net.eth1 script, it works, associates, and obtains address enabling me to ask silly questions here. (Most of the time.  Sometimes the radio is off and I have to kick it with "iwconfig txpower on", Then it associates and works)

It appears that the net.eth1 script is supposed to start wpa_supplicant and it should remain running as a daemon after this script is finished.  Is this true, or is my head up and locked?

Thanks for your consideration.

----------

## TheAbu

Here is what I have in my /etc/conf.d/net and it works perfectly for me

wpa_supplicant_wlan0="-Dwext"

config_wlan0="192.168.0.21/24 brd 192.168.0.255"

I use a fix ip to shave off the time taken by dhcp when booting but you 

could replace the config_wlan0 part with

config_wlan0="dhcp"

or in your case 

config_eth0="dhcp"

or if you are not using open rc you need it to be like this I think 

config_eth0=("dhcp")

I know it's not a direct answer to your question but if it works ...  :Smile: 

----------

## d2_racing

Hi ewaller, can you post this :

```

# cat /etc/conf.d/net

# cat /etc/wpa_supplicant/wpa_supplicant.conf

# lspci

```

----------

## ewaller

/etc/conf.d/net -- comments deleted *Quote:*   

> 
> 
> modules_eth1=( "!iwconfig" "wpa_supplicant"  )
> 
> wpa_supplicant_eth1="-Dwext"                  
> ...

 

/etc/wpa_supplicant.conf

 *Quote:*   

> ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
> 
> update_config=1
> 
> ap_scan=1
> ...

 

lspci

 *Quote:*   

> 00:00.0 Host bridge: Intel Corporation Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller (rev 03)
> 
> 00:02.0 VGA compatible controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 03)
> 
> 00:02.1 Display controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 03)
> ...

 

The bridge and tunnel stuff support Virtualbox.  They are not currently enabled in rc-config.

I am off to work.  I can check the forums from there, but I cannot respond until this evening [GMT-7]

----------

## d2_racing

Hi, your /etc/conf.d/net should be like this :

```

#WPA_SUPPLICANT

modules=( "wpa_supplicant" )

wpa_supplicant_eth1="-Dwext"

config_eth1=( "dhcp" )

tuntap_vbox0="tap"

config_vbox0=( "null")

config_br0=( "dhcp" )

bridge_br0="wan vbox0"

depend_br0()

{

need net.wan

need net.vbox0

}

brctl_br0=( "setfd 0") 

```

----------

## d2_racing

And your /etc/wpa_supplicant/wpa_supplicant.conf 

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=wheel

ap_scan=0

#update_config=1

network={

   ssid="Champion"

   psk="Your_Passphrase"

   proto=WPA

   key_mgmt=WPA-PSK

   pairwise=CCMP TKIP

   group=CCMP TKIP

   priority=5

}

```

----------

## d2_racing

Finally, can you post this just to be sure of your configurations :

```

# iwlist scan 

```

----------

## ewaller

Thanks for the suggestions.  Try as I may, I cannot get wpa_supplicant to start using these clues.

I did add the following to etc/conf.d/net,

```
preup() {

#       # Remember to return 0 on success

        if  echo ${IFVAR} | grep eth1  ;

        then

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

                iwconfig eth1 txpower on

        fi

        return 0

}

```

and everything works, including associating at boot time.  I am, however, certain this is not how it is supposed to be done.

Any chance I am fighting with dbus?

----------

## d2_racing

Hi, can you post this actually :

```

# rc-update show

# cat /etc/conf.d/rc

```

----------

## ewaller

sudo rc-update show:

 *Quote:*   

>            vixie-cron |         graphical                                default
> 
>           consolefont |                                   boot
> 
>                  swap |                                   boot
> ...

 

etc/conf.d/rc

```
# /etc/conf.d/rc: Global config file for the Gentoo RC System                                                                                                               

# This is the number of tty's used in most of the rc-scripts (like

# consolefont, numlock, etc ...)                                  

RC_TTY_NUMBER=11

# Set to "yes" if you want the rc system to try and start services

# in parallel for a slight speed improvement. NOTE: When RC_PARALLEL_STARTUP

# is enabled, init script output is replaced with simple "service foo       

# starting/stopping" messages so that output is not mixed up.               

# You can stop this from happening on the command line by passing --verbose 

# to the init script or by setting RC_VERBOSE="yes" below.                  

RC_PARALLEL_STARTUP="no"

# Set RC_INTERACTIVE to "yes" and you'll be able to press the I key during

# boot so you can choose to start specific services. Set to "no" to disable

# this feature.                                                            

RC_INTERACTIVE="yes"

# Do we allow services to be hotplugged? If not, set to RC_HOTPLUG="no"

# NOTE: This does not affect anything hotplug/udev related, just the   

# starting/stopping of the init.d service triggered by hotplug.        

RC_HOTPLUG="yes"

# Dynamic /dev managers can trigger coldplug events which cause services to

# start before we are ready for them. If this happens, we can defer these  

# services to start in the boot runlevel. Set RC_COLDPLUG="no" if you don't

# want this.                                                               

# NOTE: This also affects module coldplugging in udev-096 and higher       

# If you want module coldplugging but not coldplugging of services then you

# can set RC_COLDPLUG="yes" and RC_PLUG_SERVICES="!*"                      

RC_COLDPLUG="yes"

# Some people want a finer grain over hotplug/coldplug. RC_PLUG_SERVICES is a

# list of services that are matched in order, either allowing or not. By     

# default we allow services through as RC_COLDPLUG/RC_HOTPLUG has to be yes  

# anyway.                                                                    

# Example - RC_PLUG_SERVICES="net.wlan !net.*"                               

# This allows net.wlan and any service not matching net.* to be plugged.     

RC_PLUG_SERVICES=""

# RC_NET_STRICT_CHECKING allows some flexibility with the 'net' service.

# The following values are allowed:                                     

#  none  - The 'net' service is always considered up.                   

#  no    - This basically means that at least one net.* service besides net.lo

#          must be up.  This can be used by notebook users that have a wifi and

#          a static nic, and only wants one up at any given time to have the   

#          'net' service seen as up.                                           

#  lo    - This is the same as the 'no' option, but net.lo is also counted.    

#          This should be useful to people that do not care about any specific 

#          interface being up at boot.                                         

#  yes   - For this ALL network interfaces MUST be up for the 'net' service to 

#          be considered up.                                                   

RC_NET_STRICT_CHECKING="lo"

# RC_DOWN_INTERFACE allows you to specify if RC will bring the interface

# completely down when it stops. The default is yes, but there are some 

# instances where you may not want this to happen such as using Wake On LAN.

RC_DOWN_INTERFACE="yes"

# RC_VOLUME_ORDER allows you to specify, or even remove the volume setup

# for various volume managers (MD, EVMS2, LVM, DM, etc).  Note that they are

# stopped in reverse order.                                                 

RC_VOLUME_ORDER="raid evms lvm dm"

# RC_VERBOSE will make init scripts more verbose. Only networking scripts

# really use this at this time, and this is useful for trouble shooting  

# any issues you may have.                                               

# This is also used to re-enable init script output for init scripts     

# started or stopped from the command line.                              

RC_VERBOSE="no"

# RC_BOOTLOG will generate a log of the boot messages shown on the console.  

# Useful for headless machines or debugging.  You need to emerge the         

# app-admin/showconsole package for this to work.  Note that this probably   

# won't work correctly with boot splash.                                     

RC_BOOTLOG="no"

# Set to "yes" if you want to benchmark system boot with bootchart.

# You'll need to emerge the app-benchmarks/bootchart package for this to work.

RC_BOOTCHART="no"

# RC_USE_FSTAB allows you to override the default mount options for the 

# standard /proc, /sys, /dev, and /dev/pts mount points.  Note that this 

# is the new way for selecting ramfs/tmpfs/etc... for udev mounting.     

RC_USE_FSTAB="no"

# RC_USE_CONFIG_PROFILE allows you to have different /etc/conf.d files 

# based on your runlevel - if a conf.d file for your profile does not exist

# then we try and use the default one.                                     

# To enable runlevel selection at boot, append "softlevel=foobar" to your  

# kernel line to change to the foobar runlevel.  Here we would search for  

# /etc/conf.d/<service>.foobar config files before trying to use the default

# /etc/conf.d/<service>.                                                    

# Note that it is only active if 'softlevel' was specified via the kernel line,

# and it is intended to use for different grub/lilo entries to specify config  

# changes for say laptops between home and work, where you would have setup    

# 'work' and 'home' runlevels, with /etc/conf.d/*.<runlevel> as needed.        

RC_USE_CONFIG_PROFILE="yes"

# RC_FORCE_AUTO tries its best to prevent user interaction during the boot and 

# shutdown process.  For example, fsck will automatically be run or volumes    

# remounted to create proper directory trees.  This feature can be dangerous   

# and is meant ONLY for headless machines where getting a physical console     

# hooked up is a huge pita.                                                    

RC_FORCE_AUTO="no"

# Use this variable to control the /dev management behavior.

#  auto   - let the scripts figure out what's best at boot  

#  devfs  - use devfs (requires sys-fs/devfsd)              

#  udev   - use udev (requires sys-fs/udev)                 

#  static - let the user manage /dev (YOU need to create ALL device nodes)

RC_DEVICES="auto"

# UDEV OPTION:

# Set to "yes" if you want to save /dev to a tarball on shutdown

# and restore it on startup.  This is useful if you have a lot of

# custom device nodes that udev does not handle/know about.      

RC_DEVICE_TARBALL="no"

# RC_DMESG_LEVEL sets the level at which logging of messages is done to the

# console.  See dmesg(8) for more info.                                    

RC_DMESG_LEVEL="1"

#

# Controlling start-stop-daemon behavior

# Set to "yes" if start-stop-daemon should always retry killing the

# service with sig KILL if it fails the first time.                

RC_RETRY_KILL="yes"

# Set the amount of seconds start-stop-daemon should wait between

# retries.                                                       

RC_RETRY_TIMEOUT=1

# Set the amount of times start-stop-daemon should try to kill

# a service before giving up.                                 

RC_RETRY_COUNT=5

# Set to "yes" if start-stop-daemon should fail if the service

# is marked as started, but not actually running on stop.     

RC_FAIL_ON_ZOMBIE="no"

# Set to "yes" if start-stop-daemon should attempt to kill

# any children left in the system.                        

# Be careful with this as it really does what it was on the tin.

# fex, if you're in an ssh process and you restart a service on which ssh

# depends then your terminal will be killed also.                        

RC_KILL_CHILDREN="no"

# Set the amount of seconds start-stop-daemon waits after starting

# the daemon to check it is still running. If it's not then we    

# try and stop any children if possible.                          

RC_WAIT_ON_START="0.1"                                            

##############################################################################

# SERVICE CONFIGURATION VARIABLES                                             

# These variables are documented here, but should be configured in            

# /etc/conf.d/foo for service foo and NOT enabled here unless you             

# really want them to work on a global basis.                                 

# Some daemons are started and stopped via start-stop-daemon.

# We can launch them through other daemons here, for example valgrind.

# This is only useful for serious debugging of the daemon             

# WARNING: If the script's "stop" function does not supply a PID file then

# all processes using the same daemon will be killed.

#RC_DAEMON="/usr/bin/valgrind --tool=memcheck --log-file=/tmp/valgrind.syslog-ng"

# strace needs to be prefixed with --background as it does not detach when

# it's following

#RC_DAEMON="--background /usr/sbin/strace -f -o /tmp/strace.syslog-ng"

# Pass ulimit parameters

#RC_ULIMIT="-u 30"

##############################################################################

#

# Internal configuration variables

#

# NB:  These are for advanced users, and you should really

#      know what you are doing before changing them!

#

# rc-scripts dep-cache directory

#

# NOTE:  Do not remove the next line, as its needed by the baselayout ebuild!

#

#  svcdir="/var/lib/init.d"

svcdir="/var/lib/init.d"

# Should we mount $svcdir in a ram disk for some speed increase

# for slower machines, or for the more extreme setups ?

svcmount="no"

# FS type that should be used for $svcdir.  Note that you need

# $svcmount above set to "yes" for this to work ...  Currently

# tmpfs, ramfs, and ramdisk are supported (tmpfs is the default).

svcfstype="tmpfs"

# Size of $svcdir in KB.  Note that ramfs doesn't support this

# due to kernel limitations.

svcsize=2048

```

And, though it was not requested:

rc-status -a

```
Runlevel: sysinit                                                                       

 dmesg                                   [  started  ]                                  

 udev                                    [  started  ]                                  

 devfs                                   [  started  ]                                  

Runlevel: graphical                                                                     

 syslog-ng                               [  started  ]                                  

 vixie-cron                              [  started  ]                                  

 portmap                                 [  started  ]                                  

 cupsd                                   [  started  ]                                  

 netmount                                [  started  ]                                  

 hald                                    [  started  ]                                  

 xdm                                     [  started  ]                                  

 alsasound                               [  started  ]                                  

 ntpd                                    [  started  ]                                  

 sshd                                    [  started  ]                                  

 local                                   [  started  ]                                  

Runlevel: single                                                                        

Runlevel: shutdown                                                                      

 savecache                               [  stopped  ]                                  

 killprocs                               [  stopped  ]                                  

 mount-ro                                [  stopped  ]                                  

Runlevel: boot                                                                          

 hwclock                                 [  started  ]                                  

 modules                                 [  started  ]                                  

 device-mapper                           [  started  ]                                  

 fsck                                    [  started  ]                                  

 root                                    [  started  ]                                  

 mtab                                    [  started  ]

 localmount                              [  started  ]

 termencoding                            [  started  ]

 consolefont                             [  started  ]

 swap                                    [  started  ]

 hostname                                [  started  ]

 sysctl                                  [  started  ]

 bootmisc                                [  started  ]

 net.lo                                  [  started  ]

 ntp-client                              [  started  ]

 portmap                                 [  started  ]

 nfs                                     [  started  ]

 acpid                                   [  started  ]

 procfs                                  [  started  ]

 keymaps                                 [  started  ]

 urandom                                 [  started  ]

Runlevel: nonetwork

 local                                   [  started  ]

Runlevel: default

 syslog-ng                               [  started  ]

 vixie-cron                              [  started  ]

 portmap                                 [  started  ]

 cupsd                                   [  started  ]

 netmount                                [  started  ]

 hald                                    [  started  ]

 alsasound                               [  started  ]

 ntpd                                    [  started  ]

 sshd                                    [  started  ]

 local                                   [  started  ]

Runlevel: hotplugged

 udev-postmount                          [  started  ]

 net.eth1                                [  started  ]

 net.eth0                                [ inactive  ]

Runlevel: needed

 sysfs                                   [  started  ]

 udev-mount                              [  started  ]

 net.eth1                                [  started  ]

 rpc.statd                               [  started  ]

 mdnsd                                   [  started  ]

 dbus                                    [  started  ]

Runlevel: manual

 net.eth0                                [ inactive  ]

 udev-postmount                          [  started  ]
```

----------

## d2_racing

Hi, if you want to start net.eth1 at boot time, then you should remove the 

```

preup() { 

#       # Remember to return 0 on success 

        if  echo ${IFVAR} | grep eth1  ; 

        then 

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

                iwconfig eth1 txpower on 

        fi 

        return 0 

} 

```

And try this instead :

```

# rc-update add net.eth1 boot

```

----------

## rsa4046

 *ewaller wrote:*   

> Thanks for the suggestions.  Try as I may, I cannot get wpa_supplicant to start using these clues.
> 
> I did add the following to etc/conf.d/net,
> 
> ```
> ...

 

Hi ewaller, Just wondered if you got this fixed -- I have identical issue: wireless network starts correctly only if wpa_supplicant is either started from the command line or by preup() branch in /etc/conf.d/net, but without either of these wpa_supplicant is apparently never called. Did you get this solved?

----------

## ewaller

rsa4046:

No, I am still working the problem.  As I posted, I do have a work around in the Pre-Up function -- but I don't want to diverge from the way it is supposed to work lest I get bitten latter.  I'm not a serious Bash script person, but I am now learning how to debug Bash scripts.  I'll work on this over the next few days and see what I can find.

d2_racing

Good catch on net.eth1 not being in the boot run level.  The details as to why not are lost on me as to why it is configured in that way.  Never-the-less, it does start at boot because ntp depends upon it.  Just for fun, I did add it to boot and it still does not load wpa_supplicant unless I include the Pre-up hack.

----------

## Mausballklauer

Hi,

I got exactly the same problem here. I recently did a fresh install of my system (going from ~x86 to ~amd64). On the "old" ~x86 system net.wlan0 did start wpa_supplicant just fine. Now, on the "new" ~amd64 system (still same hardware, same kernel config and I even copied most of the configuration files like /etc/conf.d/net or /etc/wpa_supplicant/wpa_supplicant.conf from the old install) net.wlan0 just ignores that there is wpa_supplicant around. Starting wpa_supplicant manually works, though.

Because I'm using my old configuration files (which worked well) I doubt that there is a configuration mistake or anything like that. Maybe I missed something to install. Or this might be a bug which should be reported maybe.

However, I'm now using the preup() stanza you mentioned earlier (thanks a lot!  :Smile:  ) and I'm now getting a working wlan0 at boot time. But like you I think this is not the way it is supposed to be done. Did you get any new conclusions in the meantime?

----------

## Kronykus

Just for comparison, I'll post my settings....   may or may not help...  I'm using ndiswrapper for a wireless pci card and everything works fine..

/etc/conf.d/net

```

modules=( "wpa_supplicant" )

wpa_supplicant_wlan0="-Dwext"

wpa_timeout_wlan0=5

config_wlan0=( "dhcp" )

postup() {

    if [[ "${IFACE}" == "wlan0" ]] ; then

        # Wait for connection to be ready to communicate

        sleep 5

    fi

    return 0

 }

dns_domain_lo=("Kronykus-PC")

dhcpcd_wlan0=("-N")

```

/etc/wpa_supplicant/wpa_supplicant.conf

```

ctrl_interface=/var/run/wpa_supplicant

ap_scan=1

update_config=1

network={

   ssid="********"

   psk="********"

   proto=RSN

   key_mgmt=WPA-PSK

   pairwise=TKIP

   priority=2

}

```

with net.wlan0 added to the boot runlevel

EDIT: and also dhcpcd added to default runlevel....    forgot about that one

----------

## dmpogo

 *Kronykus wrote:*   

> 
> 
> EDIT: and also dhcpcd added to default runlevel....    forgot about that one

 

well, this is needed only if you run dhcp server.

----------

## dmpogo

There is actually some fine point how wpa_supplicant interacts with   /etc/init.d/net.wlan0 (or whatever is your wireless interface).

It is that if you run

/etc/init.d/net.wlan0 start

then /etc/init.d/net.wlan0 start is actually called twice.   First is your run, it launchs wpa_supplicant as well as wpa_cli in the daemon mode with the action file /etc/wpa_supplicant/wpa_cli.sh.   After wpa_supplicant associates with AP, it sends wpa_cli 'CONNECTED' signal, on which wpa_cli calls /etc/wpa_supplicant/wpa_cli.sh with CONNECTED argument, which in turn, calls '/etc/init.d/net.wlan0 start' again !!! It seems cause no harm (actually, the second call I think fails), but if one has preup() function defined, it is also called twice.

I am still a bit puzzled how to start wireless network cleanly, while using preup(), besides checking interface status from within preup.

----------

## wthrowe

This sounds like bug 277594.  Check /lib64/rc/cache/nettree to see if it has the correct path to wpa_supplicant (should be /usr/sbin/wpa_supplicant).  If not, edit nettree and see if that fixes your problem.

----------

