Still can't get the "Search Domains" to work
Having seen a lot of related questions and no solutions provided, I am trying to understand if it's a bug in macOS' resolver, or if it actually works for anyone?
Running Ventura (13.1) here, but had the same experience with previous version(s).
The search domain is there, populated by DHCP (also seen in WiFi connection properties):
earth:yuri:~$ scutil --dns
DNS configuration
resolver #1
search domain[0] : home.arpa
nameserver[0] : 192.168.1.1
if_index : 14 (en0)
flags : Request A records
reach : 0x00020002 (Reachable,Directly Reachable Address)
nslookup works:
earth:yuri:~$ nslookup europa
Server: 192.168.1.1
Address: 192.168.1.1#53
Name: europa.home.arpa
Address: 192.168.1.23
Everything else does NOT though (and that's exactly why I am looking into it):
earth:yuri:~$ ping europa
ping: cannot resolve europa: Unknown host
earth:yuri:~$ ssh europa
ssh: Could not resolve hostname europa: nodename nor servname provided, or not known
The following little program (code at the bottom as it's not that interesting) successfully resolves the unqualified hostname on all systems I tried (FreeBSD, illumos, Linux) except for macOS.
macOS:
earth:yuri:~$ cc -o r r.c
earth:yuri:~$ ./r home.arpa europa
europa: nodename nor servname provided, or not known
europa.home.arpa: ok
illumos (and other OS):
hyperion:yuri:~$ gcc -o r r.c -lsocket
hyperion:yuri:~$ ./r home.arpa europa
europa: ok
europa.home.arpa: ok
The code itself:
#include <sys/types.h>
#include <sys/socket.h>
#include <err.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main(int argc, char **argv)
{
struct addrinfo *res;
char *hostname, *fqdn;
int r;
if (argc != 3)
errx(1, "usage: <domain> <hostname>");
hostname = argv[2];
if (asprintf(&fqdn, "%s.%s", hostname, argv[1]) == -1)
err(1, "asprintf");
printf("%s: ", hostname);
r = getaddrinfo(hostname, NULL, NULL, &res);
if (r == 0)
printf("ok\n");
else
printf("%s\n", gai_strerror(r));
freeaddrinfo(res);
printf("%s: ", fqdn);
r = getaddrinfo(fqdn, NULL, NULL, &res);
if (r == 0)
printf("ok\n");
else
printf("%s\n", gai_strerror(r));
freeaddrinfo(res);
free(fqdn);
return (0);
}
MacBook Pro 16″, macOS 13.1