Reliable and updatable access point

Thanks bversluijs, very helpful. Combining that with some info above…

/mnt/boot/system-connections/balena-hotspot

[connection]
id=balena-hotspot
uuid=36060c57-aebd-4ccf-aba4-ef75121b5f77
type=wifi
autoconnect=true
interface-name=wlan0
permissions=
secondaries=

[wifi]
band=bg
mac-address-blacklist=
mac-address-randomization=0
mode=ap
seen-bssids=
ssid=MY_HOTSPOT_SSID

[wifi-security]
group=
key-mgmt=wpa-psk
pairwise=
proto=rsn
psk=MY_HOTSPOT_PASSWORD

[ipv4]
dns-search=
method=shared

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto

docker-compose.yaml

version: "2.1"
services:
  dnsmasq:
    build: ./dnsmasq
    container_name: dnsmasq
    restart: always
    network_mode: host
    entrypoint:
      - sh
      - ./start.sh
    cap_add:
      - NET_ADMIN

Dockerfile

FROM balenalib/debian:stretch

RUN apt-get update
RUN apt-get install -y dnsmasq
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

COPY dnsmasq.conf /etc/dnsmasq.conf
COPY start.sh start.sh

start.sh

echo "Starting dnsmasq - $(date)"

dnsmasq \
  --address=/#/10.42.0.1 \
  --dhcp-range=10.42.0.1,10.42.0.254 \
  --dhcp-option=option:router,10.42.0.1 \
  --interface=wlan0 \
  --keep-in-foreground \
  --bind-interfaces \
  --except-interface=lo \
  --conf-file \
  --no-hosts \
  --log-facility=-

tail -f /dev/null

Some issues

When the entrypoint initialises, it says:

dnsmasq: unknown interface wlan0

Running nmcli on balena root suggests this does indeed exist. Maybe an execution order issue…

# nmcli
wlan0: connected to balena-hotspot
        "Ralink n"
        wifi (rt2800usb), 9C:EF:D5:FB:C1:D4, hw, mtu 1500
        inet4 10.42.0.1/24
        route4 10.42.0.0/24
        inet6 fe80::4da7:5750:80d8:2c99/64
        route6 fe80::/64
        route6 ff00::/8
...

If I run the dnsmasq command again it will says:

dnsmasq: failed to create listening socket for 10.42.0.1: Address already in use

In any case, its not quite working. Visiting a domain, eg) thing.local does not route to localhost:80 on the balena device.

I have tried changing the [ipv4] hotspot settings to method=manual but if I do that, the hotspot does not seem to be initialised (I can’t see it on my client device).

Any ideas what the issue may be?

EDIT:

I have been able to make it work by delaying the dnsmasq command a few seconds to avoid unknown interface wlan0 and also changing the IPV4 config:

[ipv4]
address1=10.42.0.1/24
dns=127.0.0.1;1.1.1.1;
dns-search=
method=manual

Thanks for your help!