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?

vagrant, virtualbox, centos8でdnfできなくなった際のdns変更

Last updated at Posted at 2025-09-15

事象

構築時には普通に使えていたVirtualBox上のcentosで、
dnfに失敗。

IPレイヤーでは問題なくインターネットへ出れているが、
名前解決に失敗。

[postgres@centos8pg14a ~]$ ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=12.6 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=11.0 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=9.87 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=117 time=21.8 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3011ms
rtt min/avg/max/mdev = 9.871/13.833/21.829/4.720 ms
[postgres@centos8pg14a ~]$ curl -v http://google.com
* Rebuilt URL to: http://google.com/
* Could not resolve host: google.com
* Closing connection 0
curl: (6) Could not resolve host: google.com
[postgres@centos8pg14a ~]$ 

対処1:DNS設定変更

[vagrant@centos8pg14a ~]$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 10.0.2.3
options single-request-reopen
[vagrant@centos8pg14a ~]$ sudo nmcli connection modify eth0 ipv4.dns 8.8.8.8
[vagrant@centos8pg14a ~]$ sudo systemctl restart NetworkManager
[vagrant@centos8pg14a ~]$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 10.0.2.3
nameserver 8.8.8.8
options single-request-reopen
[vagrant@centos8pg14a ~]$

マニュアルによるとVirtualBoxのNATとしてのネームサーバ。

9.6.1 Configuring the Address of a NAT Network Interface
In NAT mode, the guest network interface is assigned to the IPv4 range 10.0.x.0/24 
by default where x corresponds to the instance of the NAT interface +2. 
So x is 2 when there is only one NAT instance active. 
In that case the guest is assigned to the address 10.0.2.15, 
the gateway is set to 10.0.2.2 and the name server can be found at 10.0.2.3.

対処2:ホストOS再起動

[postgres@centos8pg14b ~]$ ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=9.31 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=11.2 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=9.61 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=117 time=9.75 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 9.306/9.967/11.199/0.732 ms
[postgres@centos8pg14b ~]$ curl -v http://google.com
* Rebuilt URL to: http://google.com/
*   Trying 142.250.198.14...
* TCP_NODELAY set
* Connected to google.com (142.250.198.14) port 80 (#0)
> GET / HTTP/1.1
> Host: google.com
> User-Agent: curl/7.61.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Location: http://www.google.com/
< Content-Type: text/html; charset=UTF-8
< Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-kObbAZ0v9RrynBVirp4ntQ' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
< Date: Mon, 15 Sep 2025 12:55:44 GMT
< Expires: Wed, 15 Oct 2025 12:55:44 GMT
< Cache-Control: public, max-age=2592000
< Server: gws
< Content-Length: 219
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
<
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
* Connection #0 to host google.com left intact
[postgres@centos8pg14b ~]$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 10.0.2.3
options single-request-reopen
[postgres@centos8pg14b ~]$

VirtualBoxのログ見てもDNSに関するエラー見つからず。
恐らく通信はホストOSまで到達して、
その後DNSの処理で異常なのだと思う。

上記の通り、DNS設定変更で迂回か、
DNSサービス再起動の意味合いで、
ホストOSの再起動で対処できた。

以上

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?