You are not logged in.

#1 2018-12-28 18:33:04

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,452
Website

[SOLVED] Setting up wlan (w/no internet), hostapd?

I'm trying to set up a local wireless network between my laptop (arch) and a rpi zero (archARM).  The end goal is for a lot of this to be done on the pi, but as that's harder to experiment with, I've been doing most of my work so far on my arch laptop.

I'm not sure I understand which tools are called for in order to 1) create a wireless network (on "server"), and 2) allow other devices (clients) to connect to the network to access services (e.g. ssh to the server or access a web site on the server).

I started with a software access point with hostapd.  I got as far as creating a wireless network that another device could join (open only, wpa_supplicant was failing), but I could not do anything over that connection: I tried to `nmap` the local network from the secondary connected device, but it didn't detect any other IP addresses on the network (despite being connected to the wireless access point of another device).  I suspect I may need to run a DHCP server and/or dnsmasq or similar as a next step.  But in my reading of the documentation for these tools, they all seem to be geared toward bridging connections between the local network and the wider internet.  There will be no internet connection in my set up: just two devices.  Are these the wrong tools?

I also read up on ad hoc networking which seems a more straitforward way to acheive my goal.  However, in the long term, I'd like it to be trivially easy for the "client" device to connect to the created network.  Ad hoc networking sounds like it would require special steps on their end as well, where as - in theory - a hostapd created network should just look like any other wireless network to them and they'd connect with their normal tools.

Unfortunately I didn't get nearly as far with ad hoc networking as I did with hostapd.  With the wpa settings, from the wiki, I get the following errors:

$ sudo wpa_supplicant -i wls1 -c cricket.wpa -D nl80211,wext
Successfully initialized wpa_supplicant
Note: nl80211 driver interface is not designed to be used with ap_scan=2; this can result in connection failures
wls1: Trying to associate with SSID 'cricket'
wls1: Association request to the driver failed
^Cnl80211: deinit ifname=wls1 disabled_11b_rates=0
wls1: CTRL-EVENT-TERMINATING

If I remove the ap_scan=2 line:

$ sudo wpa_supplicant -i wls1 -c cricket.wpa -D nl80211,wext
Successfully initialized wpa_supplicant
wls1: Trying to associate with SSID 'cricket'
wls1: Association request to the driver failed
^Cnl80211: deinit ifname=wls1 disabled_11b_rates=0
wls1: CTRL-EVENT-TERMINATING

If I attempt the "manual" non wpa method in the same wiki page, that also fails:

$ sudo iw wls1 set type ibss

$ sudo ip link set wls1 up
ip: SIOCSIFFLAGS: I/O error

At this point, I'm looking for input on which approach I should focus on troubleshooting: is hostapd appropriate for my use-case (no outside internet connection), and if so, what's needed after associating to the server's network? 
The network configuration section of the software access point wiki page seems to be where I've stopped as neither of the two options there seem to apply to a access point / server without it's own internet connection.

[solution in bottom half of post 9]

Last edited by Trilby (2019-01-10 15:10:25)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#2 2018-12-28 21:34:33

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

WiFi (in this case represented by hostapd) just creates a "cable" connection (Layer 2) beetween the involved machines, so you need to attach an ip to the wifi interface or the bridge you are using. If you are not using the bridge option, use an ip from another subnet and do the needed routing (if so). Once done, you can connect from the client as usual (however, you need to set an ip from the hostapd subnet here too).

Last edited by Tarqi (2018-12-28 21:41:33)


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#3 2018-12-28 22:40:21

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,452
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

Thanks - is dnsmasq the appropriate tool for that, or is it only for when one is bridging to another connection?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2018-12-28 23:15:54

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

Since a bound service might fail if an interface goes down, which will happen if the carrier is lost (i.e. no station is connected) or even will not already start if the interface is not up (again: carrier), my advise is to always use a bridge with an static ip and configure hostapd to use this bridge. Hostapd will add the physical wifi interface to the bridge, so the bridge itself acts as the interface to work with. The wifi interface might stay the only one within the bridge or other interfaces (maybe an usb ethX) might be added. None of the interfaces should have an ip, as the bridge has one. This way you have always an usable interface which is up and working and where services can be bound to without problems, regardless of a physical interface is attached or a carrier is lost, so you can setup dnsmasq to bind to the bridge and do the dhcp stuff for the bridge subnet (and dns of course). The client site would then be as simple as connecting to some bought router box by WiFi or cable and DHCP.

Last edited by Tarqi (2018-12-28 23:24:11)


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#5 2018-12-28 23:29:47

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,452
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

Tarqi wrote:

Since a bound service might fail if an interface goes down, which will happen if the carrier is lost (i.e. no station is connected) or even will not already start if the interface is not up (again: carrier),

Can you elaborate on this, I don't think I understand.  Nginx, for example, is happy to run regardless of the state of any network interfaces, as is sshd.  These run *before* any client connects and continue to run even if a client disconnects.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2018-12-28 23:29:59

seth
Member
Registered: 2012-09-03
Posts: 50,012

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

Sanity check: did you check whether the interfaces (esp. the RP0 one) actually support AP/IBSS modes? ("iw list")

Offline

#7 2018-12-28 23:49:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,452
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

