hagetak's blog

どうも、はげたかです。

vagrant ゲストOSで「Temporary failure in name resolution」が出るときの対処法

vagrant ゲストOSで「Temporary failure in name resolution」が出るときの対処法

vagrantを利用していて、外部URLに通信したときに、「Temporary failure in name resolution」「名前解決に一時的に失敗しました」というエラーが出たときの対処法です。

エラー内容再現

$ ping example.com
ping: example.com: Temporary failure in name resolution

解決法

エラー内容を見る限り、名前解決に失敗していることがわかる。ということで、Google が提供しているDNSサーバ に変更する。(https://securitysoft.asia/sougou/column/publicdns.php

sudo su - 
cp /etc/resolv.conf{,.org}
vim /etc/resolv.conf
diff /etc/resolv.conf{,.org}
3c3
< nameserver 8.8.8.8
---
> nameserver 10.0.2.3


cat /etc/resolv.conf
# Generated by NetworkManager
search search-mitty.com
nameserver 8.8.8.8
options single-request-reopen

ちなみに、10.0.2.3 とは

下記URLを見る限り、virtualboxが設定する、デフォルトのDNSサーバであり、

ホスト OS が参照している DNS キャッシュサーバー

であるとのこと。

https://fumiyas.github.io/vagrant/network.html

ping は通るようだが、なぜ名前解決に失敗したのかは不明。

ping 10.0.2.3
PING 10.0.2.3 (10.0.2.3) 56(84) bytes of data.
64 bytes from 10.0.2.3: icmp_seq=1 ttl=64 time=0.019 ms
64 bytes from 10.0.2.3: icmp_seq=2 ttl=64 time=0.277 ms

本解決法は、一時的であり、virtualbox, vagrantを利用している場合は、Vagrantfileを書き換えてあげるのが正しいと思う。

https://serverfault.com/questions/453185/vagrant-virtualbox-dns-10-0-2-3-not-working/506206

実践 Vagrant

実践 Vagrant