dnsmasq が .local アドレスを 127.0.0.1 にポイントできない

dnsmasq が .local アドレスを 127.0.0.1 にポイントできない

.local指すアドレス (test.local など)を取得したいのです127.0.0.1が、うまくいきません。最新の Ubuntu を使用しています。/etc/NetworkManager/NetworkManager.conf で、コメント アウトしてdns=dnsmasqから、 を実行しましたsudo service network-manager restart

次に、dnsmasq をインストールし、address=/local/127.0.0.1/etc/dnsmasq.d/mycustomfile に を追加して、 を実行しましたsudo service dnsmasq restart。 言及した以外には、他の変更は行っていません。

しかし、test.local にアクセスすると 127.0.0.1 に解決されず、その .local アドレスの ping も成功しません。 の内容が/etc/resolv.conf関係しているのかもしれません。これは単に私が変更しなかったデフォルトのだけです。

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 222.11.22.36
nameserver 222.11.22.37

これは、dnsmasq をデーモンとしてではなく実行したときの出力です。

$ sudo dnsmasq --no-daemon     
dnsmasq: started, version 2.68 cachesize 150
dnsmasq: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth
dnsmasq: reading /etc/resolv.conf
dnsmasq: using nameserver 222.11.22.37#53
dnsmasq: using nameserver 222.11.22.36#53
dnsmasq: read /etc/hosts - 9 addresses

dnsmasq が実行されている場合、/etc/resolv.conf は自動的に更新されます (dnsmasq が停止すると上記のエントリに戻ります)。

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1

この:

$ sudo nslookup test.local 127.0.0.1
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   test.local
Address: 127.0.0.1

しかし、localhost への ping はまだ機能しません。

dnsmasq が .local アドレスを解決するように動作させるには、何をする必要がありますか?

答え1

local少なくとも Ubuntu では、何らかの予約キーワードのようです。

  • address=/local/127.0.0.1-- 動作しません。
  • address=/loc/127.0.0.1-- 動作します。

答え2

dnsmasq は正常に起動しているようです。 dnsmasq が正しく動作しているかどうかをテストする必要がありますnslookup test.local 127.0.0.1

システムが dnsmasq を使用していることを確認するには、最初のオプションとして/etc/resolv.conf使用するように更新する必要があります。nameserver 127.0.0.1

dnsmasq で custo アップストリーム リゾルバ構成を使用することもできます--resolv-file=/etc/resolv.conf.dnsmasq

答え3

おそらく、avahi-daemon はドメイン「local」を使用しています。参照:

https://unix.stackexchange.com/questions/352237/avahi-daemon-and-local-domain-issues

答え4

自分のマシンを指すだけで、dnsmasq を使用して他のコンピュータの DNS 解決を制御したくない場合は、 にエントリを追加するだけで済みます。dnsmasq とその設定に対する変更をすべて元に戻し、先頭に次の内容が含まれている/etc/hostsことを確認することをお勧めします。/etc/hosts

127.0.0.1 localhost
127.0.1.1 mycomputername mycomputername.local anothername.local

computer1.local computer2.localこの後、mycomputername.local に ping すると、自分自身を指すようになります (実際には、127.0.1.1 で実行されている dnsmasq サーバーを指し、次に localhost を指します)。ネットワーク上の他のコンピューターのエントリを追加して、このマシン上でコンピューターをetc.として参照できるようにすることもできます。

192.168.1.31 computer1.local
192.168.1.32 computer2.local

dnsmasq で変更を元に戻せない場合は、 の後にエントリを追加できますlocalhostが、エントリ自体は削除または変更しないでくださいlocalhost。次のようになります。

127.0.0.1 localhost mycomputername mycomputername.local anothername.local

ところで、Ubuntu デスクトップで resolv.conf を変更する適切な方法は、タスクバーのネットワーク マネージャーを使用することです。Ubuntu サーバーで適切な方法は、 でdns-nameserverネットワーク デバイスの下にエントリを追加し/etc/network/interfaces、再起動するか、 を実行することですifdown eth0 && ifup eth0。 の警告にあるように/etc/resolv.conf、直接変更しないでください。設定に基づいて動的に書き込まれます/etc/network/interfaces

関連情報