Report comment

First, I just want to say that I really appreciate your help. I love the utility of your work and I believe with what you’ve done and others’ contributions it’s going to evolve wonderfully. Thank you.

Onward, here’s detail of the configuration and the behavior. I’m suspicious of my network/interfaces config and hope to get your approval or correction. Two scenarios are presented; the second scenario is detailed in four phases. The network itself is probably inconsequential to troubleshooting but, in case it is: Home router is at 10.0.0.1 with DHCP range 10.0.0.100 to 10.0.0.150; Pi3 gets DHCP reservation 10.0.0.2 in home router based on Pi3 wlan0 mac address; Pi3 (testbox) is at 10.0.0.2 per autohotspot script with DHCP range 10.0.0.200 to 10.0.0.250 per dnsmasq.conf. The overall problem is that the hotspot is failing.


SCENARIO 1:

INITIAL CONDITION: HOME ROUTER AVAILABLE UPON BOOT (NOT EXPECTING THE HOTSPOT)

- hotspot is off (ok)
- wlan0 IP is correct, 10.0.0.2, as specified in autohotspot (ok)
- able to ping the home router at 10.0.0.1 (ok)
- able to ping google.com:80 (ok)
- able to establish ssh connection from other local network clients (ok)

cron log:
sed: -e expression #1, char 1: unknown command: `?'
Hostspot already active

systemctl status hostapd:
hostapd.service - LSB: Advanced IEEE 802.11 management daemon
Loaded: loaded (/etc/init.d/hostapd; generated; vendor preset: disabled)
Active: active (running) since Thu 2017-06-01 21:49:34 PDT; 1min 0s ago
Docs: man:systemd-sysv-generator(8)
Process: 517 ExecStart=/etc/init.d/hostapd start (code=exited, status=0/SUCCESS)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/hostapd.service
└─526 /usr/sbin/hostapd -B -P /run/hostapd.pid /etc/hostapd/hostapd.conf

qas 01 21:49:33 testbox systemd[1]: Starting LSB: Advanced IEEE 802.11 management daemon...
qas 01 21:49:34 testbox hostapd[517]: Starting advanced IEEE 802.11 management: hostapd.
qas 01 21:49:34 testbox systemd[1]: Started LSB: Advanced IEEE 802.11 management daemon.

systemctl status dnsmasq:
dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2017-06-01 21:49:33 PDT; 1min 46s ago
Process: 494 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=1/FAILURE)
Process: 480 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)

qas 01 21:49:33 testbox systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
qas 01 21:49:33 testbox dnsmasq[480]: dnsmasq: syntax check OK.
qas 01 21:49:33 testbox dnsmasq[494]: dnsmasq: junk found in command line
qas 01 21:49:33 testbox dnsmasq[494]: junk found in command line
qas 01 21:49:33 testbox systemd[1]: dnsmasq.service: Control process exited, code=exited status=1
qas 01 21:49:33 testbox systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
qas 01 21:49:33 testbox systemd[1]: dnsmasq.service: Unit entered failed state.
qas 01 21:49:33 testbox systemd[1]: dnsmasq.service: Failed with result 'exit-code'.


SCENARIO 2:

INITIAL CONDITION: NO HOME ROUTER AVAILABLE UPON BOOT (EXPECTING THE HOTSPOT)

- hotspot is on, broadcasting ssid and connectable, but not issuing IP (problem)
- wlan0 IP is correct, 10.0.0.2, as specified in autohotspot (ok)
- all pings unreachable (except while pinging 10.0.0.2) (problem)

cron log:
sed: -e expression #1, char 1: unknown command: `?'
/usr/bin/autohotspot: line 74: wpa_cli: command not found
RTNETLINK answers: File exists
Job for dnsmasq.service failed because the control process exited with error code.
See "systemctl status dnsmasq.service" and "journalctl -xe" for details.

cron log several minutes after boot:
sed: -e expression #1, char 1: unknown command: `?'
Hostspot already active

systemctl status hostapd:
hostapd.service - LSB: Advanced IEEE 802.11 management daemon
Loaded: loaded (/etc/init.d/hostapd; generated; vendor preset: disabled)
Active: active (running) since Thu 2017-06-01 21:58:57 PDT; 54s ago
Docs: man:systemd-sysv-generator(8)
Process: 528 ExecStart=/etc/init.d/hostapd start (code=exited, status=0/SUCCESS)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/hostapd.service
└─539 /usr/sbin/hostapd -B -P /run/hostapd.pid /etc/hostapd/hostapd.conf

qas 01 21:58:56 testbox systemd[1]: Starting LSB: Advanced IEEE 802.11 management daemon...
qas 01 21:58:57 testbox hostapd[528]: Starting advanced IEEE 802.11 management: hostapd.
qas 01 21:58:57 testbox systemd[1]: Started LSB: Advanced IEEE 802.11 management daemon.

systemctl status dnsmasq:
dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2017-06-01 21:58:56 PDT; 1min 45s ago
Process: 501 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=1/FAILURE)
Process: 494 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)

