What are the ways to persist DNS and SearchDomain settings? How to remove?
If I run scutil --dns
it shows these two resolvers (and a few others for *.in-addr.arpa addresses)
resolver #1
search domain[0] : 0.mydomain.com
nameserver[0] : 10.10.50.53
if_index : 15 (en0)
flags : Request A records
reach : 0x00000002 (Reachable)
resolver #2
domain : 0.mydomain.com
nameserver[0] : 10.10.10.53
flags : Supplemental, Request A records
reach : 0x00020002 (Reachable,Directly Reachable Address)
order : 101600
...
Both resolvers include one of my domains, and #2 has the wrong nameserver IP.
I don't have a search domain configured on *Settings -> Network -> Detail -> DNS, and my local DHCP server does not provide a searchdomain.
If I remove the invalid resolver with:
# sudo scutil
# get State:/Network/Service/[redacted, random numbers and letters]/DNS
# d.show
<dictionary> {
ServerAddresses : <array> {
0 : 10.10.10.53
}
SupplementalMatchDomains : <array> {
0 : 0.mydomain.com
}
}
remove State:/Network/Service/a09acf02331d4926/DNS
quit
Then, scutil --dns
shows the correct resolvers, without search domains.
resolver #1
nameserver[0] : 10.10.50.53
if_index : 15 (en0)
flags : Request A records
reach : 0x00000002 (Reachable)
resolver #2
domain : local
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 300000
...
After removing that key, everything works as expected. But that entry returns on every reboot.
What could be including this config? Where should I look at?
Edit: As suggested by @Allan, this ensures I`m not receiving the search domain setting from DHCP.
# ipconfig getpacket en0 | grep -i domain
domain_name_server (ip_mult): {10.10.50.53}
ipconfig getpacket enX | grep -i domain
where X is the integer of your active network connection. Post the output with an edit to the question. This will tell you what is being set by DHCP.