avahi and DNS

Related to my last posting, sudo was lagging when attempting to resolve hostnames unique to local network (my work’s domain). Anyway, after strace-ing, I found that sudo was timing-out while using avahi to resolve these local names.

From strace sudo ls:

...
connect(7, {sa_family=AF_FILE, path="/var/run/avahi-daemon/socket"}, 110) 
    = 0
fcntl64(7, F_GETFL)                     = 0x2 (flags O_RDWR)
fstat64(7, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
    = 0xb77e3000
_llseek(7, 0, 0xbfebaf98, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
write(7, "RESOLVE-HOSTNAME-IPV4 newcastle."..., 49) = 49
read(7, "-15 Timeout reached\n", 4096)  = 20
...

That explains the lag I was experiencing with sudo.

The solution is in NSCD’s configuration: I want avahi consulted last, after DNS and hosts have been exhausted. In my case, DNS would produce the correct answer.

Looking at /etc/nsswitch.conf:

...
hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

Just as suspected: avahi (multicast DNS) is being consulted before DNS. After switching the two entries (DNS and mdns4_minimal) and running sudo, no more lag! Problem solved.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: