Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
wpa_supplicant weird behaviour not honoring net.wlan0
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
abduct
Apprentice
Apprentice


Joined: 19 Mar 2015
Posts: 158

PostPosted: Sun Mar 11, 2018 5:48 pm    Post subject: wpa_supplicant weird behaviour not honoring net.wlan0 Reply with quote

I am playing with wpa_supplicant after setting it up according to the wiki, but there are a few things that seem to go wrong that I have to manually correct.

For instance on boot wpa_supplicant is started with these flags:

Code:
# ps aux | grep wpa
/usr/sbin/wpa_supplicant -B -M -c/etc/wpa_supplicant/wpa_supplicant.conf -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0


and when I use wpa_cli to setup and enable a network the wlan0 interface connects and authenticates, but does not retrieve an IP address.

I have to run
Code:

 # rc-service net.wlan0 restart
 * Bringing up interface wlan0
 *   Starting wpa_supplicant on wlan0 ...
Successfully initialized wpa_supplicant
ctrl_iface exists and seems to be in use - cannot override it
Delete '/var/run/wpa_supplicant/wlan0' manually if it is not used anymore
Failed to initialize control interface 'DIR=/var/run/wpa_supplicant GROUP=wheel'.
You may have another wpa_supplicant process already running or the file was
left by an unclean termination of wpa_supplicant in which case you will need
to manually remove this file before starting wpa_supplicant again.

nl80211: deinit ifname=wlan0 disabled_11b_rates=0
 *   start-stop-daemon: failed to start `/usr/sbin/wpa_supplicant'                                                                                                                                                                     [ !! ]
 * ERROR: net.wlan0 failed to start
# killall wpa_supplicant
# rc-service net.wlan0 restart
 * Bringing up interface wlan0
 *   Starting wpa_supplicant on wlan0 ...
Successfully initialized wpa_supplicant                                                                                                                                                                                                [ ok ]
 *   Starting wpa_cli on wlan0 ...                                                                                                                                                                                                     [ ok ]
 *   Backgrounding ... ...
 * WARNING: net.wlan0 has started, but is inactive

in order for the service to restart properly and allow the interface to obtain an IP address.

After the above the wpa_supplicant is started as

Code:
]# ps aux | grep wpa
/usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -W -B -i wlan0 -P /run/wpa_supplicant-wlan0.pid
/usr/bin/wpa_cli -a /etc/wpa_supplicant/wpa_cli.sh -p /var/run/wpa_supplicant -i wlan0 -P /run/wpa_cli-wlan0.pid -B


So here are a few questions:

-Why does the wiki specify the -M options in /etc/conf.d/wpa_supplicant? `man wpa_supplicant' does not list this option at all. What does it even do?

-How can I remove this weird auto startup of wpa_supplicant and use only the net.wlan0 service? I have the net.wlan0 rc set to run at the default run level along with net.eth0. I have a feeling the net.wlan0 service is launching some kind of dhcp service along side wpa_supplicant/wpa_cli where as what ever is starting the wpa_supplicant daemon first is not.

Here are my current configs for wpa_supplicant:

Code:
 # cat /etc/conf.d/wpa_supplicant
# conf.d file for wpa_supplicant
#
# Please check man 8 wpa_supplicant for more information about the options
# wpa_supplicant accepts.
#
wpa_supplicant_args="-B -M -c/etc/wpa_supplicant/wpa_supplicant.conf"


Code:
# cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
update_config=1

network={
        ssid="ssid"
        psk="passphrase"
}


Thanks for any information
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 5583
Location: Room 101

PostPosted: Sun Mar 11, 2018 9:08 pm    Post subject: Reply with quote

abduct wrote:
Code:
 # rc-service net.wlan0 restart
 * Bringing up interface wlan0
 *   Starting wpa_supplicant on wlan0 ...
[...]
# rc-service net.wlan0 restart
 * Bringing up interface wlan0
 *   Starting wpa_supplicant on wlan0 ...
Successfully initialized wpa_supplicant    [ ok ]

abduct ... you have wpa_supplicant and net.wlan0 in the runlevel (hence there being a cntl_interface in existance on initalisation), you should only have net.wlan0, it will start wpa_supplicant (if configured to do so via 'modules_wlan0='). Note that the configuration /etc/conf.d/wpa_supplicant is only used by wpa_supplicant (the service) and so you should configure via /etc/conf.d/net, eg:

Code:
modules_wlan0="wpa_supplicant dhcpcd"
wpa_supplicant_wlan0="-Dnl80211 -qq"
config_wlan0="dhcp"

Also, why start both the wired and the wireless interface?

HTH & best ... khay
Back to top
View user's profile Send private message
abduct
Apprentice
Apprentice


Joined: 19 Mar 2015
Posts: 158

PostPosted: Sun Mar 11, 2018 10:25 pm    Post subject: Reply with quote

@khayyam

Thanks for that, I didn't notice that wpa_supplicant was in the default runlevel for some reason. I've also corrected my /etc/conf.d/net to include a few more options.

I will reboot and check to see all is well after my updates are done.

As for starting both wired and wireless services, I use both on my laptop depending on where I am. I prefer to use wired over wireless when ever it is convenient for me.

Is this a bad thing?
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 5583
Location: Room 101

PostPosted: Mon Mar 12, 2018 9:44 am    Post subject: Reply with quote

abduct wrote:
As for starting both wired and wireless services, I use both on my laptop depending on where I am. I prefer to use wired over wireless when ever it is convenient for me. Is this a bad thing?

abduct ... it can be, and so you're best to use 'plug' (via sys-apps/ifplugd, or sys-apps/netplug), eg:

/etc/conf.d/net:
modules_eth0="plug dhcpcd"
modules_wlan0="plug wpa_supplicant dhcpcd"

This would then bring up the wired interface/service based on cable connection, switching to wireless when disconnected.

HTH & best ... khay
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6709
Location: Blighty

PostPosted: Mon Mar 12, 2018 4:23 pm    Post subject: Reply with quote

Another approach, and quite a lot easier, is to avoid using net.* and just add wpa_supplicant and dhcpcd to the default runlevels.
Configure wpa_supplicant to run for the interfaces you want, optionally using the -M directive to allow for pluggable wireless interfaces.

/etc/conf.d/wpa_supplicant
Code:
wpa_supplicant_args="-M"


dhcpcd will then react when wireless and wired become available and will prefer the wired connection through using route metrics.
The stock dhcpcd config works fine for this.

See the wiki for more complete details:
https://wiki.gentoo.org/wiki/Wpa_supplicant
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum