Bit stuck here.
I have 2 machines that cannot resolve LAN hostsnames, unless there are specific entries in /etc/hosts
But other machines on the LAN can resolves hostnames.
My LAN:
- 1 x Cisco router runnning DD-WRT v24-sp2 with DNSMasq enabled. I've configured this with the hostnames and IPs on my LAN.
- 1 x Kubuntu 12.10 (resolves all hostnames correctly as long as they are entered into DNSMasq on the router)
2 x NAS (also resolve all names correctly)
1 x Ubuntu Server 12.04 (this does NOT resolve local hostnames unless they are entered into /etc/hosts)
- 1 x XBMCLive (Dharma) (same - does not resolve unless entries are in /etc/hosts)
How do I get the last 2 to use the DNSMasq entries on the router? Each machine is set to use the router as a nameserver, and all units resolve external addresses correctly.
Thanks.
some more info:
whilst on server, if I ping another PC (wstation)
$ ping wstation
PING wstation.local.domain (x.x.x.x)
If I then append .local
$ ping wstation.local
PING wstation.local.local.domain (x.x.x.x)
and directly
$ ping 10.0.0.4
PING 10.0.0.4 (10.0.0.4) 56(84) bytes of data.
64 bytes from 10.0.0.4: icmp_req=1 ttl=64 time=0.387 ms
64 bytes from 10.0.0.4: icmp_req=2 ttl=64 time=0.316 ms
64 bytes from 10.0.0.4: icmp_req=3 ttl=64 time=0.312 ms
64 bytes from 10.0.0.4: icmp_req=4 ttl=64 time=0.280 ms
64 bytes from 10.0.0.4: icmp_req=5 ttl=64 time=0.322 ms
^C
--- 10.0.0.4 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3998ms
rtt min/avg/max/mdev = 0.280/0.323/0.387/0.038 ms
About your current output
Clearly indicates that your pc is appending
.local.domain
to non-FQDN queries. This is something configured improperly or at least wrong in your set up. (unless you actually use the.local.domain
suffix on purpose)Name resolving and periods
One important thing what a lot of people don't know, is that a full name should always end with a period (
.
). If you omit it, then the machine will try to resolve it within the local search domain (e.g. mydomain.tld). So in that case, a query formypc.local
would becomemypc.local.mydomain.tld
. To prevent this, query with the period.Resolver configuration
The resolver configuration is of great importance here. In Ubuntu (and Debian) this is configured in the file
/etc/network/interfaces
(assuming you're not running NetworkManager):Name resolving in Linux can also be accomplished in other ways. It's not just that the local DNS server is being queried for all of this. Take a look at your
/etc/nsswitch.conf
file for thehosts
configuration of resolving:This means that files are tried first (this is the
/etc/hosts
file), then mDNS and only later the real DNS server is queried. mDNS is implemented using Avahi in Linux and is called Bonjour on Apple devices. It is using the.local
suffix by default and works via broadcast messages. Much like ARP works, but then for DNS.All these systems can be very confusing and even more when using
.local
in a regular DNS setup mixed with mDNS devices. I guess this is why you're confused now as to why one device works and the other doesn't: they're not all using the same resolving method.To sort things out
.local
unless you want to rely on mDNS completely. From your question I understand you'd like to keep things configured yourself in a central place, so my approach here is to avoid it.my.home
. For dnsmasq this is a single setting, but in regular setups this should be configured on both the DNS server as well as the DHCP server (as it's being announced via DHCP)./etc/resolv.conf
in case you fiddled with it in the past.Configure the PCs in your network to use
my.home
as the local search domain. This can be done via DHCP automatically, or if using static addresses via the/etc/network/interfaces
file or in Network Manager:ping hostname
) as well as full name (ping hostname.my.home
) should work.Based on the answer by gertvdijk I just commented out the line in nsswitch.conf
I got similar issues with a /etc/hosts containing multiple spaces between IP and hostname, instead using a TAB. After changing to TAB the hostname could be resolved by ping.
see also on https://superuser.com/a/938366/467479