# wpa_supplicant

## mreff555

I've been having issues trying to keep a stable connection to the internet with a small headless system.

It is strictly wireless and should boot and and establish a connection using wpa supplicant, and start up sshd. I'am probably now going to make the connection static, but in the past it was dynamic. The problem is, the way I have it set up now, it connects and works for a while, but cuts out after about 20 minutes. before I try trouble shooting what could be signal or power issues, I want to confirm that I am doing this right. 

I originally created a symbolic link to net.lo called net.wlan0 (my wireless device) and added it to the default profile. After rebooting I found it did nothing. I removed it and set added wpa_supplicant to the default. after rebooting I discovered it had established a wireless connection but not brought up dhcp. Adding dhcpcd to the default and rebooting I started up with a connection to the internet however

1. it disconnects after a few minutes

2. sshd crashes because for some reason it insists on starting dhcpcd itself.

if I remove dhcpcd and add sshd to the default... so to recap just wpa_supplicant and sshd as default, my connection works on reboot. However it still quits on me. 

What is the correct way of doing it. I thought net.wlan0 was supposed to somehow bring up my connection and dhcp. Is there a config I have to edit to tell it what I want to use? I managed to accomplish this on my current machine but I cannot remember what I did.

----------

## DONAHUE

 *Quote:*   

> [*] Networking support  ---> 
> 
> [ ]     enable powersave by default

  If enabled could be your problem.

----------

## The Doctor

A note about method. I think you would have a better setup to use /etc/conf.d/net to define your network settings, which should define dhcdpcd and wpa_supplicant. Wpa_supplicant of course needs to be configured correctly. Then when net.wlan0 starts it runs wpa_supplicant and dhcpcd. Check the on line documentation for details.

Starting wpa_supplicant and dhcpcd directly may work, but using the network scripts are more elegant. wpa_supplicant by itself is more appropriate to using wpa_gui for a laptop rather than normal connections.

----------

## Logicien

Use net.wlan0 to configure your wireless card correctly depend on how you understand the file/ usr/share/doc/openrc*/net.example* that seem's to be the only help to an appropriate edition of the /etc/conf.d/net file used for Gentoo network setup.

About Wpa_supplicant, you can use the Linux wireless extensions driver call wext or the nl80211 driver for kernel drivers who use the 80211 specifications. The -D option of the wpa_supplicant command allow you the choose between the two. You can try them one after the other to see if it make a difference.

To try to minimise disconnections I use some personnal parameters with the cfg80211 and mac80211 modules in /etc/modprobe.d/modprobe.conf

```
options cfg80211 ieee80211_regdom=CA

options mac80211 max_nullfunc_tries=60 max_probe_tries=60 probe_wait_ms=3600000
```

Choose your appropriate country. I never had trouble with those parameters, but I cannot confirm that they aid. That's suppose that your wireless support is compiled in modules, what I think is the most common way to configure the kernel.

You can disable the powersaving mode of your wireless card at any time with the iwconfig and iw commands, what I always do on all sides of my local wireless network. More, I disable powersaving on the port on which the wireless card is connected, for met it's PCIe.

With wireless connectivity problems, I think it's a good idea to run the processor at the performance frequency scaling or at the same frequency.

----------

## mreff555

I know this thread is old but since I spent so much time working on it, and most of the documentation I found I figured I'd share what I found.

The wpa_supplicant init script assumes that wpa_supplicant will guess your driver correctly. If your driver is not wext, It probably will not. In my case only nl80211 works.

the init script executes wpa supplicant with the following arguments.

The defined conf file

The defined interface

a variable obtained from /etc/conf.d/net

Chances are your driver needs to be included in this variable.

As soon as I came to understand this, everything made much more sense.

for weeks I had the line:

wpa_supplicant_net.wlp4s0="nl80211"

in my "/etc/conf.d/net" file and I got strange errors whenever I tried to boot with net.wlp4s0 set to default in my init scripts

It turns out what I should have had was:

wpa_supplicant_net.wlp4s0="-Dnl80211"

It's a shame it took me so long to figure it out. oh well hope this helps someone.

----------

