I'm using OpenWRT 18.06.2 both stock from the download repo and built manually from source for the Raspberry PI 3 and Raspberry PI W to setup a WIFI extender that will route packets from one WIFI network (wan or the "internet") to the local WIFI network (lan). The end goal is to apply filtering between the two networks to limit kids access to the internet (like the Disney GO device). Yes, I could connect up a ethernet cable to a Raspberry PI 3 for better performance or use a "real" router device for better performance, but the intended goal is to create a USB stick from a Raspberry PI W. For our purposes, no bridging networks is required so I do not need to use routed or other such configurations. Eventually, iptables will prevent some packets from getting through, but I have to get that far.
I have managed to setup the two WIFI connections, but it does not seem to matter what I do, I cannot get both WIFI connections to work at the same time using the openwrt configuration files. I can enable the AP or I can enable the STA by changing the disabled item in the wireless config file, and individually they work fine. One at a time the interfaces come up and packets can be routed. If I change the config in wireless to enable both the AP and STA, the wlan0-1 interface goes up and down, and hostapd/wpa_supplicant never stay running.
As a test, I enabled the STA interface, made sure it connected, and found the hostapd.conf in /var/run. I use iw to manually create an ap0 interface (didn't seem to matter if I called it wlan0-1), set the device name that I created in my hostapd.conf that I grabbed, hostapd ran and worked. I was able to connect my phone to the AP on the Raspberry PI while the STA mode was working. If it matters, I was able to route traffic from my phone to the internet thru the raspberry PI.
Thus:
iw phy phy0 interface add ap0 type __ap
hostapd -dd /var/run/hostapd.conf
...after the STA interface is running.
(info above pulled from https://blog.thewalr.us/2017/09/26/raspberry-pi-zero-w-simultaneous-ap-and-managed-mode-wifi/)
Now, I'd like to figure out what I've configured incorrectly in OpenWRT to get the two interfaces coming up correctly when the system boots.
I've read over https://openwrt.org/docs/guide-user/network/wifi/relay_configuration and just about every other document on the OpenWRT wifi, searched stack overflow, etc, and I've had no success.
Google searching has turned up that perhaps order of bring up the interface and if the STA interface drops for some reason, everything will stop working. I'm not there yet.
It would appear from the logs netifd is getting confused or there are errors that cause the wlan0 interface to go up and down.
There is something simple, I am sure, in my configs I am missing. Any help would be appreciated.
My configs:
/etc/config/wireless:
config wifi-device 'radio0'
option type 'mac80211'
option channel '11'
option hwmode '11g'
option path 'platform/soc/3f300000.mmc/mmc_host/mmc1/mmc1:0001/mmc1:0001:1'
option htmode 'HT20'
option country 'CA'
option legacy_rates '1'
config wifi-iface
option device 'radio0'
option mode 'sta'
option ssid 'Hidden'
option network 'wan'
option encryption 'psk2'
option key 'password'
config wifi-iface
option device 'radio0'
option mode 'ap'
option ssid 'TestAP'
option network 'lan'
option encryption 'psk2'
option key 'password'
option disabled '1'
/etc/config/network:
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd0f:02b8:4aad::/48'
config interface 'lan'
option type 'bridge'
option ifname 'eth0'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
config interface 'wan'
option proto 'dhcp'
If I enable both AP and STA interfaces at the same time, I get a flood of messages:
[12290.912592] brcmfmac: brcmf_cfg80211_get_channel: chanspec failed (-52)
[12291.960102] IPv6: ADDRCONF(NETDEV_UP): wlan0-1: link is not ready
[12291.977093] br-lan: port 2(wlan0-1) entered blocking state
[12291.989479] br-lan: port 2(wlan0-1) entered disabled state
[12292.002075] device wlan0-1 entered promiscuous mode
[12292.127355] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[12293.070487] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[12293.370574] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0-1: link becomes ready
[12293.383855] br-lan: port 2(wlan0-1) entered blocking state
[12293.395867] br-lan: port 2(wlan0-1) entered forwarding state
[12294.095299] br-lan: port 2(wlan0-1) entered disabled state
[12294.782826] br-lan: port 2(wlan0-1) entered blocking state
[12294.794772] br-lan: port 2(wlan0-1) entered forwarding state
[12295.265545] br-lan: port 2(wlan0-1) entered disabled state
[12296.194818] br-lan: port 2(wlan0-1) entered blocking state
[12296.206517] br-lan: port 2(wlan0-1) entered forwarding state
[12296.675806] br-lan: port 2(wlan0-1) entered disabled state
[12297.594162] br-lan: port 2(wlan0-1) entered blocking state
[12297.605819] br-lan: port 2(wlan0-1) entered forwarding state
[12298.075694] br-lan: port 2(wlan0-1) entered disabled state
[12298.206375] br-lan: port 2(wlan0-1) entered blocking state
[12298.217729] br-lan: port 2(wlan0-1) entered forwarding state
/var/log/message has alot of errors:
Tue Apr 16 15:27:00 2019 daemon.notice netifd: Network device 'wlan0' link is down
Tue Apr 16 15:27:00 2019 daemon.notice netifd: Interface 'wan' has link connectivity loss
Tue Apr 16 15:27:00 2019 daemon.notice netifd: wan (27698): udhcpc: received SIGTERM
Tue Apr 16 15:27:01 2019 daemon.notice netifd: Network device 'wlan0' link is up
Tue Apr 16 15:27:01 2019 daemon.notice netifd: Interface 'wan' has link connectivity
Tue Apr 16 15:27:01 2019 daemon.notice netifd: Interface 'wan' is setting up now
Tue Apr 16 15:27:01 2019 daemon.notice netifd: wan (4970): udhcpc: started, v1.28.4
Tue Apr 16 15:27:02 2019 daemon.notice netifd: wan (4970): udhcpc: sending discover
Tue Apr 16 15:27:02 2019 daemon.notice netifd: wan (4970): udhcpc: sending select for 192.168.10.185
Tue Apr 16 15:27:02 2019 daemon.notice netifd: wan (4970): udhcpc: lease of 192.168.10.185 obtained, lease time 86400
Tue Apr 16 15:27:02 2019 daemon.warn dnsmasq[1375]: no servers found in /tmp/resolv.conf.auto, will retry
Tue Apr 16 15:27:02 2019 daemon.notice netifd: Interface 'wan' is now up
Tue Apr 16 15:27:02 2019 daemon.info dnsmasq[1375]: reading /tmp/resolv.conf.auto
Tue Apr 16 15:27:02 2019 daemon.info dnsmasq[1375]: using local addresses only for domain test
Tue Apr 16 15:27:02 2019 daemon.info dnsmasq[1375]: using local addresses only for domain onion
Tue Apr 16 15:27:02 2019 daemon.info dnsmasq[1375]: using local addresses only for domain localhost
Tue Apr 16 15:27:02 2019 daemon.info dnsmasq[1375]: using local addresses only for domain local
Tue Apr 16 15:27:02 2019 daemon.info dnsmasq[1375]: using local addresses only for domain invalid
Tue Apr 16 15:27:02 2019 daemon.info dnsmasq[1375]: using local addresses only for domain bind
Tue Apr 16 15:27:02 2019 daemon.info dnsmasq[1375]: using local addresses only for domain lan
Tue Apr 16 15:27:02 2019 daemon.info dnsmasq[1375]: using nameserver 192.168.10.1#53
Tue Apr 16 15:27:02 2019 user.notice firewall: Reloading firewall due to ifup of wan (wlan0)
Tue Apr 16 15:59:29 2019 daemon.notice netifd: Network device 'wlan0' link is down
Tue Apr 16 15:59:29 2019 daemon.notice netifd: Interface 'wan' has link connectivity loss
Tue Apr 16 15:59:29 2019 daemon.notice netifd: wan (4970): udhcpc: received SIGTERM
Tue Apr 16 15:59:29 2019 kern.err kernel: [12290.912592] brcmfmac: brcmf_cfg80211_get_channel: chanspec failed (-52)
Tue Apr 16 15:59:30 2019 daemon.notice netifd: radio0 (9395): command failed: No error information (-524)
Tue Apr 16 15:59:30 2019 user.notice mac80211: Failed command: iw dev wlan0 del
Tue Apr 16 15:59:30 2019 daemon.notice netifd: Interface 'wan' is disabled
Tue Apr 16 15:59:30 2019 daemon.notice netifd: radio0 (9433): command failed: No error information (-524)
Tue Apr 16 15:59:30 2019 user.notice mac80211: Failed command: iw dev wlan0 del
Tue Apr 16 15:59:30 2019 user.notice mac80211: Failed command: iw phy phy0 set antenna all all
Tue Apr 16 15:59:30 2019 daemon.notice netifd: radio0 (9433): command failed: Not supported (-95)
Tue Apr 16 15:59:30 2019 user.notice mac80211: Failed command: iw phy phy0 set antenna_gain 0
Tue Apr 16 15:59:30 2019 daemon.notice netifd: radio0 (9433): command failed: I/O error (-5)
Tue Apr 16 15:59:30 2019 user.notice mac80211: Failed command: iw phy phy0 set distance 0
Tue Apr 16 15:59:30 2019 daemon.notice netifd: radio0 (9433): command failed: Too many open files in system (-23)
Tue Apr 16 15:59:30 2019 user.notice mac80211: Failed command: iw phy phy0 interface add wlan0 type managed
Tue Apr 16 15:59:31 2019 daemon.err hostapd: Configuration file: /var/run/hostapd-phy0.conf
Tue Apr 16 15:59:31 2019 kern.info kernel: [12291.960102] IPv6: ADDRCONF(NETDEV_UP): wlan0-1: link is not ready
Tue Apr 16 15:59:31 2019 kern.info kernel: [12291.977093] br-lan: port 2(wlan0-1) entered blocking state
Tue Apr 16 15:59:31 2019 kern.info kernel: [12291.989479] br-lan: port 2(wlan0-1) entered disabled state
Tue Apr 16 15:59:31 2019 kern.info kernel: [12292.002075] device wlan0-1 entered promiscuous mode
Tue Apr 16 15:59:31 2019 daemon.notice hostapd: wlan0-1: interface state UNINITIALIZED->COUNTRY_UPDATE
Tue Apr 16 15:59:31 2019 daemon.warn hostapd: wlan0-1: Could not connect to kernel driver
Tue Apr 16 15:59:31 2019 daemon.err hostapd: Using interface wlan0-1 with hwaddr ba:27:eb:93:54:4c and ssid "OpenWrt"
Tue Apr 16 15:59:31 2019 daemon.notice hostapd: wlan0-1: interface state COUNTRY_UPDATE->ENABLED
Tue Apr 16 15:59:31 2019 daemon.notice hostapd: wlan0-1: AP-ENABLED
Tue Apr 16 15:59:31 2019 kern.info kernel: [12292.127355] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Tue Apr 16 15:59:31 2019 daemon.notice netifd: radio0 (9433): Successfully initialized wpa_supplicant
Tue Apr 16 15:59:31 2019 daemon.notice netifd: Interface 'wan' is enabled
Tue Apr 16 15:59:32 2019 daemon.notice netifd: Network device 'wlan0' link is up
Tue Apr 16 15:59:32 2019 daemon.notice netifd: Interface 'wan' has link connectivity
Tue Apr 16 15:59:32 2019 daemon.notice netifd: Interface 'wan' is setting up now
Tue Apr 16 15:59:32 2019 kern.info kernel: [12293.070487] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Tue Apr 16 15:59:32 2019 daemon.warn hostapd: wlan0-1: Could not connect to kernel driver
Tue Apr 16 15:59:32 2019 daemon.notice netifd: wan (9629): udhcpc: started, v1.28.4
Tue Apr 16 15:59:32 2019 daemon.notice netifd: wan (9629): udhcpc: sending discover
Tue Apr 16 15:59:32 2019 daemon.notice netifd: wan (9629): udhcpc: sending select for 192.168.10.185
Tue Apr 16 15:59:32 2019 kern.info kernel: [12293.370574] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0-1: link becomes ready
Tue Apr 16 15:59:32 2019 kern.info kernel: [12293.383855] br-lan: port 2(wlan0-1) entered blocking state
Tue Apr 16 15:59:32 2019 kern.info kernel: [12293.395867] br-lan: port 2(wlan0-1) entered forwarding state
Tue Apr 16 15:59:32 2019 daemon.notice netifd: Network device 'wlan0-1' link is up
Tue Apr 16 15:59:32 2019 daemon.notice netifd: Network device 'wlan0' link is down
Tue Apr 16 15:59:32 2019 daemon.notice netifd: Interface 'wan' has link connectivity loss
Tue Apr 16 15:59:32 2019 daemon.notice netifd: wan (9629): udhcpc: received SIGTERM
Tue Apr 16 15:59:33 2019 daemon.notice netifd: Network device 'wlan0-1' link is down
Tue Apr 16 15:59:33 2019 kern.info kernel: [12294.095299] br-lan: port 2(wlan0-1) entered disabled state
Tue Apr 16 15:59:33 2019 daemon.notice netifd: Network device 'wlan0' link is up
Tue Apr 16 15:59:33 2019 daemon.notice netifd: Interface 'wan' has link connectivity
Tue Apr 16 15:59:33 2019 daemon.notice netifd: Interface 'wan' is setting up now
Tue Apr 16 15:59:33 2019 daemon.warn hostapd: wlan0-1: Could not connect to kernel driver
Tue Apr 16 15:59:33 2019 daemon.notice netifd: wan (9669): udhcpc: started, v1.28.4
Tue Apr 16 15:59:33 2019 daemon.notice netifd: wan (9669): udhcpc: sending discover
Tue Apr 16 15:59:33 2019 kern.info kernel: [12294.782826] br-lan: port 2(wlan0-1) entered blocking state
Tue Apr 16 15:59:33 2019 kern.info kernel: [12294.794772] br-lan: port 2(wlan0-1) entered forwarding state
Tue Apr 16 15:59:33 2019 daemon.notice netifd: Network device 'wlan0-1' link is up
Tue Apr 16 15:59:33 2019 daemon.notice netifd: Network device 'wlan0' link is down
Tue Apr 16 15:59:33 2019 daemon.notice netifd: Interface 'wan' has link connectivity loss
Tue Apr 16 15:59:33 2019 daemon.notice netifd: wan (9669): udhcpc: received SIGTERM
Tue Apr 16 15:59:34 2019 daemon.notice netifd: Network device 'wlan0-1' link is down
Tue Apr 16 15:59:34 2019 kern.info kernel: [12295.265545] br-lan: port 2(wlan0-1) entered disabled state
Tue Apr 16 15:59:34 2019 daemon.notice netifd: Network device 'wlan0' link is up
Tue Apr 16 15:59:34 2019 daemon.notice netifd: Interface 'wan' has link connectivity
Tue Apr 16 15:59:34 2019 daemon.notice netifd: Interface 'wan' is setting up now
Tue Apr 16 15:59:34 2019 daemon.warn hostapd: wlan0-1: Could not connect to kernel driver
Tue Apr 16 15:59:35 2019 daemon.notice netifd: wan (9728): udhcpc: started, v1.28.4
Tue Apr 16 15:59:35 2019 daemon.notice netifd: wan (9728): udhcpc: sending discover
Tue Apr 16 15:59:35 2019 kern.info kernel: [12296.194818] br-lan: port 2(wlan0-1) entered blocking state
Tue Apr 16 15:59:35 2019 kern.info kernel: [12296.206517] br-lan: port 2(wlan0-1) entered forwarding state
Tue Apr 16 15:59:35 2019 daemon.notice netifd: Network device 'wlan0-1' link is up
Tue Apr 16 15:59:35 2019 daemon.notice netifd: Network device 'wlan0' link is down
Tue Apr 16 15:59:35 2019 daemon.notice netifd: Interface 'wan' has link connectivity loss
Tue Apr 16 15:59:35 2019 daemon.notice netifd: wan (9728): udhcpc: received SIGTERM
Tue Apr 16 15:59:35 2019 daemon.notice netifd: Network device 'wlan0-1' link is down
Tue Apr 16 15:59:35 2019 kern.info kernel: [12296.675806] br-lan: port 2(wlan0-1) entered disabled state
Tue Apr 16 15:59:36 2019 daemon.notice netifd: Network device 'wlan0' link is up
Tue Apr 16 15:59:36 2019 daemon.notice netifd: Interface 'wan' has link connectivity
Tue Apr 16 15:59:36 2019 daemon.notice netifd: Interface 'wan' is setting up now
Tue Apr 16 15:59:36 2019 daemon.notice netifd: wan (9766): udhcpc: started, v1.28.4
Tue Apr 16 15:59:36 2019 daemon.warn hostapd: wlan0-1: Could not connect to kernel driver
Tue Apr 16 15:59:36 2019 daemon.notice netifd: wan (9766): udhcpc: sending discover
Tue Apr 16 15:59:36 2019 daemon.notice netifd: wan (9766): udhcpc: sending select for 192.168.10.185
Tue Apr 16 15:59:36 2019 daemon.notice netifd: Network device 'wlan0' link is down
Tue Apr 16 15:59:36 2019 daemon.notice netifd: Interface 'wan' has link connectivity loss
Tue Apr 16 15:59:36 2019 kern.info kernel: [12297.594162] br-lan: port 2(wlan0-1) entered blocking state
Tue Apr 16 15:59:36 2019 kern.info kernel: [12297.605819] br-lan: port 2(wlan0-1) entered forwarding state
Tue Apr 16 15:59:36 2019 daemon.notice netifd: Network device 'wlan0-1' link is up
Tue Apr 16 15:59:36 2019 daemon.notice netifd: wan (9766): udhcpc: received SIGTERM
Tue Apr 16 15:59:37 2019 daemon.notice netifd: Network device 'wlan0-1' link is down
Tue Apr 16 15:59:37 2019 kern.info kernel: [12298.075694] br-lan: port 2(wlan0-1) entered disabled state
Tue Apr 16 15:59:37 2019 kern.info kernel: [12298.206375] br-lan: port 2(wlan0-1) entered blocking state
Tue Apr 16 15:59:37 2019 kern.info kernel: [12298.217729] br-lan: port 2(wlan0-1) entered forwarding state
Tue Apr 16 15:59:37 2019 daemon.notice netifd: Network device 'wlan0-1' link is up
Tue Apr 16 15:59:40 2019 daemon.notice hostapd: wlan0-1: interface state ENABLED->DISABLED
Tue Apr 16 15:59:40 2019 daemon.notice hostapd: wlan0-1: AP-DISABLED
Tue Apr 16 15:59:40 2019 daemon.notice hostapd: wlan0-1: CTRL-EVENT-TERMINATING
Tue Apr 16 15:59:40 2019 daemon.notice hostapd: nl80211: deinit ifname=wlan0-1 disabled_11b_rates=0
Tue Apr 16 15:59:40 2019 kern.info kernel: [12301.874917] device wlan0-1 left promiscuous mode
Tue Apr 16 15:59:40 2019 kern.info kernel: [12301.885669] br-lan: port 2(wlan0-1) entered disabled state
Tue Apr 16 15:59:41 2019 daemon.notice netifd: Network device 'wlan0-1' link is down
Tue Apr 16 15:59:51 2019 daemon.notice netifd: radio0 (9840): command failed: No error information (-524)
Tue Apr 16 15:59:51 2019 user.notice mac80211: Failed command: iw dev wlan0 del
Tue Apr 16 15:59:51 2019 kern.err kernel: [12312.458224] brcmfmac: brcmf_cfg80211_get_channel: chanspec failed (-52)
Tue Apr 16 15:59:51 2019 daemon.notice netifd: Interface 'wan' is disabled