I'm building a WLAN Router out of a Raspberry Pi 4. The internal WLAN adapter is used as Hot-Spot access point, the internal ethernet will be connected to the net.
I'm using NetworkManager and Netplan on Ubuntu 24.04 in order to set this up, and almost everything works beautifully.
The only thing I'm struggling with is, that I cannot get clients connected to the WLAN to DNS name-resolve the hostname of the Router itself. This is relevant, because the router also hosts a small HTTP frontend I want clients to be able to access.
So, I have the following Netplan:
network:
version: 2
renderer: NetworkManager
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
dhcp4: true
addresses:
- 192.168.200.1/24
access-points:
"MyHotSpotSSID":
password: "MyHotSpotPassword"
mode: ap
In addition, I have added my router host to my /etc/cloud/templates/hosts.debian.tmpl
, so that after a reboot my /etc/hosts
reads:
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
192.168.200.1 myrouter
127.0.1.1 myrouter myrouter
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
I can now connect a WLAN client to the MyHotSpotSSID
-WLAN of myrouter
and access the internet. Great!
However, from my client, I cannot ssh
, ping
or nslookup
the router myrouter
itself! What would be the recommended way to fix this?
For context, the router does seem to know its own hostname:
me@myrouter:~$ hostnamectl
Static hostname: myrouter
Icon name: computer
Machine ID: 391dffd2af51405487cd6c8011e68776
Boot ID: 62c61f761043491c9e669deb19400d0c
Operating System: Ubuntu 24.04 LTS
Kernel: Linux 6.8.0-1009-raspi
Architecture: arm64
On the client side, is does seem to know to direct DNS requests to my router:
me@myclient:~$ nmcli device show wlx3c33320101af
GENERAL.DEVICE: wlx3c33320101af
GENERAL.TYPE: wifi
GENERAL.HWADDR: 3C:33:32:01:01:AF
GENERAL.MTU: 1500
GENERAL.STATE: 100 (verbunden)
GENERAL.CONNECTION: MyHotSpotSSID
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/5
IP4.ADDRESS[1]: 192.168.200.131/24
IP4.GATEWAY: 192.168.200.1
IP4.ROUTE[1]: dst = 192.168.200.0/24, nh = 0.0.0.0, mt = 600
IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 192.168.200.1, mt = 600
IP4.DNS[1]: 192.168.200.1
IP6.ADDRESS[1]: fe80::d47:75ec:5a98:6ce/64
IP6.GATEWAY: --
IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 1024
nslookup
fails, when I ask via my client DNS cache:
me@myclient:~$ nslookup myrouter
;; Got SERVFAIL reply from 127.0.0.53
Server: 127.0.0.53
Address: 127.0.0.53#53
** server can't find myrouter: SERVFAIL
The router itself does seem to provide good DNS replies (although the order does not bode well):
meg@myclient:~$ nslookup myrouter 192.168.200.1
Server: 192.168.200.1
Address: 192.168.200.1#53
Name: myrouter
Address: 127.0.1.1
Name: myrouter
Address: 192.168.200.1
Can anyone help? Thank you in advance, friends!
TL;DR: Use .local
domain
Here's my somewhat incomplete answer after some research and the hint from @grawity_u1686 's comment:
The client I was connecting from is using systemd-resolved
as local DNS resolver (standard Ubuntu 24.04 desktop). It, as documented in the systemd-resolved manpage, provides different behavior depending on the type of hostname being queried:
.local
domain are resolved using MulticastDNS, which does work out of the box for me.So, my first attempt was to go with option 3. and assign a domain to myrouter
, which can be done by modifying its /etc/cloud/cloud.cfg
like so:
# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: false
# ==> new entries <==
hostname: myrouter
fqdn: myrouter.mydomain.org
prefer_fqdn_over_hostname: true
With this, myrouter.mydomain.org
resolves just fine from my client
However, after reading about what domain names to use for your home network, I understand, that inventing an own domain name is bad practice.
Hence, I finally just went with using myrouter.local
and resolver option 2. from above.