前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >影响ubuntu18.04系统DNS的几个因素

影响ubuntu18.04系统DNS的几个因素

作者头像
zd123
发布2021-07-29 14:49:31
6420
发布2021-07-29 14:49:31
举报
文章被收录于专栏:日知录日知录

1、resolv.conf

/etc/resolv.conf 文件里面的dns服务器是实时生效的,发现ubuntu18.04和Centos系列的差别很大,ubuntu18.04是个软链接并建议不要去修改;centos系列是个配置文件,可以直接修改使用。

2、resolvconf 默认软链接

代码语言:javascript
复制
user@ubuntu:~$ ls -lh /etc/resolv.conf 
lrwxrwxrwx 1 root root 27 10月 22  2018 /etc/resolv.conf -> /run/resolvconf/resolv.conf

user@ubuntu:~$ netstat -tulpn|grep 53
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -                   
udp        0      0 127.0.0.53:53           0.0.0.0:*                           -   

user@ubuntu:~$ 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 114.114.114.114
nameserver 127.0.0.53

user@ubuntu:~$ cat /run/resolvconf/interface/eth0.inet 
nameserver 114.114.114.114  
mogo@mogo-desktop:~$ cat /run/resolvconf/interface/systemd-resolved 
nameserver 127.0.0.53

3、systemd-resloved 修改软链接

代码语言:javascript
复制
user@ubuntu:~$ ls -lh /etc/resolv.conf 
lrwxrwxrwx 1 root root 27 10月 22  2018 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf

user@ubuntu:~$ 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=192.168.1.1
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes


user@ubuntu:~$ 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.1.1


user@ubuntu:~$ 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 "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

4、network-manager(图形界面)/network(服务器) 图形界面时可以直接桌面修改dns。如果不是图形界面直接network服务控制的/etc/network/interfaces配置文件dns-nameservers参数可以配置。经过测试,以上所有服务都开启时,systemd-resolved优先级大于network-manager。 综上可以推荐使用第三个systemd-resloved服务的软链接,通过修改/etc/systemd/resolved.conf配置文件来定义dns服务器,默认该服务是开机启动的。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档