当前位置: 首页 > article >正文

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

/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
Global
         Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: stub

Link 2 (eth0)
    Current Scopes: DNS
         Protocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 183.60.83.19
       DNS Servers: 183.60.83.19 183.60.82.98

Link 3 (docker0)
    Current Scopes: none
         Protocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

Link 10 (br-ef5110e42154)
    Current Scopes: none
         Protocols: -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.conf

ubuntu@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
Global
         Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: uplink
       DNS Servers: 8.8.8.8 114.114.114.114

Link 2 (eth0)
    Current Scopes: DNS
         Protocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
       DNS Servers: 183.60.83.19 183.60.82.98

Link 3 (docker0)
    Current Scopes: none
         Protocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

Link 4 (br-ef5110e42154)
    Current Scopes: none
         Protocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

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


http://www.kler.cn/news/336258.html

相关文章:

  • 基于SpringBoot+Vue的科研课题项目管理系统源码
  • MQ 架构设计原理与消息中间件详解(三)
  • bus中设备驱动的probe触发逻辑和device、driver的添加逻辑
  • Vue83 引入elementUI
  • CSS 布局——清除浮动 (二)
  • hutool bug
  • 核心理论框架对比:如何通过TOGAF实现企业数字化转型的全面战略
  • javaweb-分层解耦
  • 接口怎么返回文件或数据流,@RequestMapping注解里面的属性项有哪些
  • 计算机组成原理(笔记6阵列乘法器、补码阵列乘法器)
  • Nuxt.js 应用中的 app:beforeMount 钩子详解
  • 18年408数据结构
  • 论文笔记:微表情欺骗检测
  • FineReport 11 在线学习
  • INS风格时尚自拍人像摄影后期Lr调色,手机滤镜PS+Lightroom预设下载!
  • Android阶段学习思维导图
  • pytorch中的TensorDataset和DataLoader
  • 红外画面空中目标检测系统源码分享
  • LeetCode讲解篇之139. 单词拆分
  • JS模块化工具requirejs详解