Using scutil to set DNS for specific domains I'm trying to resolve only example1.com and example2.com using a custom DNS server. I've read that scutil could come in handy, but after doing the following, the system-wide DNS is still used:

sudo scutil
&gt; open
&gt; d.init
&gt; d.add ServerAddresses * 198.35.23.2 198.32.56.32
&gt; d.add DomainName example1.com
&gt; set State:/Network/Service/PRIMARY_SERVICE_ID/DNS
&gt; quit


Am I missing something?
I would not recommend scutil for this -- it's hard to understand and hard to use (and I'm not sure what the commands you've done so far actually do, but I'm pretty sure it's not what you want).  The "standard" way to configure custom resolution policies for specific domains is to create a /etc/resolver directory, and then put file(s) in it named for the domain(s) you want the policies applied to. See man 5 resolver and this web page for more info.

In you case, this would mean creating both /etc/resolver/example1.com and /etc/resolver/example2.com, both containing this:

nameserver 198.35.23.2
nameserver 198.32.56.32


Note: I haven't tested this in a while, but I assume it still works. Also, note that changing /etc/resolv.conf does not change the system resolver's behavior; it's just there for compatibility with unix-heritage tools that depend on it.