UPDATE Feb. 25, 2019: Note - An effective and fairly simple solution for the issue described in this initial post is right here.
So I have successfully configured my Raspberry Pi 2 b+ installed with Stretch to be a wifi to wifi extender (with 2 usb wifi dongles) using more or less the following helpful guide:TL;DR: After setting up a wifi to wifi extender system on my pi hostapd and dnsmasq do not come up properly as services at boot time but can be restarted at the end of the boot sequence with a restart command. It appears that hostapd fails because the wifi interfaces have not had time to come up before it launches. Despite the failed service launches, using crontabs one can successfully restart these services sequentially with a delay relative to reboot. Is there a less hacky way to correct this issue?
https://pimylifeup.com/raspberry-pi-wifi-extender/
This allows one usb wifi dongle to join an existing network and then share that connection via the second wifi dongle configured as an access point (AP) with DHCP NAT routing.
The strange thing though is that hostapd fails to start as a service upon reboot and subsequently dnsmasq also fails (these failures can be verified with the sudo systemctl status hostapd command and sudo systemctl status dnsmasq command). Why this is strange is because I can first sudo service hostapd restart as a service at a post reboot bash prompt and then sudo service dnsmasq restart and then there is no further problem, everything comes up and works smoothly as intended.
Based upon some log readings I have the impression that at boot up time hostapd tries to start as a service before the wlan interfaces are up and operational and thus immediately it fails.
I found a hacky solution idea that taps into cron to restart these services with two time delays after boot:
Code: Select all
sudo crontab -e
Code: Select all
@reboot sleep 25; /home/pi/fixhostapdlaunch/delayed-restart-hostapd.sh
@reboot sleep 40; /home/pi/fixhostapdlaunch/delayed-restart-dnsmasq.sh
delayed-restart-hostapd.sh located in a home directory I created /home/pi/fixhostapdlaunch/
set with sudo chmod a+rx delayed-restart-hostapd.sh
Code: Select all
#!/bin/bash
sudo service hostapd restart
delayed-restart-dnsmasq.sh located in the same directory and also set with sudo chmod a+rx delayed-restart-dnsmasq.sh
Code: Select all
#!/bin/bash
sudo service dnsmasq restart
What I am wondering is if the reason this might be an issue is because Stretch does not rely upon the /etc/network/interfaces functionality any longer?
While my hacky solution works fine it does not feel "right". Perhaps someone knows a standard way in Stretch to have the start of hostapd as a service be delayed until the wifi interfaces are well established? Or perhaps know that what I am thinking is actually not the issue but is something else?
Thank you in advance,
-Scott