My /etc/dhcpcd.conf file is configured so that if I manually run this wpa_supplicant command from the terminal:

wpa_supplicant -B -D nl80211 -P /var/run/wpaSupplicantPid.pid -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

it fetches my static IP address and settings and I get connectivity. However, this is not automatic, and the connected state does not survive a reboot and I need to run this command again to get connectivity. If it survived the reboot, I wouldn't mind running the command once, so I presume this could be solved by altering the startup script, but that is beyond my scope of knowledge. I've also seen all the related questions about calling wpa_supplicant from the dhcpcd somehow using "hooks" (in quotes because I'm new to the term), but I have not been able to figure out how to configure a hook script to run the proper wpa_supplicant command. On startup, a wpa_supplicant command does execute, but it does not result in connectivity and I don't know where to find/alter it. Running ps -aux | grep supplicant with connectivity yields:

root      2364  0.0  0.0  44892  3100 ?        Ss   10:46   0:00 wpa_supplicant -B -D nl80211 -P /var/run/wpaSupplicantPid.pid -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf 
root      2843  0.0  0.0  21536  1056 pts/0    S+   11:17   0:00 grep --color=auto supplicant

and after reboot ps -aux | grep supplicant yields the following and there is no connectivity:

root       834  0.0  0.0  44752  2792 ?        Ss   11:19   0:00 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
root      1972  0.0  0.0  21536  1032 pts/0    S+   11:20   0:00 grep --color=auto supplicant

Here is my /etc/dhcpcd.conf file:

# Inform the DHCP server of our hostname for DDNS.

# Use the hardware address of the interface for the Client ID.
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.

# Persist interface configuration when dhcpcd exits.
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones    

slaac private

    denyinterfaces eth0

    interface wlan0
    static ip_address=
    static routers=
    static domain_name_servers=
    env wpa_supplicant_conf=/etc/wpa_supplicant/wpa_supplicant.conf

My /etc/wpa_supplicant/wpa_supplicant.conf file contains:

  • How did you construct that configuration? I see elements that are irrelevant for a Pi (such as interface name 'enp1s0'). Which OS do you use? Can you get a working connection if you Raspbian Desktop and use the GUI applet to configure the connection? – Dirk Aug 1 '18 at 15:55
  • Sorry, enp1s0 was a mistake, I corrected it to eth0. I'm using Raspbian. All the settings will be executed through a java program, so I don't want to use the GUI for anything. The configuration is just what I came up with from help on the web. My apologies if it is incompetent, but that is why I'm here. – Shmod Aug 1 '18 at 16:14
  • That was not the only problem: 'profile' is irrelevant, you cannot execute commands from dhcpcd,conf (last two lines). Normally you don't need to issue any commands manually (or from any program). Why do you think you need to run any command from an external program? – Dirk Aug 1 '18 at 16:19
  • Because unless I run it manually, wpa_supplicant doesn't connect me to the internet I assumed I needed to add some functionality for dhcpcd to handle it. If not in dhcpcd.conf, where would I go about fixing the wpa_supplicant problem? – Shmod Aug 1 '18 at 18:11

See https://raspberrypi.stackexchange.com/a/37921/42636 for info on configuring networking. In your case I would set /etc/wpa_supplicant/wpa_supplicant.conf to:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


Undo all changes to /etc/dhcpcd.conf to get an DHCP address. For static address add the following to an unchanged /etc/dhcpcd.conf:

interface wlan0
static ip_address=
static routers=
static domain_name_servers=
  • could you give me an example of an "an unchanged /etc/dhcpcd.conf"? I made all those changes and still no luck, but I'm not quite sure what the rest of /etc/dhcpcd.conf should look like when using a static ip. Your help is much appreciated – Shmod Aug 1 '18 at 18:32
  • I made my wpa_supplicant.conf and dhcpcd.conf files identical to the example you gave me. Is there another step to trigger wpa_supplicant? Running "service dhcpcd restart" does not trigger wpa_supplicant and rebooting does, but seems to run "/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant" which apparently doesn't result in connectivity like "wpa_supplicant -B -D nl80211 -P /var/run/wpaSupplicantPid.pid -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf" does – Shmod Aug 1 '18 at 19:01
  • 'slaac private' is the last line in the default dhcpcd.conf. Have you rebooted your Pi after making the modifications? Have you checked with ifconfig if wlan0 gets an IP address? BTW: I would try to get a connection with DHCP first. Don't make all the mods in one go, it makes it much harder to debug – Dirk Aug 1 '18 at 19:10
  • Great advice, but still no luck. I just rebooted using both DHCP and static IP and both yield the same result: wpa_supplicant is not running properly, and I get no connectivity. In both cases, ifconfig shows wlan0 without an IP until I manually run "wpa_supplicant -B -D nl80211 -P /var/run/wpaSupplicantPid.pid -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf" – Shmod Aug 1 '18 at 19:33
  • This may help narrow it down though: the issue is only with wireless. My static or dynamic ethernet connection is not lost on reboot. This means that it is definitely an issue with wpa_supplicant – Shmod Aug 1 '18 at 19:47

I do not really understand all the trouble. Please flash an image from Raspbian Stretch 2018-06-27. Then you have the possibilities to setup wireless using the Desktop or the command line or doing a headless setup. How to do that you can look at the official documentation for Wireless connectivity.

Btw.: the line in your /etc/wpa_supplicant/wpa_supplicant.conf is wrong. It looks:


But it must look like this, including DIR=

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
  • Thanks, but a couple issues: first, I can use only the command line. I read the documentation you shared for connecting with the command line, but it doesn't give me any new information. I fixed /etc/wpa_supplicant/wpa_supplicant.conf but nothing changed. Still no connectivity on reboot, but manually I get connectivity no problem. – Shmod Aug 1 '18 at 18:37
  • @Shmod I suppose you have a virgin flashed Raspbian and used raspi-config to setup your wifi. Please edit your question and give us the output from ip addr, systemctl status wpa_supplicant.service, sudo iw dev wlan0 scan ssid SSID and .journalctl --unit dhcpcd | grep wlan0:. – Ingo Aug 1 '18 at 20:59
  • You're missing the country code in wpa_supplicant. wlan0 will not be activated if the code is missing. BTW: wpa_supplicant.service being disabled is normal. – Dirk Aug 2 '18 at 18:35
  • So reverting to a virgin install did the trick. Thank you very much Ingo – Shmod Aug 2 '18 at 18:53
  • @Shmod Glad to help you :-). You can honor it by up voting. – Ingo Aug 2 '18 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.