首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >过了一段时间,Ubuntu不再从DNS-Server找到主机

过了一段时间,Ubuntu不再从DNS-Server找到主机
EN

Ask Ubuntu用户
提问于 2019-12-10 22:06:31
回答 1查看 620关注 0票数 0

由于几天,我有一个Raspberry Pi与dnsmasq设置为DNS服务器192.168.1.2在我的局域网。它可以帮助其他计算机根据名字找到服务器..。它工作得很好,除了我的Ubuntu18.04笔记本电脑,它似乎不知何故“忘了”服务器。

当笔记本电脑启动时,一开始一切正常。在命令行nslookup server.lan中,主机server.lan,ping server.lan都给出了正确的结果,并且在服务器上打开一个网页很好。

代码语言:javascript
复制
xeros@laptop:~ $ nslookup server.lan
Server:     127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
Name:   server.lan
Address: 192.168.1.3

然而,过了一段时间,它就停止工作了。从服务器打开网站时说找不到它,nslookup突然失败:

代码语言:javascript
复制
xeros@laptop:~ $ nslookup server.lan
Server:     127.0.0.53
Address:    127.0.0.53#53

** server can't find server.lan: NXDOMAIN

不过,DNS-服务器正在工作。我的智能手机或其他设备没有问题。另外,如果我指定DNS-Server,正确的答案将在我的Ubuntu膝上型计算机上返回:

代码语言:javascript
复制
xeros@laptop:~ $ nslookup server.lan 192.168.1.2
Server:     192.168.1.2
Address:    192.168.1.2#53

Non-authoritative answer:
Name:   server.lan
Address: 192.168.1.3

如果我重启笔记本电脑,一切都会好起来的。

我不知道为什么过了一段时间就失败了。有人知道会出什么问题吗?

根据请求编辑其他信息(在RPi DNS-服务器上执行):

代码语言:javascript
复制
pi@raspberry:~ $ ls -al /etc/resolv.conf
-rw-r--r-- 1 root root 47 Dec  8 16:43 /etc/resolv.conf
代码语言:javascript
复制
pi@raspberry:~ $ cat /etc/resolv.conf
# Generated by resolvconf
nameserver 127.0.0.1
代码语言:javascript
复制
pi@raspberry:~ $ cat /etc/systemd/resolved.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details

[Resolve]
#DNS=
#FallbackDNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
#Domains=
#LLMNR=yes
#DNSSEC=no
#Cache=yes
#DNSStubListener=udp

笔记本电脑也是如此:

代码语言:javascript
复制
xeros@laptop:~$ ls -al /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Mai  1  2018 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
代码语言:javascript
复制
xeros@laptop:~$ 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 "systemd-resolve --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
代码语言:javascript
复制
xeros@laptop:~$ cat /etc/systemd/resolved.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details

[Resolve]
#DNS=
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes
EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2019-12-11 15:02:26

在Ubuntu笔记本上试试这个..。这是我在AU上的另一个答案.

报告回来..。

我们需要检查您的DNS服务器(dnsmasq)在/etc/解析式中的options edns0是否有问题。

goes是一个指向三个位置之一的符号链接。做a:

ls -al /etc/resolv.conf #注意原始的符号链接设置

sudo cat /etc/resolv.conf #注意当前的文件内容

sudo rm -i /etc/resolv.conf #删除符号链接

sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf #新符号链接

sudo cat /etc/resolv.conf #注意当前的文件内容

使用以下方法重新测试DNS:

host -v www.booking.com | grep -i received #每次使用不同的网站

sudo rm -i /etc/resolv.conf #删除符号链接

根据结果,还可以尝试以下符号链接:

sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf #一个不同的符号链接

sudo cat /etc/resolv.conf #注意当前的文件内容

使用以下方法重新测试DNS:

host -v www.booking.com | grep -i received #每次使用不同的网站

sudo rm -i /etc/resolv.conf #删除符号链接

如果一个符号链接比另一个更好,那么暂时保持它。如果没有更好的方法,请将其设置为原来的:

sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf #重置为原始符号链接

票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1195274

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档