調べたこと
名前解決の方法について
-
/etc/hosts内のマッピングを見て解決する - スタブリゾルバ(
glibc/resolvなど)が、DNSサーバーに問い合わせて解決する- DNSサーバーのアドレスは
/etc/resolv.confに記されている。
- DNSサーバーのアドレスは
hosts, resolv.conf の2種類の名前解決の優先順位を/etc/nsswitch.confで指定する。ref
/etc/resolv.conf について
以下のよう。ネットワーク環境に応じて、動的に生成される。
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
# scutil --dns
#
# SEE ALSO
# dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
nameserver 2001:268:98ef:5b3d::c3
nameserver 192.168.134.52
この例だと、nameserverは、IPv4のものとIPv6のものの二つが記されている。
なお、「IPv4のネームサーバーによる名前解決時に返されるIPアドレスの配列に、IPv4のアドレスとIPv6のアドレスの両方が含まれる」ことはありうる。
例えば、以下のように/etc/resolv.confを書き換えてgoogle.comを名前解決すると、142.251.222.14と2404:6800:4004:821::200eが得られた。
# nameserver 2001:268:98ef:5b3d::c3
nameserver 192.168.134.52
Ref.