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

【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
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,这里受什么控制?

相关文章:

  • TypeSctipt学习第二篇
  • uni-app之旅-day01-home页
  • 第18周 3-过滤器
  • 关于公司小程序项目在登录流程获取token并全局使用的梳理(学习篇)
  • 【从零开始实现stm32无刷电机FOC】【实践】【7.1/7 硬件设计】
  • 25 基于51单片机的温度电流电压检测系统(压力、电压、温度、电流、LCD1602)
  • MongoDB入门
  • 第十三届蓝桥杯真题Python c组D.数位排序(持续更新)
  • A Learning-Based Approach to Static Program Slicing —— 论文笔记
  • web应用合规(一)双因子认证2FA解决方案
  • 音视频通话 SDK
  • 数据结构——队列的基本操作
  • [leetcode] 70. 爬楼梯
  • 前端工程化之vite
  • 汽修行业的知识库搭建:赋能在线教育与知识付费
  • [数据结构]链表的实现在PHP中
  • 【140天】尚学堂高淇Java300集视频精华笔记(86-87)
  • 【译】React性能工程(下) -- 深入研究React性能调试
  • 3.7、@ResponseBody 和 @RestController
  • ECMAScript入门(七)--Module语法
  • gcc介绍及安装
  • javascript面向对象之创建对象
  • javascript数组去重/查找/插入/删除
  • leetcode46 Permutation 排列组合
  • maya建模与骨骼动画快速实现人工鱼
  • mysql_config not found
  • Netty源码解析1-Buffer
  • Node.js 新计划:使用 V8 snapshot 将启动速度提升 8 倍
  • spark本地环境的搭建到运行第一个spark程序
  • underscore源码剖析之整体架构
  • 回流、重绘及其优化
  • 使用 Docker 部署 Spring Boot项目
  • 手写双向链表LinkedList的几个常用功能
  • 一个普通的 5 年iOS开发者的自我总结,以及5年开发经历和感想!
  • 用 vue 组件自定义 v-model, 实现一个 Tab 组件。
  • kubernetes资源对象--ingress
  • 分布式关系型数据库服务 DRDS 支持显示的 Prepare 及逻辑库锁功能等多项能力 ...
  • ​软考-高级-信息系统项目管理师教程 第四版【第14章-项目沟通管理-思维导图】​
  • # 执行时间 统计mysql_一文说尽 MySQL 优化原理
  • ######## golang各章节终篇索引 ########
  • #{} 和 ${}区别
  • $.each()与$(selector).each()
  • (2022 CVPR) Unbiased Teacher v2
  • (55)MOS管专题--->(10)MOS管的封装
  • (php伪随机数生成)[GWCTF 2019]枯燥的抽奖
  • (Python第六天)文件处理
  • (超简单)使用vuepress搭建自己的博客并部署到github pages上
  • (二十三)Flask之高频面试点
  • (附源码)springboot建达集团公司平台 毕业设计 141538
  • (每日一问)基础知识:堆与栈的区别
  • (三) diretfbrc详解
  • (学习日记)2024.01.09
  • (转)http协议
  • .gitignore文件忽略的内容不生效问题解决
  • .NET Conf 2023 回顾 – 庆祝社区、创新和 .NET 8 的发布