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 / 问题 / 1047735
Accepted
Sarke
Sarke
Asked: 2018-06-19 14:55:18 +0800 CST2018-06-19 14:55:18 +0800 CST 2018-06-19 14:55:18 +0800 CST

Ubuntu 18.04 无法识别来自路由器的主机名

  • 772

我之前安装了 Xubuntu 16.04,它确实识别了我的路由器(番茄)设置的主机名。

例如,我mate在网络上有一台名称为 的计算机,其静态 IP 为192.168.2.202,以前我可以这样做:

$ host mate                                                               
mate has address 192.168.2.202

但现在我明白了:

$ host mate
Host mate not found: 2(SERVFAIL)

这次我做了一个最小的桌面安装,所以我想知道我是否缺少某个包。

编辑:

$ cat /var/run/systemd/resolve/resolv.conf:
nameserver 192.168.2.1
$ cat /var/run/NetworkManager/resolv.conf
nameserver 127.0.0.53
$ netstat -antup
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:5000            0.0.0.0:*               LISTEN      3421/VBoxHeadless   
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      663/systemd-resolve 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      950/sshd            
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      737/cupsd              
tcp6       0      0 :::5900                 :::*                    LISTEN      3421/VBoxHeadless   
tcp6       0      0 :::22                   :::*                    LISTEN      950/sshd            
tcp6       0      0 ::1:631                 :::*                    LISTEN      737/cupsd           
udp    14784      0 0.0.0.0:52712           0.0.0.0:*                           2092/VirtualBox     
udp     8704      0 0.0.0.0:53789           0.0.0.0:*                           2092/VirtualBox     
udp     9536      0 0.0.0.0:5353            0.0.0.0:*                           730/avahi-daemon: r 
udp    19648      0 0.0.0.0:55126           0.0.0.0:*                           2092/VirtualBox     
udp     8704      0 0.0.0.0:39114           0.0.0.0:*                           2092/VirtualBox     
udp    13248      0 0.0.0.0:41109           0.0.0.0:*                           2092/VirtualBox     
udp        0      0 0.0.0.0:57555           0.0.0.0:*                           730/avahi-daemon: r 
udp     3648      0 0.0.0.0:59213           0.0.0.0:*                           2092/VirtualBox     
udp     8064      0 0.0.0.0:59519           0.0.0.0:*                           2092/VirtualBox     
udp     3648      0 0.0.0.0:48795           0.0.0.0:*                           2092/VirtualBox     
udp     3648      0 0.0.0.0:48900           0.0.0.0:*                           2092/VirtualBox     
udp    36096      0 127.0.0.53:53           0.0.0.0:*                           663/systemd-resolve 
udp    37120      0 0.0.0.0:68              0.0.0.0:*                           1066/dhclient       
udp    15424      0 0.0.0.0:33008           0.0.0.0:*                           2092/VirtualBox     
udp     3648      0 0.0.0.0:49597           0.0.0.0:*                           2092/VirtualBox     
udp    14464      0 0.0.0.0:33395           0.0.0.0:*                           2092/VirtualBox     
udp        0      0 0.0.0.0:631             0.0.0.0:*                           828/cups-browsed    
udp    19840      0 0.0.0.0:49883           0.0.0.0:*                           2092/VirtualBox     
udp    14592      0 0.0.0.0:33614           0.0.0.0:*                           2092/VirtualBox     
udp6       0      0 :::51356                :::*                                730/avahi-daemon: r 
udp6   49344      0 :::5353                 :::*                                730/avahi-daemon: r 
$ systemd-resolve --status
Global
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 6 (vboxnet2)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 5 (vboxnet1)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 4 (vboxnet0)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 3 (wlp4s1)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 2 (eno1)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 192.168.2.1

我的路由器是 192.168.2.1

编辑2:

使用dig表明路由器确实正确报告了主机名。

$ dig @192.168.2.1 mate    
; <<>> DiG 9.11.3-1ubuntu1.1-Ubuntu <<>> @192.168.2.1 mate
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47046
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;mate.              IN  A

;; ANSWER SECTION:
mate.           0   IN  A   192.168.2.202

;; Query time: 0 msec
;; SERVER: 192.168.2.1#53(192.168.2.1)
;; WHEN: Mon Jun 18 18:53:26 PDT 2018
;; MSG SIZE  rcvd: 38

但是如果我不特别提到路由器的DNS IP,我没有找到它。

$ dig mate             
; <<>> DiG 9.11.3-1ubuntu1.1-Ubuntu <<>> mate
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 65394
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

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

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Mon Jun 18 19:06:13 PDT 2018
;; MSG SIZE  rcvd: 33 

因此,即使它被列出,它似乎也/var/run/systemd/resolve/resolv.conf没有被使用。我该如何解决?

networking hosts router
  • 3 3 个回答
  • 10659 Views

3 个回答

  • Voted
  1. Best Answer
    Sarke
    2018-06-19T18:33:08+08:002018-06-19T18:33:08+08:00

    这似乎与这个问题有关:

    https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1624320

    在全新安装时,/etc/resolv.conf链接到/run/systemd/resolve/stub-resolv.conf而不是/run/systemd/resolve/resolv.conf.

    根据https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1624320/comments/8更新它修复了它。

    • 5
  2. cmak.fr
    2018-06-20T00:14:14+08:002018-06-20T00:14:14+08:00

    这是发生的事情: systemd-resolved 如果名称不是完全限定的名称,则不解析本地域名,如mate.local

    有关Systemd-networkd的文档中所述,一个好的解决方法是修剪/etc/nsswitch.conf文件

    sudo nano /etc/nsswitch.conf
    

    修改主机行

    # /etc/nsswitch.conf
    #
    # Example configuration of GNU Name Service Switch functionality.
    # If you have the `glibc-doc-reference' and `info' packages installed, try:
    # `info libc "Name Service Switch"' for information about this file.
    
    passwd:         compat systemd
    group:          compat systemd
    shadow:         compat
    gshadow:        files
    # ---- MODIFY THIS LINE ------------------------------------------------
    # hosts:          files mdns4_minimal [NOTFOUND=return] dns myhostname
    # ---- TO --------------------------------------------------------------
    hosts:          files mdns4_minimal dns myhostname
    # ---- THATS ALL -------------------------------------------------------
    networks:       files
    
    protocols:      db files
    services:       db files
    ethers:         db files
    rpc:            db files
    
    netgroup:       nis
    

    说明:
    主机名解析首先在文件(/etc/hosts)中搜索,然后使用 avahi(zeroconf),然后询问 dns 服务器。如果 avahi 没有[NOTFOUND=return]强制找到本地名称,请不要停止。希望它清楚。

    重启服务

    sudo systemctl restart systemd-resolved
    
    • 3
  3. yoyoma2
    2020-01-11T19:13:22+08:002020-01-11T19:13:22+08:00

    此错误报告评论中给出的解决方法为我的 Ubuntu 18.04 LTS 安装解决了这个问题。

    Disable and stop the systemd-resolved service:
    
    sudo systemctl disable systemd-resolved.service
    sudo systemctl stop systemd-resolved
    
    Then put the following line in the [main] section of your /etc/NetworkManager/NetworkManager.conf:
    
    dns=default
    
    Delete the symlink /etc/resolv.conf
    
    rm /etc/resolv.conf
    
    Restart network-manager
    
    sudo service network-manager restart
    
    • 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