qas 01 21:58:56 testbox systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
qas 01 21:58:56 testbox dnsmasq[494]: dnsmasq: syntax check OK.
qas 01 21:58:56 testbox dnsmasq[501]: dnsmasq: junk found in command line
qas 01 21:58:56 testbox systemd[1]: dnsmasq.service: Control process exited, code=exited status=1
qas 01 21:58:56 testbox systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
qas 01 21:58:56 testbox systemd[1]: dnsmasq.service: Unit entered failed state.
qas 01 21:58:56 testbox systemd[1]: dnsmasq.service: Failed with result 'exit-code'.


PHASE TWO: HOME ROUTER POWERED-UP WHILE PI REMAINS BOOTED AND HOTSPOT ON (EXPECTING THE HOTSPOT OFF AND SWITCH TO HOME ROUTER AFTER >2 MINS PER CRON)

- all behavior is same as cold-boot while home router is available (ok)

PHASE THREE: HOME ROUTER IS POWERED-DOWN WHILE PI REMAINS BOOTED AND HOTSPOT OFF (EXPECTING THE HOTSPOT ON AND SWITCH TO HOTSPOT AFTER >2 MINS PER CRON)

- hotspot is off and not broadcasting ssid (problem)

systemctl status hostapd:
hostapd.service - LSB: Advanced IEEE 802.11 management daemon
Loaded: loaded (/etc/init.d/hostapd; generated; vendor preset: disabled)
Active: active (running) since Thu 2017-06-01 21:58:57 PDT; 25min ago
Docs: man:systemd-sysv-generator(8)
Process: 528 ExecStart=/etc/init.d/hostapd start (code=exited, status=0/SUCCESS)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/hostapd.service
└─539 /usr/sbin/hostapd -B -P /run/hostapd.pid /etc/hostapd/hostapd.conf

qas 01 21:58:56 testbox systemd[1]: Starting LSB: Advanced IEEE 802.11 management daemon...
qas 01 21:58:57 testbox hostapd[528]: Starting advanced IEEE 802.11 management: hostapd.
qas 01 21:58:57 testbox systemd[1]: Started LSB: Advanced IEEE 802.11 management daemon.
qas 01 22:00:08 testbox hostapd[539]: wlan0: STA (::mac::) IEEE 802.11: associated
qas 01 22:00:08 testbox hostapd[539]: wlan0: STA (::mac::) RADIUS: starting accounting session 5930F090-
qas 01 22:00:08 testbox hostapd[539]: wlan0: STA (::mac::) WPA: pairwise key handshake completed (RSN)
qas 01 22:08:14 testbox hostapd[539]: wlan0: STA (::mac::) IEEE 802.11: disassociated
qas 01 22:08:14 testbox hostapd[539]: wlan0: STA 00:00:00:00:00:00 IEEE 802.11: disassociated

systemctl status dnsmasq:
dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2017-06-01 21:58:56 PDT; 27min ago
Process: 501 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=1/FAILURE)
Process: 494 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)

qas 01 21:58:56 testbox systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
qas 01 21:58:56 testbox dnsmasq[494]: dnsmasq: syntax check OK.
qas 01 21:58:56 testbox dnsmasq[501]: dnsmasq: junk found in command line
qas 01 21:58:56 testbox systemd[1]: dnsmasq.service: Control process exited, code=exited status=1
qas 01 21:58:56 testbox systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
qas 01 21:58:56 testbox systemd[1]: dnsmasq.service: Unit entered failed state.
qas 01 21:58:56 testbox systemd[1]: dnsmasq.service: Failed with result 'exit-code'.


PHASE FOUR: HOME ROUTER IS POWERED-UP WHILE PI REMAINS BOOTED AND HOTSPOT FAILED TO START (EXPECTING THE HOTSPOT TO REMAIN OFF AND SWITCH TO HOME ROUTER AFTER >2 MINS PER CRON)

- all behavior is same as cold-boot while home router is available (ok)


ALL CONFIGURATION FILES EXCEPT THE AUTOHOTSPOT SCRIPT. ONLY CHANGE TO AUTHOTSPOT SCRIPT IS THE IP AS p a add 10.0.0.2/24 dev wlan0. USING WPASSID=, LEFT SSID= COMMENTED


/etc/network/interfaces:
# auto lo
# iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto lo wlan0
iface lo inet loopback

allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf


/etc/hostapd/hostapd.conf:
interface=wlan0
driver=nl80211
ssid=(masked)
hw_mode=g
channel=6
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=(masked)
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP


added to end of /etc/dnsmasq.conf:
#Pi3Hotspot Config
#stop DNSmasq from using resolv.conf
no-resolv
#Interface to use
interface=wlan0
bind-interfaces
dhcp-range=10.0.0.200,10.0.0.250,12h


/etc/wpa_supplicant/wpa_supplicant.conf:
network={
ssid=“(masked)”
psk=“(masked)”
key_mgmt=WPA-PSK
}


/etc/systemd/system/autohotspot.service:
[Unit]
Description=Generates a non-internet Hotspot for ssh when a listed ssid is not in range
After=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/autohotspot
[Install]
WantedBy=multi-user.target


crontab: (sudo in cron had no effect on performance and was therefore not used in the information presented)
*/2 * * * * /usr/bin/autohotspot > /home/pi/cron.log 2>&1