【Ubuntu】DNS设置不生效/重启被重置

devtools/2024/10/18 5:30:10/

/etc/resolv.conf 是一个链接,指向/run/systemd/resolve/stub-resolv.conf

ubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ ll /etc/resolv.conf 
lrwxrwxrwx 1 root root 39 Sep 30 14:40 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

这两个(resolv.confstub-resolv.conf)文件时间每次重启后会重新生成,所以单纯修改/etc/resolv.conf 后续会被覆盖

ubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ ll
total 8
drwxr-xr-x  2 systemd-resolve systemd-resolve 120 Sep 30 18:10 ./
drwxr-xr-x 23 root            root            580 Sep 30 18:11 ../
srw-rw-rw-  1 systemd-resolve systemd-resolve   0 Sep 30 18:10 io.systemd.Resolve=
srw-------  1 systemd-resolve systemd-resolve   0 Sep 30 18:10 io.systemd.Resolve.Monitor=
-rw-r--r--  1 systemd-resolve systemd-resolve 930 Sep 30 18:10 resolv.conf
-rw-r--r--  1 systemd-resolve systemd-resolve 920 Sep 30 18:10 stub-resolv.conf

resolvectl status用来查看当前DNS

ubuntu@VM-4-13-ubuntu:/opt$ sudo resolvectl status
GlobalProtocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupportedresolv.conf mode: stubLink 2 (eth0)Current Scopes: DNSProtocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 183.60.83.19DNS Servers: 183.60.83.19 183.60.82.98Link 3 (docker0)Current Scopes: noneProtocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupportedLink 10 (br-ef5110e42154)Current Scopes: noneProtocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

查询了一些资料说是修改sudo vi /etc/systemd/resolved.conf 这个文件

[Resolve]
DNS=8.8.8.8 114.114.114.114

我修改后重启,resolv.conf这个文件的内容是修改了的,但是的stub-resolv.conf的内容还是没有修改,但是/etc/resolv.conf 是指向stub-resolv.conf的,所以我改了一下链接的引用让他指向/run/systemd/resolve/resolv.conf

ubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ sudo rm /etc/resolv.conf
ubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.confubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ ll /etc/resolv.conf 
lrwxrwxrwx 1 root root 32 Sep 30 14:46 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf

resolvectl status查看一下就出来了配置的DNS

ubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ resolvectl status
GlobalProtocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupportedresolv.conf mode: uplinkDNS Servers: 8.8.8.8 114.114.114.114Link 2 (eth0)Current Scopes: DNSProtocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupportedDNS Servers: 183.60.83.19 183.60.82.98Link 3 (docker0)Current Scopes: noneProtocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupportedLink 4 (br-ef5110e42154)Current Scopes: noneProtocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

这样就关联上了,但还有些疑惑不太明白,后面再学习~
1.自动生成的机制是怎么样的?
2.Global的 resolv.conf mode: stub ==> resolv.conf mode: uplink,这里受什么控制?


http://www.ppmy.cn/devtools/119590.html

相关文章

1、深入理解Redis线程模型

文章目录 一、Redis是什么?有什么用?1、Redis是什么?2、2024年的Redis是什么样的? 二、Redis到底是单线程还是多线程?三、Redis如何保证指令原子性1、复合指令2、Redis事务3、Pipeline4、lua脚本5、Redis Function6、R…

Spring系列 AOP实现过程

文章目录 实现原理EnableAspectJAutoProxyAnnotationAwareAspectJAutoProxyCreator 代理创建过程wrapIfNecessarygetAdvicesAndAdvisorsForBeanfindCandidateAdvisorsfindAdvisorsThatCanApply createProxy AspectJ注解处理代理调用过程 实现原理 本文源码基于spring-aop-5.3.…

针对GNU/Linux synology_apollolake_418play下的删除数据脚本

1、目的 一个在 Linux 下的 Bash 脚本,用于每三年删除 /volume1 目录下的文件以及子文件夹下的文件。这个脚本假设你已经有了判断时间间隔是否为三年的方法(比如上述提到的通过记录上一次执行时间并进行比较的方法)。 2、操作 1&#xff09…

Python从入门到高手4.1节-掌握条件控制语句

目录 4.1.1 理解条件控制 4.1.2 if, elif, else 4.1.3 条件表达式 4.1.4 条件控制可以嵌套 4.1.5 if语句的三元运算 4.1.6 国庆节快乐 4.1.1 理解条件控制 在日常生活中,我们常喜欢说如果, "如果怎么样,那么就会怎么样"。"如果&qu…

基于单片机的催眠电路控制系统

** 文章目录 前言一 概要功能设计设计思路 软件设计效果图 程序文章目录 前言 💗博主介绍:✌全网粉丝10W,CSDN特邀作者、博客专家、CSDN新星计划导师,一名热衷于单片机技术探索与分享的博主、专注于 精通51/STM32/MSP430/AVR等单片机设计 主…

如何给一张图像判断失真类型?

判断失真类型 类型 类型 模糊失真: 表现:图像细节不清晰,边缘模糊,整体看起来像是被一层薄雾笼罩。 原因:可能是由对焦不准确、相机抖动、快门速度过慢或景深过浅等原因造成。 判断方法:观察图像中的细节是…

小川科技携手阿里云数据库MongoDB:数据赋能企业构建年轻娱乐生态

随着信息技术的飞速发展,企业在处理海量数据时所面临的挑战日益严峻。特别是在年轻娱乐领域,用户行为的多样性和数据量的激增对数据存储与分析技术提出了更高的要求。在此背景下,小川凭借其前瞻性的技术视野,选择了MongoDB作为其数…

互斥量mutex、锁、条件变量和信号量相关原语(函数)----很全

线程相关知识可以看这里: 线程控制原语(函数)的介绍-CSDN博客 进程组、会话、守护进程和线程的概念-CSDN博客 1.同步概念 所谓同步,即同时起步,协调一致。不同的对象,对“同步”的理解方式略有不同。如,设备同步,是…