0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

/etc/hosts と /etc/resolv.conf

0
Posted at

調べたこと

名前解決の方法について

  • /etc/hosts内のマッピングを見て解決する
  • スタブリゾルバ(glibc/resolvなど)が、DNSサーバーに問い合わせて解決する
    • DNSサーバーのアドレスは/etc/resolv.confに記されている。

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.142404:6800:4004:821::200eが得られた。

# nameserver 2001:268:98ef:5b3d::c3
nameserver 192.168.134.52

Ref.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?