# [solved] wpa_supplicant connects but no IP is assigned

## bifi.ftw

Greetings everybody,

Some time ago I was already able to connect to wireless networks, however, not anymore.

Also I can use my laptop as a hotspot, therefore I am confident that my general setup (drivers, etc.) works.

As described in the title wpa_supplicant connects to the desired network but no IP is recieved, consequently not internet connection is available

For unknown reasons wpa_cli/wpa_gui only works as root, otherwise the error message "Could not connect to wpa_supplicant: (nil) - re-trying" is prompted.

I'm not sure which information to append, so please let me know if additional information is required.

/etc/conf.d/net

```
# Network group

dns_domain_lo="linuxnetwork"

# Use dhcp client

modules_enp4s0f1="dhcp"

modules_wlp3s0="wpa_supplicant"

# dhcp or fixed ip

config_enp4s0f1="dhcp"

config_wlp3s0="dhcp"

# Exclude DNS from DHCP

dhcp_enp4s0f1="release nodns"

dhcp_wlp3s0="release nodns"

# DNS server

dns_servers_enp4s0f1="37.58.63.27 46.101.70.183"

dns_servers_wlp3s0="37.58.63.27 46.101.70.183"

```

/etc/wpa_supplicant/wpa_supplicant.conf

```
ctrl_interface=DIR=/var/run/wpa_supplicant

ctrl_interface_group=wheel

update_config=1

network={

   ssid="morningstar"

   scan_ssid=1

   psk="***"

   proto=RSN

   key_mgmt=WPA-PSK

   priority=5

   disabled=1

}

network={

   ssid="eduroam"

   proto=RSN

   key_mgmt=WPA-EAP

   pairwise=CCMP

   auth_alg=OPEN

   eap=PEAP

   identity="***

   anonymous_identity="anonymous@mwn.de"

   password=***

   ca_cert="/etc/ssl/certs/Deutsche_Telekom_Root_CA_2.pem"

   subject_match="radius.lrz.de"

   phase2="auth=MSCHAPV2"

}

```

Message when starting wpa_gui

```

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-b

```

Output of wpa_cli when connecting with home wifi

```

> select_network morningstar

OK

<3>CTRL-EVENT-SCAN-STARTED 

<3>CTRL-EVENT-SCAN-RESULTS 

<3>SME: Trying to authenticate with 4c:eb:42:4d:6b:57 (SSID='morningstar' freq=2442 MHz)

<3>Trying to associate with 4c:eb:42:4d:6b:57 (SSID='morningstar' freq=2442 MHz)

<3>Associated with 4c:eb:42:4d:6b:57

<3>CTRL-EVENT-SUBNET-STATUS-UPDATE status=0

<3>WPA: Key negotiation completed with 4c:eb:42:4d:6b:57 [PTK=CCMP GTK=CCMP]

<3>CTRL-EVENT-CONNECTED - Connection to 4c:eb:42:4d:6b:57 completed [id=0 id_str=]

```

Thank you to anybody helping me out.

bifi.Last edited by bifi.ftw on Mon Apr 23, 2018 8:25 am; edited 1 time in total

----------

## khayyam

 *bifi.ftw wrote:*   

> For unknown reasons wpa_cli/wpa_gui only works as root, otherwise the error message "Could not connect to wpa_supplicant: (nil) - re-trying" is prompted.

 

bifi.ftw ... is user in the group 'wheel'? ... you won't be able to connect to the socket, and wpa_cli/wpa_gui will fail for this reason. Otherwise, XDG_RUNTIME_DIR or '/tmp/runtime-b' is QT related it's not used by wpa_supplicant ... and so I doubt this has anything to do with it.

 *bifi.ftw wrote:*   

> 
> 
> ```
> modules_enp4s0f1="dhcp"
> 
> ...

 

I'm not sure there is a dhcp client called 'dhcp' that should be 'dhcpcd' or 'dhclient' (for example) :

```
modules_enp4s0f1="dhcpcd"

modules_wlp3s0="!plug wpa_supplicant dhcpcd"

config_enp4s0f1="dhcp"

config_wlp3s0="dhcp"
```

... so I think that's the root of your problem.

HTH & best ... khay

----------

## bifi.ftw

Thanks for your reply.

I switched to dhcpcd (which was uninstalled, during boot I now get my IP assign by dhcpcd.

However, I still get no IP address assigned when I'm trying to connect to a wifi network, the problem remains unchanged.

New /etc/conf.d/net

```

# Network group

dns_domain_lo="linuxnetwork"

# Use dhcp client

modules_enp4s0f1="dhcpcd"

