Most of RT#6923, except for the part that depends on the sendto_kdc rewrite (it's still in locate_kdc in this version): pass AI_ADDRCONFIG whenever we specify hints to getaddrinfo() to get the address of a server. Index: src/plugins/locate/python/py-locate.c =================================================================== --- src/plugins/locate/python/py-locate.c.orig +++ src/plugins/locate/python/py-locate.c @@ -303,6 +303,7 @@ lookup(void *blob, enum locate_service_t return -1; } aihints.ai_socktype = thissocktype; + aihints.ai_flags = AI_ADDRCONFIG; x = getaddrinfo (hoststr, portstr, &aihints, &airesult); if (x != 0) continue; Index: src/appl/sample/sclient/sclient.c =================================================================== --- src/appl/sample/sclient/sclient.c.orig +++ src/appl/sample/sclient/sclient.c @@ -124,6 +124,7 @@ main(int argc, char *argv[]) memset(&aihints, 0, sizeof(aihints)); aihints.ai_socktype = SOCK_STREAM; + aihints.ai_flags = AI_ADDRCONFIG; aierr = getaddrinfo(argv[1], portstr, &aihints, &ap); if (aierr) { fprintf(stderr, "%s: error looking up host '%s' port '%s'/tcp: %s\n", Index: src/kadmin/dbutil/kadm5_create.c =================================================================== --- src/kadmin/dbutil/kadm5_create.c.orig +++ src/kadmin/dbutil/kadm5_create.c @@ -182,7 +182,7 @@ static int add_admin_princs(void *handle goto clean_and_exit; } memset(&ai_hints, 0, sizeof(ai_hints)); - ai_hints.ai_flags = AI_CANONNAME; + ai_hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG; gai_error = getaddrinfo(localname, (char *)NULL, &ai_hints, &ai); if (gai_error) { ret = EINVAL; Index: src/lib/kadm5/alt_prof.c =================================================================== --- src/lib/kadm5/alt_prof.c.orig +++ src/lib/kadm5/alt_prof.c @@ -901,7 +901,7 @@ kadm5_get_admin_service_name(krb5_contex } memset(&hint, 0, sizeof(hint)); - hint.ai_flags = AI_CANONNAME; + hint.ai_flags = AI_CANONNAME | AI_ADDRCONFIG; err = getaddrinfo(params_out.admin_server, NULL, &hint, &ai); if (err != 0) { ret = KADM5_CANT_RESOLVE; Index: src/lib/kadm5/clnt/client_init.c =================================================================== --- src/lib/kadm5/clnt/client_init.c.orig +++ src/lib/kadm5/clnt/client_init.c @@ -563,8 +563,9 @@ connect_to_server(const char *hostname, (void) snprintf(portbuf, sizeof(portbuf), "%d", port); memset(&hint, 0, sizeof(hint)); hint.ai_socktype = SOCK_STREAM; + hint.ai_flags = AI_ADDRCONFIG; #ifdef AI_NUMERICSERV - hint.ai_flags = AI_NUMERICSERV; + hint.ai_flags |= AI_NUMERICSERV; #endif err = getaddrinfo(hostname, portbuf, &hint, &addrs); if (err != 0) Index: src/lib/krb5/os/hostaddr.c =================================================================== --- src/lib/krb5/os/hostaddr.c.orig +++ src/lib/krb5/os/hostaddr.c @@ -44,7 +44,7 @@ krb5_os_hostaddr(krb5_context context, c return KRB5_ERR_BAD_HOSTNAME; memset (&hints, 0, sizeof (hints)); - hints.ai_flags = AI_NUMERICHOST; + hints.ai_flags = AI_NUMERICHOST | AI_ADDRCONFIG; /* We don't care what kind at this point, really, but without this, we can get back multiple sockaddrs per address, for SOCK_DGRAM, SOCK_STREAM, and SOCK_RAW. I haven't checked if Index: src/lib/krb5/os/hst_realm.c =================================================================== --- src/lib/krb5/os/hst_realm.c.orig +++ src/lib/krb5/os/hst_realm.c @@ -103,7 +103,7 @@ get_fq_hostname(char *buf, size_t bufsiz int err; memset (&hints, 0, sizeof (hints)); - hints.ai_flags = AI_CANONNAME; + hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG; err = getaddrinfo (name, 0, &hints, &ai); if (err) return krb5int_translate_gai_error (err); Index: src/slave/kprop.c =================================================================== --- src/slave/kprop.c.orig +++ src/slave/kprop.c @@ -325,6 +325,7 @@ open_connection(krb5_context context, ch memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_ADDRCONFIG; error = getaddrinfo(host, port, &hints, &answers); if (error != 0) { com_err(progname, 0, "%s: %s", host, gai_strerror(error)); Index: src/lib/krb5/os/locate_kdc.c =================================================================== --- src/lib/krb5/os/locate_kdc.c.orig +++ src/lib/krb5/os/locate_kdc.c @@ -259,8 +259,9 @@ krb5int_add_host_to_list (struct addrlis memset(&hint, 0, sizeof(hint)); hint.ai_family = family; hint.ai_socktype = socktype; + hint.ai_flags = AI_ADDRCONFIG; #ifdef AI_NUMERICSERV - hint.ai_flags = AI_NUMERICSERV; + hint.ai_flags |= AI_NUMERICSERV; #endif result = snprintf(portbuf, sizeof(portbuf), "%d", ntohs(port)); if (SNPRINTF_OVERFLOW(result, sizeof(portbuf)))