$ uname -a Linux pi 4.9.59+ #1047 Sun Oct 29 11:47:10 GMT 2017 armv6l GNU/Linux

System fully updated via apt.

I'm aware there are many, many questions and blogs on this topic, but after several days of looking and asking friends I can't find an answer.

My Raspberry Pi Zero W has two wireless interfaces: wlan0 and wlan1.

I want wlan0 to be an AP and wlan1 to connect to an AP.

So I need wlan0 to have a static IP and wlan1 to get one from DHCP over wireless.

If I set a static IP for wlan0 in dhcpcd.conf, dhcpcd still calls wpa_supplicant and so even with a static IP it joins the AP - which causes conflicts when trying to run hostapd.

If I set a static IP for wlan0 via interfaces, dhcpcd fails because it detected the interface being configured in interfaces - eventhough I'd added denyinterface wlan0 to the dhcpcd.conf.

I know that wpa_supplicant has a command-line parameter for interface, but I haven't been able to find a way of limiting which interfaces get passed from the dhcpcd hook.

The question is: what configuration should I use in dhcpcd.conf (or elsewhere?) so I can get a static IP address on wlan0 and not have it connect to an AP AND get an IP address via DHCP on wlan1 and have it connect to an AP? phew


I've tried using systemctl start dhcpcd@wlan0.service to have a per-interface config, but there is no dhcpcd@.service file, only dhcpcd.service.


I've added a system unit file (if that's the right word?) for dhcpcd@.service:

Description=dhcpcd on %I

ExecStart=/sbin/dhcpcd --config /etc/dhcpcd-%I.conf -A -q -w %I
ExecStop=/sbin/dhcpcd -k %I


(Modified from: https://github.com/devkral/systemd-arch-units/blob/master/service/dhcpcd@.service)

This means I can successfully apply an interface-specific config into which I put a static IP address configuration and nohook wpa_supplicant.

This correctly doesn't call wpa_supplicant, but doesn't seem to set the IP address either. No errors on run and I can see it's loading the correct conf file, but ip addr shows no IP address on the interface.


I solved this by using the interface-specific unit (/lib/systemd/system/dhcpcd@.service), with an interface-specific dhcpcd.conf.

For wlan0, static IP address and no wpa_supplicant:


interface wlan0
static ip_address==

denyinterfaces wlan0    # don't send DHCP requests
nohook wpa_supplicant   # don't call the wpa_supplicant hook

For wlan1, no changes to the default /etc/dhcpcd.conf, but had to create an interface-specific version:

cp /etc/dhcpcd.conf /etc/dhcpcd-wlan1.conf

Then, start dhcpcd for each interface:

systemctl start dhcpcd@wlan0
systemctl start dhcpcd@wlan1


Although this is an answer, @Nasha above was correct: you can specify a different wpa_supplicant.conf file per interface. Leaving this (wrong) answer here as it may prove useful.

| improve this answer | |
  • 1
    I think this is a better way to do it for the host AP / client AP case, as for this case we want to disable wpa_supplicant completely for the host AP. Thanks for leaving the answer up! :) – Donald Harvey Mar 15 '18 at 12:42

You don't need a unit for that. Use /etc/dhcpcd.conf. From the man pages:

denyinterfaces pattern

When discovering interfaces, the interface name must not match pattern which is a space or comma separated list of patterns passed to fnmatch(3).

So just add denyinterfaces wlan1 to dhcpcd.conf and dhcpcd will ignore that interface when sending DHCP requests.

| improve this answer | |
  • Thanks for the comment. In this case, can I still configure the static IP address in dhcpcd.conf or would I need to do it somewhere else, like interfaces? – Bridgey Nov 1 '17 at 18:03
  • Although this prevents DHCP requests being sent for the denied interface, it is still included in the interfaces when hooks are executed. Therefore, wpa_supplicant is still called for the denied interface. I'm trying to avoid wpa_supplicant being called for the denied interface. – Bridgey Nov 1 '17 at 18:17
  • You don't have to prevent wpa_supplicant from being called for the denied interface as the former is also responsible for putting the wireless adapter in access point mode instead of just client mode. Just find a way to provide it with 2 different configs... although I'm almost certain it's possible to configure multiple adapters in different modes from the same one and only wpa_supplicant.conf. Someone can confirm? – user29510 Nov 2 '17 at 10:25
  • you're right about the wpa_supplicant.conf per interface! 10-wpa_supplicant hook shows the list of files, in order, that are checked. wpa_supplicant-"$interface".conf is at the top of the list. If you update the answer I can mark it as the correct one? – Bridgey Nov 8 '17 at 21:26
  • @Bridgey I don't have my Pi accessible for the moment (all my available machines are Gentoo), I'll check that as soon as I can. – user29510 Nov 15 '17 at 13:27

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.