title: MacOS problem with DNS server (dnsmasq, resolver)
body: <p>Like every standard developer, I was using <code>/etc/hosts</code> to add new domains related to localhost. But today (because of project requirements and needs of wildcard for local domain) I tried to install and use <code>dnsmasq</code>.</p>
  <h1>System info</h1>
  <h2>Macos</h2>
  <p><code>macOs Monterey 12.5.1 (21G83)</code></p>
  <h2>dnsmasq (installed using brew)</h2>
  <pre><code>╰─ sudo /usr/local/opt/dnsmasq/sbin/dnsmasq --version
  Dnsmasq version 2.86  Copyright (c) 2000-2021 Simon Kelley
  Compile time options: IPv6 GNU-getopt no-DBus no-UBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack no-ipset auth no-cryptohash no-DNSSEC loop-detect no-inotify dumpfile
  
  This software comes with ABSOLUTELY NO WARRANTY.
  Dnsmasq is free software, and you are welcome to redistribute it
  under the terms of the GNU General Public License, version 2 or 3.
  </code></pre>
  <h1>Problem</h1>
  <p>When I tried to make <code>dnsmasq</code> work, I found a very strange thing.
  (Info below will be with disabled wifi. Wired internet connection direct to MacBook I do NOT have.)</p>
  <pre><code>dig example1 @127.0.0.1
  
  ; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; example1 @127.0.0.1
  ;; global options: +cmd
  ;; Got answer:
  ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 27361
  ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
  ;; WARNING: recursion requested but not available
  
  ;; QUESTION SECTION:
  ;example1.          IN  A
  
  ;; ANSWER SECTION:
  example1.       3600    IN  A   198.18.2.86
  
  ;; Query time: 0 msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  ;; WHEN: Thu Sep 22 16:03:12 EEST 2022
  ;; MSG SIZE  rcvd: 50
  
  dig example1.local @127.0.0.1
  
  ; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; example1.local @127.0.0.1
  ;; global options: +cmd
  ;; Got answer:
  ;; WARNING: .local is reserved for Multicast DNS
  ;; You are currently testing what happens when an mDNS query is leaked to DNS
  ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 3372
  ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
  ;; WARNING: recursion requested but not available
  
  ;; QUESTION SECTION:
  ;example1.local.            IN  A
  
  ;; ANSWER SECTION:
  example1.local.     3600    IN  A   198.18.2.87
  
  ;; Query time: 0 msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  ;; WHEN: Thu Sep 22 16:03:15 EEST 2022
  ;; MSG SIZE  rcvd: 62
  
  dig example2.local @127.0.0.1
  
  ; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; example2.local @127.0.0.1
  ;; global options: +cmd
  ;; Got answer:
  ;; WARNING: .local is reserved for Multicast DNS
  ;; You are currently testing what happens when an mDNS query is leaked to DNS
  ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 31079
  ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
  ;; WARNING: recursion requested but not available
  
  ;; QUESTION SECTION:
  ;example2.local.            IN  A
  
  ;; ANSWER SECTION:
  example2.local.     3600    IN  A   198.18.2.1
  
  ;; Query time: 0 msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  ;; WHEN: Thu Sep 22 16:03:20 EEST 2022
  ;; MSG SIZE  rcvd: 62
  
  dig example3.local @127.0.0.1
  
  ; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; example3.local @127.0.0.1
  ;; global options: +cmd
  ;; Got answer:
  ;; WARNING: .local is reserved for Multicast DNS
  ;; You are currently testing what happens when an mDNS query is leaked to DNS
  ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 22255
  ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
  ;; WARNING: recursion requested but not available
  
  ;; QUESTION SECTION:
  ;example3.local.            IN  A
  
  ;; ANSWER SECTION:
  example3.local.     3600    IN  A   198.18.2.3
  
  ;; Query time: 0 msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  ;; WHEN: Thu Sep 22 16:03:33 EEST 2022
  ;; MSG SIZE  rcvd: 62
  
  dig example3.dev @127.0.0.1
  
  ; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; example3.dev @127.0.0.1
  ;; global options: +cmd
  ;; Got answer:
  ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 43093
  ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
  ;; WARNING: recursion requested but not available
  
  ;; QUESTION SECTION:
  ;example3.dev.          IN  A
  
  ;; ANSWER SECTION:
  example3.dev.       3600    IN  A   198.18.2.4
  
  ;; Query time: 0 msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  ;; WHEN: Thu Sep 22 16:03:45 EEST 2022
  ;; MSG SIZE  rcvd: 58
  
  dig example4.dev @127.0.0.1
  
  ; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; example4.dev @127.0.0.1
  ;; global options: +cmd
  ;; Got answer:
  ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 22783
  ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
  ;; WARNING: recursion requested but not available
  
  ;; QUESTION SECTION:
  ;example4.dev.          IN  A
  
  ;; ANSWER SECTION:
  example4.dev.       3600    IN  A   198.18.2.88
  
  ;; Query time: 0 msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  ;; WHEN: Thu Sep 22 16:03:48 EEST 2022
  ;; MSG SIZE  rcvd: 58
  
  dig example2.dev @127.0.0.1
  
  ; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; example2.dev @127.0.0.1
  ;; global options: +cmd
  ;; Got answer:
  ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 49506
  ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
  ;; WARNING: recursion requested but not available
  
  ;; QUESTION SECTION:
  ;example2.dev.          IN  A
  
  ;; ANSWER SECTION:
  example2.dev.       3600    IN  A   198.18.2.89
  
  ;; Query time: 0 msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  ;; WHEN: Thu Sep 22 16:03:52 EEST 2022
  ;; MSG SIZE  rcvd: 58
  
  dig example2.localhost @127.0.0.1
  
  ; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; example2.localhost @127.0.0.1
  ;; global options: +cmd
  ;; Got answer:
  ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 23993
  ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
  ;; WARNING: recursion requested but not available
  
  ;; QUESTION SECTION:
  ;example2.localhost.        IN  A
  
  ;; ANSWER SECTION:
  example2.localhost. 3600    IN  A   198.18.2.90
  
  ;; Query time: 0 msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  ;; WHEN: Thu Sep 22 16:03:58 EEST 2022
  ;; MSG SIZE  rcvd: 70
  
  dig example3.localhost @127.0.0.1
  
  ; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; example3.localhost @127.0.0.1
  ;; global options: +cmd
  ;; Got answer:
  ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 36206
  ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
  ;; WARNING: recursion requested but not available
  
  ;; QUESTION SECTION:
  ;example3.localhost.        IN  A
  
  ;; ANSWER SECTION:
  example3.localhost. 3600    IN  A   198.18.2.91
  
  ;; Query time: 0 msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  ;; WHEN: Thu Sep 22 16:04:03 EEST 2022
  ;; MSG SIZE  rcvd: 70
  </code></pre>
  <p>Nmap when <code>dnsmasq</code> enabled:</p>
  <pre><code>nmap -p 53 127.0.0.1
  Starting Nmap 7.93 ( https://nmap.org ) at 2022-09-22 16:07 EEST
  Nmap scan report for localhost (127.0.0.1)
  Host is up (0.00017s latency).
  
  PORT   STATE  SERVICE
  53/tcp closed domain
  
  Nmap done: 1 IP address (1 host up) scanned in 0.03 seconds
  </code></pre>
  <p>Nmap when <code>dnsmasq</code> disabled:</p>
  <pre><code>nmap -p 53 127.0.0.1
  Starting Nmap 7.93 ( https://nmap.org ) at 2022-09-22 16:09 EEST
  Nmap scan report for localhost (127.0.0.1)
  Host is up (0.00016s latency).
  
  PORT   STATE SERVICE
  53/tcp open  domain
  
  Nmap done: 1 IP address (1 host up) scanned in 0.03 seconds
  </code></pre>
  <p>Files in resolver folder <code>/etc/resolver/</code> all with content <code>nameserver 127.0.0.1</code>:</p>
  <pre><code>.local
  .localhost
  dev
  local
  localhost
  test
  </code></pre>
  <pre><code>scutil --dns
  DNS configuration
  
  resolver #1
    flags    :
    reach    : 0x00000000 (Not Reachable)
  
  resolver #2
    domain   : local
    options  : mdns
    timeout  : 5
    flags    :
    reach    : 0x00000000 (Not Reachable)
    order    : 300000
  
  resolver #3
    domain   : 254.169.in-addr.arpa
    options  : mdns
    timeout  : 5
    flags    :
    reach    : 0x00000000 (Not Reachable)
    order    : 300200
  
  resolver #4
    domain   : 8.e.f.ip6.arpa
    options  : mdns
    timeout  : 5
    flags    :
    reach    : 0x00000000 (Not Reachable)
    order    : 300400
  
  resolver #5
    domain   : 9.e.f.ip6.arpa
    options  : mdns
    timeout  : 5
    flags    :
    reach    : 0x00000000 (Not Reachable)
    order    : 300600
  
  resolver #6
    domain   : a.e.f.ip6.arpa
    options  : mdns
    timeout  : 5
    flags    :
    reach    : 0x00000000 (Not Reachable)
    order    : 300800
  
  resolver #7
    domain   : b.e.f.ip6.arpa
    options  : mdns
    timeout  : 5
    flags    :
    reach    : 0x00000000 (Not Reachable)
    order    : 301000
  
  resolver #8
    domain   : test
    nameserver[0] : 127.0.0.1
    flags    : Request A records, Request AAAA records
    reach    : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
  
  resolver #9
    domain   : .local
    nameserver[0] : 127.0.0.1
    flags    : Request A records, Request AAAA records
    reach    : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
  
  resolver #10
    domain   : local
    nameserver[0] : 127.0.0.1
    flags    : Request A records, Request AAAA records
    reach    : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
  
  resolver #11
    domain   : .localhost
    nameserver[0] : 127.0.0.1
    flags    : Request A records, Request AAAA records
    reach    : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
  
  resolver #12
    domain   : dev
    nameserver[0] : 127.0.0.1
    flags    : Request A records, Request AAAA records
    reach    : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
    order    : 1
  
  resolver #13
    domain   : localhost
    nameserver[0] : 127.0.0.1
    flags    : Request A records, Request AAAA records
    reach    : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
  </code></pre>
  <p>So, the question is: Where and how I get IP address <code>192.168.2.*</code> instead of <code>127.0.0.1</code>? And how to replace it with <code>127.0.0.1</code>. I do not have anything starting with <code>192.168</code> in my network configs:</p>
  <pre><code>ifconfig | grep 192
  
  </code></pre>