Hotspot Static IP wlan1 method=manual and dnsmasq/DNS?

raspberrypi3

#1

Hello,

I have following goal:

  1. if the container starts, wlan1(usb-wifi) will open up a static ip hotspot.
  2. if wlan0 resin-wifi credentials are ok, it will connect to the internet using wlan0.
  3. Flask server running on the static ip of wlan1 and modifying wlan0 using nmcli from the app container.

It would nearly work. What I am missing is:
if there is no internet on wlan0 (but, deployment was done before hand) and the app loads. I open up a wlan1 static ip hotspot.

My problem:
If I try to connect to my wifi hotspot, I will not get an IP assigned by the hotspot.
Mostlikely I need some DNS Server running for hotspot wlan1. How can I achieve this?
Do I have to install dnsmasq in the app container and enable the service + place a .conf file inside/etc defining DHCP ranges?

/etc/dnsmasq.conf

interface=wlan1  
bind-interfaces
dhcp-range=192.168.1.2,192.168.1.50,255.255.255.0,24h

/resin-boot/system-connections/resin-wifi-02

[connection]
id=resin-wifi-02
uuid=36060c57-aebd-4ccf-aba4-ef75121b5f77
type=wifi
autoconnect=false
interface-name=wlan1
permissions=
secondaries=

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

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

[ipv4]
address1=192.168.1.1/24,192.168.1.1
dns-search=
method=manual

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

Thank you for help


#4

Perhaps I don’t fully understand the issue here, but can you try altering the [ipv4] section above as follows?

[ipv4]
address1=192.168.1.1/24,192.168.1.1
dns=8.8.8.8;8.8.4.4;
dns-search=
method=manual

#5

This, I tried long time ago. But it requires that I have internet.

The gist ist, I want to client to connect to a static ip access point wlan1 to enter the wpa credentials for wlan0, so it gets internet.
I dont want resin-wifi-connect, because there is not method for the customer to clear the credentials, if there is no internet.

The problem is wlan1 does not always spawn at start. I don’t get it. Sometimes I can see wlan1 sometimes not. Something to do with link not ready initialized.
What I need is some standalone running dns server like in resin-wifi-connect to define DHCP ranges for connecting clients.

after COPY ..

I do

CMD ./nmcl connection up resin-wifi-02

using the resin-nmcli wrapper

Why does nmcli not always activate the connection. Sometimes it does, sometimes not? I have autoconnect=false in my hotspot, because putting it to true, leads to the wlan0 not connecting. If I purposely put a wrong password into wlan0 andautoconnect=true in the hotspot, the hotspot boots up.

Dockerfile

FROM resin/%%RESIN_MACHINE_NAME%%-node:6-slim

ENV INITSYSTEM on

#RUN echo "deb http://ftp.debian.org/debian stretch-backports main" >> /etc/apt/sources.list

RUN apt-get update && \
	apt-get install network-manager && \
    apt-get install dnsmasq && \
	systemctl mask NetworkManager.service


WORKDIR /usr/src/app

# Copies the package.json first for better cache on later pushes
COPY package.json package.json

# This install npm dependencies on the resin.io build server,
# making sure to clean up the artifacts it creates in order to reduce the image size.
RUN JOBS=MAX npm install --production --unsafe-perm && npm cache clean && rm -rf /tmp/*

COPY . .

CMD ["./nmcli", "connection", "up", "resin-wifi-02"]

CMD ["npm", "start"]


DEVICE     TYPE      STATE         CONNECTION
resin-dns  bridge    connected     resin-dns
wlan0      wifi      connected     resin-wifi-01
wlan1      wifi      disconnected  --
eth0       ethernet  unavailable   --
balena0    bridge    unmanaged     --
lo         loopback  unmanaged     --

After I do inside the appcontainer:./nmcli connection up resin-wifi-02. The hotspot is up. But how come it does not when booting?

DEVICE     TYPE      STATE        CONNECTION
resin-dns  bridge    connected    resin-dns
wlan0      wifi      connected    resin-wifi-01
wlan1      wifi      connected    resin-wifi-02
eth0       ethernet  unavailable  --
balena0    bridge    unmanaged    --
lo         loopback  unmanaged    --

#6

Hi, you should not use multiple CMD commands in the Dockerfile (https://docs.docker.com/engine/reference/builder/#cmd) . Only the last cmd is executed. Maybe you should wrap the two commands in a shell script, that is executed in the container


#7

Hi, you should not use multiple CMD commands in the Dockerfile (https://docs.docker.com/engine/reference/builder/#cmd) . Only the last cmd is executed. Maybe you should wrap the two commands in a shell script, that is executed in the container


#8

I thank you, I fixed this. I found out the problem is the usb-wifi stick in AP mode. It has driver problems. I switched around. Internal Wifi Access Ppint, and usb-wifi normal.


#9

teardown: user experienced driver issues with some of their hardware, self resolved.