AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1357086
Accepted
sancho.s ReinstateMonicaCellio
sancho.s ReinstateMonicaCellio
Asked: 2021-08-10 23:54:25 +0800 CST2021-08-10 23:54:25 +0800 CST 2021-08-10 23:54:25 +0800 CST

为什么同一网络中的两个 Ubuntu 系统在 DNS 解析中表现不同?

  • 772

编辑(tl;博士)

我似乎在这里确定了部分问题,因为至少/etc/resolv.conf和相关文件的差异已经消失。

但我仍然无法通过 WiFi 连接,因此其他差异可能仍然存在。

我的意思是识别这些,并采取行动。


我故意选择了与此 OP相同的标题。我有两个 Ubuntu 系统,server1并且server2在各方面都非常相似。两者都通过 WiFi 连接到同一个路由器。我通过比较两个系统来帮助跟踪问题。

在server2,我刚开始遇到 DNS 名称解析问题。我已连接到 VPN,并且服务器已重新启动,所以我猜这个 PostScriptum可能会描述这种情况。 server2没有resolvconf,我安装了它作为结果。当时/etc/resolv.conf开始指向/run/resolvconf/resolv.conf(注意下面的修改日期),而不是/run/systemd/resolve/stub-resolv.conf. 为此,我必须在顶部手动添加/etc/resolv.conf名称服务器 8.8.8.8 ,插入有线互联网连接,我可以立即sudo apt update等。注意:截至目前,上面链接中引用的文件权限问题不存在. 如果下次我连接/断开 VPN 时出现,我会处理它。

我在下面列出:1)和中的不同之处server1,server22)两者中的相同之处(any替换服务器名称),以及 3)几乎相同的地方(据我了解,有不相关的差异)。

为什么DIFFERENCE #3在下面?( nameserver ::1)。 如果可能,
如何通过保留与 ? 相同的配置来修复? server2server1 我可以尝试修改/etc/resolvconf/resolv.conf.d/tailin server2,但由于该文件在server1此操作中为空,因此即使成功,也可能会掩盖其他问题。

我想如果我只能修复下面的 DIFFERENCES #1-4,那将解决问题。但是所有 4 个文件都被引用为动态创建的。我找不到谁负责/负责“创造”差异,以及如何解决这个问题。

不同的

dig:

[server1]$ dig google.com

; <<>> DiG 9.16.1-Ubuntu <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64202
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;google.com.            IN  A

;; ANSWER SECTION:
google.com.     94  IN  A   216.58.202.46

;; Query time: 36 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: mar ago 10 03:44:51 -03 2021
;; MSG SIZE  rcvd: 55

对比

[server2]$ dig google.com

; <<>> DiG 9.16.1-Ubuntu <<>> google.com
;; global options: +cmd
;; connection timed out; no servers could be reached

/etc/resolv.conf及相关文件:

[server1]$ cat /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
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53
search fibertel.com.ar                                     <--- DIFFERENCE #1

[server1]$ cat /run/systemd/resolve/stub-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 trust-ad
search fibertel.com.ar                                     <--- DIFFERENCE #2

[server1]$ cat /run/systemd/resolve/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 directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# 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 192.168.0.1                                     <--- DIFFERENCE #3
search fibertel.com.ar                                     <--- DIFFERENCE #3

[server1]$ cat /run/resolvconf/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
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53
search fibertel.com.ar                                     <--- DIFFERENCE #4

[server1]$ ll /etc/resolv.conf 
lrwxrwxrwx 1 root root 29 feb  1  2021 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
[server1]$ ll /run/resolvconf/resolv.conf
-rw-r--r-- 1 root root 327 ago  9 20:59 /run/resolvconf/resolv.conf

对比

[server2]$ cat /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
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53

[server2]$ cat /run/systemd/resolve/stub-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 trust-ad

[server2]$ cat /run/systemd/resolve/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 directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# 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 ::1                                     <--- DIFFERENCE #3

[server2]$ cat /run/resolvconf/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
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53

[server2]$ ll /etc/resolv.conf
lrwxrwxrwx 1 root root 29 ago  9 22:38 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
[server2]$ ll /run/resolvconf/resolv.conf
-rw-r--r-- 1 root root 304 ago 10 03:13 /run/resolvconf/resolv.conf

相同的

[any]$ uname -a
Linux <serverN> 5.11.0-25-generic #27~20.04.1-Ubuntu SMP Tue Jul 13 17:41:23 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

[any]$ dpkg -l | grep resolvconf
ii  resolvconf                                    1.82                                all          name server information handler

[any]$ cat /etc/netplan/01-network-manager-all.yaml 
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

[any]$ cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no

[any]$ cat /etc/hosts
127.0.0.1   localhost
127.0.1.1   <serverN>

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

[any]$ cat /etc/nsswitch.conf
...
[any]$ cat /etc/systemd/networkd.conf 
...
[any]$ ss -plnt | grep ':53'
LISTEN   0        4096       127.0.0.53%lo:53            0.0.0.0:* 
[any]$ sudo systemctl status resolvconf.service
...
[any]$ /lib/systemd/network/
...

差不多一样

[server1]$ lsb_release -a
LSB Version:    core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal

[server2]$ lsb_release -a
LSB Version:    core-11.1.0ubuntu2-noarch:printing-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal

相关:

  1. DNS 设置为 systemd 的 127.0.0.53 - 如何永久更改?
networking
  • 1 1 个回答
  • 277 Views

1 个回答

  • Voted
  1. Best Answer
    chili555
    2021-08-11T06:18:54+08:002021-08-11T06:18:54+08:00

    文件 /etc/resolv.conf 旨在成为 /run/systemd/resolve/stub-resolv.conf 的符号链接 检查:

    ls -al /etc/resolv.conf
    

    如果不是,请更正:

    sudo rm /etc/resolv.conf
    sudo ln -s /run/systemd/resolve/stub-resolv.conf  /etc/resolv.conf
    

    您的 netplan yaml 文件表明您正在运行网络管理器。这是对 DNS 名称服务器进行更改的地方。

    在此处输入图像描述

    • 1

相关问题

  • 如何设置 VLAN 转发?

  • 如何将主机 Ubuntu 上的 VPN (tun0) 网络适配器映射到 VirtualBox 来宾 Windows?

  • 如何限制下载/上传带宽?

  • 如何通过 Windows 网络共享文件?

  • 面板小程序以文本形式显示当前网络流量?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve