3

I'm trying to change the default DNS server on my macos laptop. What I have:

% scutil --dns

DNS configuration

resolver #1 search domain[0] : example.com nameserver[0] : aa.bb.cc.dd.ee flags : Request A records reach : 0x00000002 (Reachable) order : 50000

resolver #2 domain : local options : mdns timeout : 5 flags : Request A records reach : 0x00000000 (Not Reachable) order : 300000

... <CUT> ...

DNS configuration (for scoped queries)

resolver #1 search domain[0] : lan nameserver[0] : 192.168.1.1 if_index : 6 (en0) flags : Scoped, Request A records reach : 0x00020002 (Reachable,Directly Reachable Address)

The goal is to replace default/global/primary (how does it called properly?) resolver #1: search domain[0] : example.com and nameserver[0] : aa.bb.cc.dd.ee with anything else, for example 8.8.8.8.

What has been done so far:

  • editing /etc/resolv.conf, obviously didn't help much, except maybe for ping and nslookup.
  • tried https://superuser.com/a/86188/927968 solution, which has no visible effect. At least, scutil --dns didn't show any change
  • tried https://superuser.com/a/86245/927968, but this nicely changes DNS configuration (for scoped queries) not the upper main/global/primary section.

So, am I stuck. Could you please, explain, what I am doing wrong and how to achieve the goal.

Gringo Suave
  • 1,394

1 Answers1

4

How about

Find the network services with:

$ networksetup -listallnetworkservices

Ethernet USB 10/100/1000 LAN Thunderbolt Bridge Wi-Fi

then for each service

$ sudo networksetup -setdnsservers <networkservice> empty
$ sudo networksetup -setdnsservers <networkservice> 8.8.8.8 9.8.4.4

Flush or Reset DNS Cache

$ sudo killall -HUP mDNSResponder; sleep 2; echo macOS DNS Cache Reset | say
Pat
  • 3,048