3

I have a Raspberry PI Zero W configured as a Wi-Fi access point and running a web server. Its hostname is a-casa-de-casario. I can access my website perfectly from any other machine connected to the local network provided by the PI using the a-casa-de-casario.local address. But is there a way to get rid of the .local suffix so as to access the website using only the a-casa-de-casario address?

The PI Zero W is providing the access point through its wlan0 interface and is therefore not connected to any other network. Here is the relevant part of /etc/dhcpcd.conf :

interface wlan0
  static ip_address=192.168.4.1/24
  static domain_name_servers=192.168.4.1
  nohook wpa_supplicant
2
  • 1
    What is your network environment? The answer to this question highly depends on your dns server (most likely in your router/modem).
    – Uwe Plonus
    Commented Apr 23, 2019 at 16:34
  • @UwePlonus Sorry. I edited the question and tried to add more information about the network environment.
    – Jujule
    Commented Apr 24, 2019 at 15:14

1 Answer 1

2

You are using the .local DNS top-level domain. This domain is reserved for multicast DNS (mDNS) mostly used for Link-local addresses and defined not be be served by any DNS server. This is managed by avahi and implies that there is no DHCP server present on the subnet and there is no DNS server serving the .local top level domain. All devices on the subnet have ip addresses from the subnet 169.254.0.0/16.

The local DNS resolver is managed with the file /etc/resolv.conf. You can tell the resolver to always append a default domain if the queried DNS name isn't full qualified. These options are

domain Local domain name
search Search list for host-name lookup

For its specific use look at man resolv.conf. This way you can omit typing the domain name .local.

But there is a problem with modifying /etc/resolv.conf. This file is mostly modified by resolver configuration programs like resolvconf or openresolv or systemd-resolved.service to manage changed DNS server entries on mobile devices. They will always overwrite your settings in resolv.conf. You have to determine what configuration options of that programs will set domain and/or search entries in resolv.conf.

If you do not use a resolver configuration program you can just edit /etc/resolv.conf.

UPDATE:
I have learned that the description above is the default behavior with DNS name resolution but .local is a special top level domain that do not follow this. It is used as an parallel service to DNS with DNS server. Any DNS query for a name ending with .local MUST be sent to the mDNS IPv4 link-local multicast address 224.0.0.251. (2)

The .local domain should not be used when setting up DNS infra-structures. So a query to a DNS infra-structure should never give an answer. Most applications use glibc's Name Service Switch to decide how host names are looked up. This is configured in /etc/nsswitch.conf and has a special entry for mDNS which ensures that a .local query is never asked to DNS server. For detailed info about this look at (1).

All together: you will not get an answer if you try to search a DNS infra-structure for the domain .local. The domain name itself is used to distinguish between mDNS and DNS infra-structure. You cannot omit it.

References:
(1) - Can not resolve .local domains internal to my office LAN - Answer 1
(2) - Can not resolve .local domains internal to my office LAN - Answer 2

2
  • Thanks for you informative and detailed answer. /etc/resolv.conf does indeed state that if was generated by resolvconf. As you suggested, I looked into its configuration file and added search local' after the name-servers 127.0.0.1` line. Now search local is added to /etc/resolv.conf but I still can't connect to a-casa-de-casario ( a-casa-de-casario.local still works, though ).
    – Jujule
    Commented Apr 24, 2019 at 15:30
  • @Jujule With research to your comment I have learned the difference between mDNS and DNS infra-structure. I have updated the answer at the end.
    – Ingo
    Commented Apr 24, 2019 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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