networking - 如何在 Ubuntu 19.04 VirtualBox VM 上获得名称解析?

标签 networking virtual-machine virtualbox nat ubuntu-19.04

我在 Windows 7 主机上使用多个 VirtualBox Ubuntu 18.10/19.04 虚拟机。有那么一刻,其中一个名称解析停止工作。互联网连接仍然有效。

ax@buildvm:~$ ping 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=51 time=40.5 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=51 time=35.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=51 time=42.4 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=51 time=36.2 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 35.456/38.635/42.408/2.906 ms
ax@buildvm:~$ ping google.com
ping: google.com: Temporary failure in name resolution

如何让名称解析工作?


附加信息

ax@buildvm:~$ ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:fb:bc:af brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.5/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 947sec preferred_lft 947sec
    inet6 fe80::a00:27ff:fefb:bcaf/64 scope link
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:27:32:88 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.106/24 brd 192.168.56.255 scope global dynamic enp0s8
       valid_lft 947sec preferred_lft 947sec
    inet6 fe80::a00:27ff:fe27:3288/64 scope link
       valid_lft forever preferred_lft forever
ax@buildvm:~$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0
search fritz.box

VirtualBox-VM-Settings-Network-Adapter-1-NAT

最佳答案

This博客文章提供了解决方案:

$ sudo rm /etc/resolv.conf
$ sudo ln -s /var/run/systemd/resolve/resolv.conf /etc/resolv.conf
$ sudo systemctl restart systemd-resolved.service

关于networking - 如何在 Ubuntu 19.04 VirtualBox VM 上获得名称解析?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61443872/

相关文章:

networking - 尝试连接 samba 客户端时出现 NT_STATUS_IO_TIMEOUT

azure - 创建虚拟机、对其进行镜像并删除后,可用 vCPU 配额不足

linux - VirtualBox VM 中的 VirtualBox VM

sql-server - 将 SQL Server 添加到现有 Azure VM?

ruby - 使用 Veewee 创建 VirtualBox 时如何传输一些文件

php - 使用 laravel 拒绝 .composer/config 文件权限

docker - Traefik v2 不使用路径进行路由,而是使用 ip

android - 以编程方式切换 "Restrict Background Data"

android - 无法在 axios 上发出 POST 请求(React-Native)

python - Windows 上是否有 time.clock() 的替代精确计时器?