Index: share/man/man5/resolv.conf.5 =================================================================== RCS file: /cvs/src/share/man/man5/resolv.conf.5,v diff -u -p -r1.65 resolv.conf.5 --- share/man/man5/resolv.conf.5 25 Nov 2023 08:14:43 -0000 1.65 +++ share/man/man5/resolv.conf.5 25 Sep 2024 23:46:34 -0000 @@ -96,6 +96,20 @@ entries are present, the default is to u (The algorithm used is to try a name server, and if the query times out, try the next, until out of name servers, then repeat trying all name servers until a maximum number of retries are performed.) +.Ic nameserver +entries can be specified for use by specific routing domains by adding +.Ic Cm rdomain Ar id +to the +.Ic nameserver +configuration. +For example: +.Pp +.Dl nameserver 192.168.0.1 rdomain 1 +.Pp +.Ic nameserver +statements without +.Ic Cm rdomain +will be used by all routing domains. .It Ic domain Local domain name. Most queries for names within this domain can use short names Index: lib/libc/asr/asr.c =================================================================== RCS file: /cvs/src/lib/libc/asr/asr.c,v diff -u -p -r1.68 asr.c --- lib/libc/asr/asr.c 20 Jan 2022 14:18:10 -0000 1.68 +++ lib/libc/asr/asr.c 25 Sep 2024 23:46:34 -0000 @@ -528,6 +528,7 @@ asr_ctx_create(void) return (NULL); ac->ac_options = RES_RECURSE | RES_DEFNAMES | RES_DNSRCH; + ac->ac_rdomain = -1; /* we don't care by default */ ac->ac_refcount = 1; ac->ac_ndots = 1; ac->ac_family[0] = AF_INET; @@ -594,12 +595,32 @@ pass0(char **tok, int n, struct asr_ctx int i, j, d; const char *e; struct sockaddr_storage ss; + int rdomain; + const char *errstr; if (!strcmp(tok[0], "nameserver")) { if (ac->ac_nscount == ASR_MAXNS) return; - if (n != 2) + switch (n) { + case 4: + if (strcmp(tok[2], "rdomain") != 0) + return; + + if (ac->ac_rdomain == -1) + ac->ac_rdomain = getrtable(); + + rdomain = strtonum(tok[3], 0, INT_MAX, &errstr); + if (errstr != NULL) + return; + + if (ac->ac_rdomain != rdomain) + return; + /* FALLTHROUGH */ + case 2: + break; + default: return; + } if (asr_parse_nameserver((struct sockaddr *)&ss, tok[1])) return; if ((ac->ac_ns[ac->ac_nscount] = calloc(1, ss.ss_len)) == NULL) Index: lib/libc/asr/asr_private.h =================================================================== RCS file: /cvs/src/lib/libc/asr/asr_private.h,v diff -u -p -r1.49 asr_private.h --- lib/libc/asr/asr_private.h 20 Nov 2023 12:15:16 -0000 1.49 +++ lib/libc/asr/asr_private.h 25 Sep 2024 23:46:34 -0000 @@ -121,6 +121,7 @@ enum async_type { #define ASR_DB_DNS 'b' struct asr_ctx { + int ac_rdomain; int ac_refcount; int ac_options; int ac_ndots;