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 / 问题 / 1475085
Accepted
CB_Ron
CB_Ron
Asked: 2023-06-28 04:57:23 +0800 CST2023-06-28 04:57:23 +0800 CST 2023-06-28 04:57:23 +0800 CST

Ubuntu server 22.04 如何从命令行确定正在使用哪个 DNS 服务器?

  • 772

我已经阅读了这里的链接。我从接受的答案中尝试了这个 nmcli device status ,但我得到了这个结果 sudo: nmcli: command not found。然后我读了这个链接。我尝试过, systemd-resolve --status | grep 'DNS Servers' 但得到了这个结果 sudo: systemd-resolve: command not found。

有谁知道可以在 22.04 上运行的命令吗?

networking
  • 1 1 个回答
  • 70 Views

1 个回答

  • Voted
  1. Best Answer
    mpboden
    2023-06-28T06:49:21+08:002023-06-28T06:49:21+08:00

    在 Ubuntu Server 22.04 中,网络由 systemd-networkd (而不是 NetworkManager)管理。使用 Netplan 配置网络设置

    DNS 名称解析由名为 systemd-resolved 的服务提供。它通过 D-Bus 接口、解析 NSS 服务 (nss-resolve(8)) 和 127.0.0.53 上的本地 DNS 存根侦听器提供 DNS 解析。如果运行命令 ,cat /etc/resolv.conf您将看到它列出 127.0.0.53 作为 DNS 服务器。这是本地存根解析器。

    $ cat /etc/resolv.conf
    # This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
    # Do not edit.
    #
    # This file might be symlinked as /etc/resolv.conf. If you're looking at
    # /etc/resolv.conf and seeing this text, you have followed the symlink.
    #
    # 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 should typically 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 localdomain
    

    当您运行命令 时ls -l /etc/resolv.conf,您将看到它链接到定义本地存根解析器的文件:

    $ ls -l /etc/resolv.conf
    lrwxrwxrwx 1 root root 37 Mar 20 10:16 /etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf
    

    这是正常行为。它在本地缓存 DNS 查询以进行解析。如果查询不在缓存中,那么它将查询通过 DHCP 提供的或在 Netplan 配置文件中手动定义的任何上行链路 DNS 服务器。要查看您的上行链路 DNS 服务器是什么,请运行resolvectl status:

    $ resolvectl status
    Global
           Protocols: -LLMNR -mDNS -DNSOverTLS
                      DNSSEC=no/unsupported
    resolv.conf mode: stub
    
    Link 2 (eth0)
    Current Scopes: none
         Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS
                    DNSSEC=no/unsupported
    
    Link 3 (eth1)
    Current Scopes: none
         Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS
                    DNSSEC=no/unsupported
    
    Link 4 (bond0)
        Current Scopes: DNS
             Protocols: +DefaultRoute +LLMNR -mDNS
                        -DNSOverTLS DNSSEC=no/unsupported
    Current DNS Server: 192.168.10.1
           DNS Servers: 192.168.10.1
            DNS Domain: localdomain
    
    • 2

相关问题

  • 如何设置 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