DNS resolution problem – dig working, ping not

Today I was reconfiguring my internal laptop network as I use virtual machines a lot (KVM ftw) and using /etc/hosts was not scaling anymore. I could use DNSmasq but I prefer BIND – so I installed & chrooted it, and configured as caching-name server that properly resolv my internal zone ‘local’ (as I use adresses like ‘git.local’ or ‘dev1.local’ or whatever). Next I had to make NetworkManager to use this local DNS in the first place instead of those given from DHCP. I could of course edit properly /etc/resolv.conf and protect it with immutable attribute but I suppose, that NM developers didn’t take it into consideration, that resolv.conf would be unwritable and hell knows what would happen then. So I added:

To the /etc/sysconfig/network-scripts/ifcfg-Auto_WLANname and things were ok – after restarting network I had what i wanted to have in /etc/resolv.conf. I resolved VPN resolving problem in a similar way.

So now I wanted to start my work with VMs and it appeared that I couldn’t make a connection to any of those:

Weird… And check this:

So WTF with this DNS?

This time WTF was much bigger. Local DNS appears to be working correctly. So I thought that this Fedora claimed that won’t be resolving ‘local’ adresses via DNS. Just to confirm this idea I used tcpdump:  “tcpdump -n port 53″ – in the meantime trying to ping ‘git.local’ host. And nothing there – tcpdump was silent. bingo – Fedora was not using DNS at all to resolve this one. So why? Let’s see:

Ok – we have nscd in the first way (which is not running on my laptop) and next we have Avahi… but where the hell is DNS? Let’s see /etc/nsswitch.conf:

Ha – now everything is clear! You can read about Avahi, MDNS and ‘local’ domains here: http://avahi.org/wiki/AvahiAndUnicastDotLocal

Solution? There are two. Firstly we could just replace above nsswitch.conf entry with the following (of course only when NOT using Avahi):

Second solution – we could reconfigure Avahi – just as You can read in the above URL:

Now only restart Avahi, web browsers and everything should be working fine.