Yes, it supports AP and IBSS.  In fact I have the wireless connection "working".  More so than in the first post even, I can establish a WPA2 connection between two devices.  But I just started tinkering with dnsmasq assuming that must be the next step needed to get IP addresses to allow ssh and/or webpage access.  However I feel like I'm getting contradictory information from various sources on how to configure dnsmasq or whether it is even the appropriate tool for what I'm trying to do.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2018-12-28 23:53:58

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

If the wifi connection works, just use dnsmasq as you would for an ethX device.


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#9 2018-12-29 00:01:55

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,452
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

I have no idea how one would use dnsmasq for an wired device.  Again, I don't even know if that tool is applicable to my current situation.  All the examples I find for dnsmasq seem to assume the machine running it has an active internet connection.

For example, I don't know what address to listen on, as the server running dnsmasq will not be provided an IP address by anything else.  So I just added my own with the following:

ip address add 192.168.1.1/24 broadcast + dev wlan0

And then I listen on 192.168.1.1, but dnsmasq now gives this error:

dnsmasq: failed to create listening socket for 192.168.1.1: Cannot assign requested address

EDIT: oops, standby, I had rebooted between adding the IP address with `ip` and the last run that generated that error ...  EDIT2: that error was due to the IP not yet being created, once it was, dnsmasq ran without any error, but dhcpcd on the client just times out unable to get an IP address.

EDIT 3: Got it!

This is a very unsafisfactory solution as it was through trial and error rather than any understanding gained, but this guide helped:
https://nims11.wordpress.com/2012/04/27 … ess-point/

It turns out when I got rid of everything in my dnsmasq.conf except for the two lines from that guide, it worked (I changed the 10.0.0.* address range to 192.168.1.*).  I may dig into this more to see if I can use hostnames within the local network, but I'm perfectly happy with being able to ssh to 192.168.1.1 and calling it a day.

In case anyone else stumbles upon this trying to do the same thing, here are my working configs for reference with only the SSID and passphrase redacted:

# hostapd.conf
interface=wlan0
driver=nl80211

ssid=********
hw_mode=g
channel=1

macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=********
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
# dnsmasq.conf
interface=wlan0
dhcp-range=192.168.1.3,192.168.1.20,12h

I need to manually add the static ip of 192.168.1.1 to wlan0 before this works, but I'm pretty sure there's a systemd way of doing that on boot up.  Worst case, I'll add the ip command to do it as an ExecStart prior to dnsmasq in the dnsmasq service.  But that's the polishing and automating stage.  For now I'm going to celebrate success at this stage and get some rest.

Last edited by Trilby (2018-12-29 00:33:42)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#10 2018-12-29 00:51:14

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

Trilby wrote:
Tarqi wrote:

Since a bound service might fail if an interface goes down, which will happen if the carrier is lost (i.e. no station is connected) or even will not already start if the interface is not up (again: carrier),

Can you elaborate on this, I don't think I understand.  Nginx, for example, is happy to run regardless of the state of any network interfaces, as is sshd.  These run *before* any client connects and continue to run even if a client disconnects.

Just for the completeness...

I apologize for my bad memories, I thought I have had problems with losing the carrier, but now I remember I used the bridge because of the interface coming and going (usb wifi stick) and the bound services obvously had problems with that. To avoid this, I used the bridge as a fixed interface, where I don't need to think about any problems, as far as the main configuration succeds. That way I could also add another usb ethX stick, which can be removed without disturbing any services. Though I'm convinced that the bridge solution is more robust.

For the clients: Regardless of that carrier thing, I meant Layer 2 clients and believe you meant Layer 3.

Edit: Spelling

Last edited by Tarqi (2018-12-29 01:06:10)


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#11 2018-12-29 00:54:30

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

Trilby wrote:

Worst case, I'll add the ip command to do it as an ExecStart prior to dnsmasq in the dnsmasq service

Just for curiosity: One could do an own service file for this (I did, because in my case it's more complex) or using systemd-networkd or netctl or whatever, but what's wrong with that?

Edit: Sorry for creating a new post, wasn't intended.

Last edited by Tarqi (2018-12-29 01:02:42)


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#12 2018-12-29 01:06:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,452
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

Nothing would be wrong with a new service file for it, other than ensuring the ip adding service ran before the dnsmasq service.  I believe this would require modifying the dnsmasq service, so at that point it seems easier to me to just add the ip command there.

But I think there is a more systemd-ish way of doing this.  I've seen examples referencing /etc/systemd/network/<interface>.network files that seem to be for this purpose.  I've just not dug into that yet.  But for my purposes any approach would be as good as any other.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#13 2018-12-29 01:13:13

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

That's a missunderstanding, I meant why it would be worse to add that line to the dnsmasq service? In my opinion this would be KISS and the service managemenet in question of the correct order would be obsolete could be done by simply ordering dnsmasq after hostapd. However, in the end this is a question of taste.

Regards...

Last edited by Tarqi (2018-12-29 01:16:26)


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

#14 2018-12-29 01:16:12

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,452
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

It may have been a poor choice of words on my part.  I didn't mean that'd be the worst opion - just that "worst case" mean if I didn't learn any more or find other options, I had one that worked.  If I learn and experiment more I might find it to be the "best case" too.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#15 2018-12-29 01:17:04

Tarqi
Member
From: Ixtlan
Registered: 2012-11-27
Posts: 179
Website

Re: [SOLVED] Setting up wlan (w/no internet), hostapd?

I understand. Thanks.


Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse

Offline

Board footer

Powered by FluxBB