You are not logged in.

#1 2015-02-13 16:03:42

replabrobin
Member
Registered: 2010-05-06
Posts: 235

configure resolv.conf nsswitch.conf etc to search .local

After installing a new router I find I cannot ping hosts on my local network using just the simple hostname.

I used to be able to ping myhost, but now I find I need to ping myhost.local.

My nsswitch.conf hosts line looks like

hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname wins

I tried adding various search values to  /etc/resolv.conf, but couldn't find one that worked.

Is there a way to get the .local domain searched, my router (although expensive) doesn't seem to facilitate this?

Offline

#2 2015-02-14 18:44:26

replabrobin
Member
Registered: 2010-05-06
Posts: 235

Re: configure resolv.conf nsswitch.conf etc to search .local

After some digging in the nss-mdns package source I find that the option to respect resolv.conf search domains is turned off in the Arch build. However, a simple patch to nss.c seems to fix things up fairly easily. A more complex one would be required to respect the /etc/mdns.allowed file domains. It seems like such an obvious thing to do for domainless searches that I wonder why this wasn't done by the original author.

$ diff nss.c.orig nss.c
380a381,407
>     if (u.count == 0 && avahi_works && !strstr(name, ".")) {
>         const char *p="local";
>         int fullnamesize;
>         char *fullname;
>         fullnamesize = strlen(name) + strlen(p) + 2;
>         if ((fullname = malloc(fullnamesize))){
>             snprintf(fullname, fullnamesize, "%s.%s", name, p);
>             if (verify_name_allowed(fullname)) {
>                 int r;
>                 if ((r = avahi_resolve_name(af, fullname, data)) < 0) {
>                         /* Lookup failed */
>                         avahi_works = 0;
>                     }
>                 else if (r == 0) {
>                     /* Lookup succeeded */
>                     if (af == AF_INET && ipv4_func)
>                        ipv4_func((ipv4_address_t*) data, &u);
>                     if (af == AF_INET6 && ipv6_func)
>                         ipv6_func((ipv6_address_t*)data, &u);
>                     }
>                 else
>                    /* Lookup suceeded, but nothing found */
>                    status = NSS_STATUS_NOTFOUND;
>                 }
>             free(fullname);
>             }
>         }

Offline

Board footer

Powered by FluxBB