0

Edit: I'm not looking for a full guide/answer necessarily, a nudge in the right direction (like what tool to use) would be of great help already! thanks :)

I am trying to create an accesspoint with a captive portal on my pi. The access point does not need to have internet access.

I succesfully configured the accesspoint using systemd-networkd and wpa_supplicant with the following configs:

/etc/systemd/network/10-wlan0.network

[Match]
Name = wlan0

[Network]
Address = 192.168.4.1/24
DHCPServer = yes

[DHCPServer]
DNS = 192.168.4.1
EmitDns = yes
PoolOffset = 1O
PoolSize = 40
DefaultLeaseTimeSec = 300

/etc/wpa_supplicant/wpa_supplicant-wlan0.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=BE

network={
    ssid="piAp"
    mode=2
    frequency=2437
    key_mgmt=NONE
}

I can connect to this 'hotspot' and I get an ip from the DHCP, so that all works.

/etc/hosts contains the following entry

127.0.0.1        raspberrypi

And running 'nslookup raspberrypi' locally on the pi produces the following output:

Server:        127.0.0.53
Address:       127.0.0.53#53

Non-authorative answer:
Name:          raspberrypi
Address:       127.0.1.1

However, when I run the nslookup command on a machine connected to the ap, it fails to resolve the hostname.

So my question then is: What do I need to do to make sure the connected devices can resolve the 'raspberrypi' domain?

0

It looks like that dnsmasq is missing. I've got the same setup, everything works, except IPv6. dnsmasq allows entries for single addresses as well like: address=/mylan/127.0.0.1

So for dnsmasq.conf I have:

cat dnsmasq.conf
domain-needed
bogus-priv
dhcp-authoritative
no-resolv
except-interface=eth0
interface=wlan0
bind-interfaces
domain=mywlan
dhcp-fqdn
enable-ra

#listen-address=127.0.0.1,192.168.2.1
dhcp-range=192.168.2.2,192.168.2.255,12h

dhcp-mac=set:client_is_a_pi,B8:27:EB:*:*:*
dhcp-reply-delay=tag:client_is_a_pi,2

Hope this helps!

1

You have accepted to use dnsmasq as additional DNS-server together with the built-in DNS-server of systemd-networkd that you enabled with option DHCPServer = yes in /etc/systemd/network/10-wlan0.network.

You must not have two DHCP-server running on one network!

It is out of specification and may confuse your network with mixed up ip addresses.

You must decide what solution you want to use, either only systemd-networkd or mixed with traditional network components like dnsmasq. I prefer to use modern software technologies like systemd that does not need additional helper programs. But if you prefer to use dnsmasq then you have to disable the DHCP-server in ../10-wlan0.network.

Or with systemd-resolved you simply enable the needed name resolution in the *.network files. There are mainly three services used for name resolution in a networks: DNS, mDNS and LLMNR. All three are supported by systemd-resolved. You used nslookup (better use dig) to check your name resolution. But this checks only DNS name resolution. It is unclear that you really setup your own private DNS server or maybe one of the other services are used. Because you have setup systemd-networkd you should use resolvectl that checks all three name resolution services. For more details look at to use options and testing name resolution with systemd-resolved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.