0

I have a raspberry pi (192.168.1.1) set up as an AP for a few devices. The WIFI connection works, DHCP also seems to give out valid addresses. The issue is that none of the devices in the network are able to resolve the hostname of the pi, 'home'. Here are some configuration files:

/etc/hosts
127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

127.0.1.1       home
/etc/dnsmasq.conf
interface=wlan0
no-dhcp-interface=eth0

dhcp-range=192.168.1.2,192.168.1.254,12h

dhcp-option=option:dns-server,192.168.1.1
log-queries
log-facility=/tmp/dnsmasq.log
/etc/dhcpcd.conf
interface wlan0
        static ip_address=192.168.1.1/24
        static domain_name_servers=192.168.1.1
        nohook wpa_supplicant
/etc/hostapd/hostapd.conf
# WLAN-Router-Betrieb

# Schnittstelle und Treiber
interface=wlan0
#driver=nl80211

# WLAN-Konfiguration
ssid=HomeNetwork
channel=2
hw_mode=g
ieee80211n=1
ieee80211d=1
country_code=DE
wmm_enabled=1
ignore_broadcast_ssid=1
max_num_sta=255

# WLAN-Verschlüsselung
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=xxxxxxx

ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
/var/lib/misc/dnsmasq.leases
1609402473 3c:71:bf:3a:09:c2 192.168.1.67 living-shelf *
1609402474 dc:4f:22:aa:08:1e 192.168.1.42 living-computer-light *
1609402473 dc:4f:22:92:75:da 192.168.1.215 living-beamer *
1609402647 c8:2b:96:53:79:a5 192.168.1.94 living-heater-carpet *
1609400799 dc:4f:22:a7:e5:4d 192.168.1.186 living-light *
1609402473 84:0d:8e:aa:81:7c 192.168.1.98 kitchen-passage *
1609402514 3c:71:bf:3a:12:8f 192.168.1.158 living-wallclock *
1609402652 c8:2b:96:53:77:bd 192.168.1.227 tasmota-printer *

My questions are:

  1. Which component of my AP-pi should recognize a DNS query as a hostname of one of the devices and resolve it?
  2. What do I have to set up in order for all the devices in the network to be able to reach each other through their hostnames?
  3. What is required for the devices to be able to reach the AP-pi by its hostname?
4
  • What are the other devices? What are you trying to reach the Pi with (ping, shh, ftp etc)? What commands have you issued? Technically this is not a Pi issue as it's the other devices having the issue :-) – user115418 Dec 30 '20 at 23:38
  • Most of the other devices are esp8266, but other PI's can't reach the main PI aswell. Also, I fear that the issue lies in the DNS somewhere in the AP-pi. – Daniel D. Dec 31 '20 at 3:06
  • You need to have a look at the host file and add a proper entry for the Pi using the 192.168.1.1 <Pi FQDN> - I use .local here being basically a Mac network but others here may shout at me for that :-) so my entry would be 192.168.1.1 home.local then sudo systemctl restart dnsmasq – user115418 Dec 31 '20 at 13:28
  • What did you try that didn't work? – Milliways Jan 1 at 0:36
4

You are asking for a general tutorial in name resolution which has nothing to do with Raspberry Pi. It is a general networking issue and I can only give an overview where you can look for more details.

At the beginning of the internet there was a simple file /etc/hosts used that contained all ip address to name mappings on every device. It is obviously that this can't be handled on a growing network.

The evolution comes to the Domain Name Service, in short DNS, that becomes a distributed database all over the world with ip address to name mappings, organized in a tree manner. Yeah, and that is not simple to manage and needs some deeper knowledge about networking.

This was the reason why there was defined a self configuring name resolution system for small local networks using multicast messages. This system is called mDNS (multicast DNS). Because of its nature it cannot pass router so it is restricted to the local network with the same ip address range, a so called broadcast domain.

To have a name resolution on your local network you must decide what system you want to use. Using /etc/hosts is very simple and always still works.

When you get tired to manage all names on all devices you can use one of the other solutions. To configure a DNS system you have to setup a DNS server with your own domain. Please never use domain local because it is reserved for mDNS. You also have to ensure that this private DNS-server queries other DNS-server on the internet for names that it is not authoritative (eg. google.com).

Too complicated? Then you should use mDNS. On a Linux operating system this is managed by the avahi program. On the default Raspberry Pi OS it is preinstalled and works out of the box. You should be able to address it with ping raspberrypi.local. All devices which support mDNS can be addressed with its hostname prepended to .local, for example ssh username@mylaptop.local.

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.