I have a Raspberry Pi with 2 WiFi interfaces (built-in and USB dongle). I want to set up one of them (wlan0) to connect to a WiFi router for Internet access and the other one (wlan1) as an Access Point for clients to connect to.
I have the following, which worked perfectly fine in Raspbian Jessie:
/etc/network/interfaces
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
# eth0 is upstream (Internet - currently unused)
iface eth0 inet manual
# wlan0 is upstream (Internet)
allow-hotplug wlan0
iface wlan0 inet manual
# eth1 and wlan1 are for clients
allow-hotplug eth1
iface eth1 inet manual
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
/etc/wpa_supplicant/wpa_supplicant.conf
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="UPSTREAM_SSID"
psk="UPSTREAM_PASSWORD"
proto=WPA
key_mgmt=WPA-PSK
}
/etc/hostpad/hostapd.conf
logger_syslog=-1
logger_syslog_level=2
interface=wlan1
driver=nl80211
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
ssid=MY_AP_SSID
wpa_passphrase=MY_AP_PASSWORD
This all worked in Jessie. In Raspbian Stretch, however, I cannot see my AP SSID broadcast. iwconfig shows UPSTREAM_SSID as the ESSID for both wlan0 and wlan1.
syslog has this (not sure if relevant):
syslog:Jun 2 16:07:00 atom hostapd[665]: Configuration file: /etc/hostapd/hostapd.conf
syslog:Jun 2 16:07:00 atom hostapd[665]: wlan1: Could not connect to kernel driver
syslog:Jun 2 16:07:00 atom hostapd[665]: Using interface wlan1 with hwaddr WLAN1_MAC and ssid "MY_AP_SSID"
syslog:Jun 2 16:07:00 atom hostapd[665]: wlan1: interface state UNINITIALIZED->ENABLED
syslog:Jun 2 16:07:00 atom hostapd[665]: wlan1: AP-ENABLED
syslog:Jun 2 16:07:00 atom hostapd: wlan1: STA UPSTREAM_ROUTER_MAC IEEE 802.11: disassociated
syslog:Jun 2 16:07:00 atom hostapd: wlan1: STA UPSTREAM_ROUTER_MAC IEEE 802.11: disassociated
syslog:Jun 2 16:07:00 atom hostapd: wlan1: STA UPSTREAM_ROUTER_MAC IEEE 802.11: disassociated
syslog:Jun 2 16:07:00 atom hostapd: wlan1: STA UPSTREAM_ROUTER_MAC IEEE 802.11: disassociated
So it doesn't seem like it's even trying to set up an AP but just connects to the upstream WiFi router using both WiFi cards!
Edit: Forgot to say that I had to add a /etc/dhcpcd.conf file in Stretch - under Jessie these settings were in /etc/network/interfaces
# ... all the stuff from the default file ...
interface eth1
static ip_address=192.168.5.1/24
interface wlan1
static ip_address=192.168.4.1/24
Edit 2: With Epehmeral's help I ended up getting it working by removing the interface wlan1 lines from /etc/dhcpcd.conf and instead adding this to /etc/network/interface:
iface wlan1 inet manual
post-up ip a add 192.168.4.1/24 dev wlan1
post-down ip a del 192.168.4.1/24 dev wlan1

interface=wlan1must beinterface=wlan0? And removeiface wlan0 inet manualis a good option (because you are the AP and probably you want manipulate the dhcp/dns server) if wlan0 must be the AP. – Ephemeral Jun 02 '19 at 18:33MANAGED modeof an interface in the same time andMASTER mode(this require another configuration). An Access Point useMASTER modeonly. Here probably you have a bad tool using this interface or a bad configuration in a file, causing your problem ...try to replace:
interface wlan1 static ip_address=192.168.4.1/24tointerface wlan0 static ip_address=192.168.4.1/24for your case, you want wlan0 as cllient dhcp/dns... And I do not understand how you assign the IP addresses of your AP clients because I do not see any DHCP / DNS server configuration? – Ephemeral Jun 02 '19 at 20:27wlan1 (the AP) will need a static IP. I tried commenting out the wlan1 lines in dhcpcd.conf, but that hasn't made a difference.
Interestingly, when I do
service hostapd restartquickly followed byiwconfigit briefly showswlan1 IEEE 802.11 ESSID:off/any Mode:Managed Access Point: Not-Associatedbut then if I run
– EM0 Jun 02 '19 at 20:34iwconfigagain it sayswlan1 IEEE 802.11 ESSID:"UPSTREAM_SSID" Mode:Managedsudo systemctl stop networking? before trying to run the AP for testing if the AP want start on the interface ? (UP the interface is not require, hostapd will do that) because networking service can use this same interface and then put that in Managed mode when the dhcp client needs a lease or re-lease. (Remove all inet conf for the hostapd interface wlan1, in dhcpcd.conf , network/interfaces ...) I remember meeting a lot of problems with that ... – Ephemeral Jun 02 '19 at 20:52systemctl stop networkingand that disconnected me from the Internet (wlan0). Both wlans were still in managed mode but it tried to use wlan1 for the uplink and wlan0 was "unassociated".What I still don't understand is how wpa_supplicant decides which interface to use for its configuration. Some websites describe a wpa_supplicant configuration with multiple networks and http://blog.hoxnox.com/gentoo/wifi-hotspot.html describes how to configure an AP with it, without hostapd. That would be ideal for me in principle, but how do I tell it: use wlan0 for network X and wlan1 for Y.
– EM0 Jun 02 '19 at 20:52