modules_wlp3s0="!plug wpa_supplicant dhcpcd"

#modules_enp4s0f1="dhcp"

#modules_wlp3s0="wpa_supplicant"

# dhcp or fixed ip

config_enp4s0f1="dhcp"

config_wlp3s0="dhcp"

# Exclude DNS from DHCP

dhcp_enp4s0f1="release nodns"

dhcp_wlp3s0="release nodns"

# DNS server

dns_servers_enp4s0f1="37.58.63.27 46.101.70.183"

dns_servers_wlp3s0="37.58.63.27 46.101.70.183"

```

Regarding the 'wheel'-group:

```

wheel:x:10:root,bifi

```

bifi is in, it but it still doesn't work.

----------

## khayyam

 *bifi.ftw wrote:*   

> I switched to dhcpcd (which was uninstalled, during boot I now get my IP assign by dhcpcd. However, I still get no IP address assigned when I'm trying to connect to a wifi network, the problem remains unchanged.

 

bifi.ftw ... hmmm ... ok, I think I see why, you have the old syntax in wpa_supplicant.conf, change to the following:

```
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
```

I'm not sure this would effect dhcp assignment, but it's probably the cause of not being able to connect to the socket. You should check owner/group of /run/wpa_supplicant/wlp3s0 ... it should be 'root wheel' but I suspect yours is currently 'root root'.

Should that not fix things then please post the output of the following:

```
# egrep '^[^#]' /etc/rc.conf

# egrep '^[^#]' /etc/dhcpcd.conf

# rc-status default

# wpa_cli status

# iw dev wlp3s0 station dump
```

You're welcome & best ... khay

----------

## bifi.ftw

I did not check with the old syntax, but after the change of wpa_supplicant.conf /run/wpa_supplicant/wlp3s0 is "root wheel".

The problem still remains.

egrep '^[^#]' /etc/rc.conf

```
rc_shell=/sbin/sulogin

unicode="YES"

rc_tty_number=12
```

egrep '^[^#]' /etc/dhcpcd.conf

Those are the vanilla settings, I did not modify anything.

```
hostname

duid

persistent

option rapid_commit

option domain_name_servers, domain_name, domain_search, host_name

option classless_static_routes

option interface_mtu

require dhcp_server_identifier

slaac private
```

rc-status default 

Note: for testing I start /etc/init.d/wpa_supplicant manually, my wifi card is not started on boot, hope that's not the problem.

```
Runlevel: default

 dbus                                                                                       [  started  ]

 metalog                                                                                    [  started  ]

 net.enp4s0f1                                                                               [  started  ]

 consolekit                                                                                 [  started  ]

 netmount                                                                                   [  stopped  ]

 xdm                                                                                        [  started  ]

 cronie                                                                                     [  started  ]

 local                                                                                      [  started  ]
```

wpa_cli status 

```

Selected interface 'wlp3s0'

bssid=4c:eb:42:4d:6b:57

freq=2442

ssid=morningstar

id=0

mode=station

pairwise_cipher=CCMP

group_cipher=CCMP

key_mgmt=WPA2-PSK

wpa_state=COMPLETED

address=ac:fd:ce:e5:0a:1f
```

iw dev wlp3s0 station dump

```

Station 4c:eb:42:4d:6b:57 (on wlp3s0)

   inactive time:   3939 ms

   rx bytes:   5709

   rx packets:   41

   tx bytes:   1584

   tx packets:   15

   tx retries:   0

   tx failed:   0

   beacon loss:   0

   rx drop misc:   1

   signal:     -39 [-39] dBm

   signal avg:   -39 [-39] dBm

   tx bitrate:   130.0 MBit/s MCS 15

   rx bitrate:   54.0 MBit/s

   authorized:   yes

   authenticated:   yes

   associated:   yes

   preamble:   long

   WMM/WME:   yes

   MFP:      no

   TDLS peer:   no

   DTIM period:   3

   beacon interval:100

   short preamble:   yes

   short slot time:yes

   connected time:   292 seconds

