Local hostname not working without the trailing dot

dd-wrtdnsdnsmasqnetworkingrouter

I noticed all my local hostnames have a trailing dot at the end when I use some LAN scan tool on my Android phone. And without it, I can't get a ping to work from my Windows desktop (it works fine from my Linux VMs):

C:\Users\dnll>ping router
Ping request could not find host router. Please check the name and try again.

C:\Users\dnll>ping router.

Pinging router [192.168.1.1] with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.1.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

This is more obvious when trying to reach my router web UI as I need to enter http://router./ since http://router/ won't work. I'm using DD-WRT with dnsmasq enabled, not sure if that could be the issue. I'd prefer the hostnames to be reachable without the dot from my Windows PC.

dnsmasq settings

I tried disabling the local DNS without much success.

Here is ipconfig /all from my desktop:

C:\Users\dnll>ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : desktop
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Intel(R) Ethernet Connection (5) I219-V
   Physical Address. . . . . . . . . : 70-4D-7B-67-7C-FD
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 192.168.1.205(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : December 12, 2018 18:11:50
   Lease Expires . . . . . . . . . . : December 17, 2018 00:21:37
   Default Gateway . . . . . . . . . : 192.168.1.1
   DHCP Server . . . . . . . . . . . : 192.168.1.1
   DNS Servers . . . . . . . . . . . : 192.168.1.1
   NetBIOS over Tcpip. . . . . . . . : Enabled

There is nothing really special about my Windows configuration that I know of. I'm not using a domain, at least not that I know of (and I tried a ping to router.local or router.mydomain without success, just to be sure).

What's wrong?

Best Answer

  • The dot at the end is required to force a DNS lookup. Without it, Windows may try first other methods such as NETBIOS or the hosts file, which it will not try if the dot is present. When you put a dot, you are saying the host-name is fully qualified, otherwise it will add your DNS suffix. The final "dot" is always implied in DNS even if it's not specified.

    From the DD-WRT forum article Can't resolve hostname but can resolve hostname. (with a . ):

    This is typical DNS behavior.

    The "trailing dot" signifies a fully qualified domain name (FQDN). Without the dot, the name you are trying to ping is ambiguous (having several possible meanings or interpretations).

    You can help prevent the use of trailing dot by specifying a LAN domain of (for example) "local" in the router. Then release/renew DHCP on the client.

    ping stan.local
    
    ping stan
    

    So if your router's host-name would be router.local., and your DNS resolver would have a search path of local, when doing a lookup for router the DNS client will automatically append the .local. and then successfully resolve the address.

  • Related Question