```

Thank you for your kind help.

----------

## khayyam

bifi.ftw ...

if starting wpa_supplicant "manually" then any configuration from /etc/conf.d/net isn't applied ... you would need to start net.wlp3s0 for this to occur (and have dhcpcd run).

As for wpa_supplicant, I should have asked to see the full permission/ownership of the directories above (though I don't expect this to be the problem). 

```
# ls -ld /run{,/wpa_supplicant{,/wlp3s0}}
```

Also, is selinux or grsec in use?

Again, you're welcome & best ... khay

----------

## bifi.ftw

Since I usually don't need a wifi connection I figured I don't need my wifi card active or is setting it up on boot and letting it scan every x seconds two different things?

I don't need a wifi connection 90% of the time so I don't want it to be scanning all the time.

If that's not the case anyway should I just add net.wlp3s0 to boot level in rc?

----------

## khayyam

 *bifi.ftw wrote:*   

> Since I usually don't need a wifi connection I figured I don't need my wifi card active or is setting it up on boot and letting it scan every x seconds two different things? I don't need a wifi connection 90% of the time so I don't want it to be scanning all the time. If that's not the case anyway should I just add net.wlp3s0 to boot level in rc?

 

bifi.ftw ... you don't need to add it to the 'default' runlevel (and definitely not 'boot'), simply start net.wlp3s0 in stead of wpa_supplicant.

There are various ways you could manage this, ie via 'plug' (ie, sys-apps/ifplugd) ... which would allow for switching between ethernet and wireless on the basis of there being a cable connected, or not. Or by using dhcpcd's 10-wpa_supplicant (and possibly your rfkill key). Or you could create runlevels for 'eth' and 'wlan' and so switch between them with 'rc <runlevel>'.

best ... khay

----------

## bifi.ftw

khayyam, thank you for you patient help.

This did the trick, wpa_gui now also works as non-root.

For everybody reading this who also does not get an ip assigned after successfully connecting to a wifi network:

check if you start wifi-card with /etc/init.d/net.wlan0 and not /etc/init.d/wpa_supplicant because otherwise your config in /etc/conf.d/net does not get applied (obviously).

----------

## Semantika

Hello Khayyman,

I am having the same problem with wpa_gui, but I don't get what you mean by:

"f starting wpa_supplicant "manually" then any configuration from /etc/conf.d/net isn't applied ... you would need to start net.wlp3s0 for this to occur (and have dhcpcd run). "

That means that I have to 

```
/etc/init.d/wpa_supplicant start
```

 but then, what do you mean by saying /etc/conf.d/net is not applied. 

The second part of your comment means that I have to have net.wlp3s0 and dhcpcd at the default runlevel?

The description of bifi actually applies very well to the problem I am having.

Thanks a lot for your help.

----------

## khayyam

 *Semantika wrote:*   

> [...] but then, what do you mean by saying /etc/conf.d/net is not applied. The second part of your comment means that I have to have net.wlp3s0 and dhcpcd at the default runlevel?

 

Semantika ... if /etc/init.d/wpa_supplicant is started "netifrc" isn't in use (and so the configuration in /etc/conf.d/net isn't applied). So, for "netifrc" (ie, net.wlp3s0, or whatever your interface is named) you would have something like the following (for wpa_supplicant and dhcpcd):

```
modules_wlp3s0="!plug wpa_supplicant dhcpcd"

wpa_supplicant_wlp3s0="-Dnl80211 -qq"

config_wlp3s0="dhcp"
```

You would then only need 'net.wlp3s0" in the runlevel, as wpa_supplicant, and dhcpcd, would be started as a result.

HTH & best ... khay

----------

## Goverp

I've just been battling the same issues with a new laptop.  (There was a hardware problem with the rtl8723de wifi that obscured the problem, eventually solved by setting the module parameter for antenna 2.)

I followed the wiki entry, and got it all to work by removing net.wlan0 from default or any other runlevel, and commenting out its config from /etc/conf.d/net, and adding both dhcpcd and wpa_supplicant to default runlevel.  As I write this, /etc/init.d/net.wlan0 status is "stopped".

FWIW, I set the GROUP to "users", as I don't care who sets the wifi - there's only me here.

I get the wpa_gui in the system tray (using KDE), and it selects networks and runs like it should.  I've also installed dhcpcd_ui, but not yet played with it.  I'm not sure if its needed, but I've yet to plug an ethernet cable in to see what happens!

----------

## Semantika

Hey, thanks a ton khayyam and Goverp, I have managed to make it work, I made the changes in /etc/config.d/net and then removed the net interface from the default runlevel, leaving dhcpcd and wpa_supplicant. Everything works just fine.

 :Very Happy:   :Very Happy:   :Very Happy: 

----------

## khayyam

 *Semantika wrote:*   

> Hey, thanks a ton khayyam and Goverp, I have managed to make it work, I made the changes in /etc/config.d/net and then removed the net interface from the default runlevel, leaving dhcpcd and wpa_supplicant. Everything works just fine.

 

Semantika ... you're welcome, but I think you've missed my meaning, the "changes" you've made to /etc/conf.d/net are only applied if using /etc/init.d/net.* ("netifrc"). So, having "removed the net interface" those changes play absolutely no role in it working.

best ... khay

----------

