惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - LiuYanYGZ

2025.04.15交通事故记录(沈阳、爸爸) 10KG、2KG盘称 摩托车贝纳利302S换机油 excel身份证号验证 在本机A中执行expect脚本:ssh到B,在B机器上从A机器scp文件到B 妈妈的药:血府逐瘀丸、天麻钩藤颗粒、半夏白术天麻汤、杞菊地黄丸、当归补血汤、糠酸莫米松凝胶、尿素维E乳膏 桂附地黄丸、舒筋活血片 辽宁省沈阳市居住证办理2026.01.21 北京健康证(立水桥地铁站附近)第二次去2025.12.28 鼻窦炎、鼻炎、花粉过敏 70迈M800后摄像头改装 D07线 京B摩托车第6年年检,《京顺机动车检测场》150元不用预约 source insight4菜单工具按钮变乱恢复 探索Go语言性能优化:全面解析pprof工具 检查一个IP地址是否在一个网段中 __attribute__((visibility(“default“)))含义 ls | tee 1.txt 如何拿到ls的返回值$? 使用golang访问linux telnet服务器 手机CPU性能天梯图 Poedit Pro国际化翻译编辑器 Proe和Creo的区别 Ubuntu中apt设置国内源(以阿里云为例) Ghidra(反汇编工具)
Ubuntu修改DNS方法(临时和永久修改DNS)
LiuYanYGZ · 2025-03-24 · via 博客园 - LiuYanYGZ

摘自:https://blog.csdn.net/weixin_44304605/article/details/135850791

Ubuntu 是我们常用的Linux系统,这不在选择海外云服务器的时候,由于默认的DNS适合海外线路,我们国内的用户访问的时候有些卡顿,这里我们较多的会更换DNS。这里我们准备好用的方法来修改DNS。

永久修改DNS方法

1、修改 /etc/systemd/resolved.conf 文件

vi /etc/systemd/resolved.conf

这里我们可以看到这些参数:

# 指定 DNS 服务器,以空白分隔,支持 IPv4 或 IPv6 位置
DNS=8.8.8.8 114.114.115.115
# 备用 DNS 服务器
FallbackDNS=8.8.8.8
# 设置搜索域名
Domains=domain.com
# 设置 LLMNR 是否激活,可用的选项有 yes、no、resolve
LLMNR=yes
# 设置 MulticastDNS 是否激活,可用的选项有 yes、no、resolve
MulticastDNS=yes
# 设置 DNSSEC 是否激活,可用的选项有 yes、no、allow-downgrade
DNSSEC=yes
# 设置缓存是否激活,可用的选项有 yes、no、no-negative
Cache=no-negative

根据需要修改 resolved.conf 文件中的DNS,然后保存。
2、重启 systemd-resolved 服务

systemctl restart systemd-resolved

3、设置开机启动 systemd-resolved 服务

systemctl enable systemd-resolved

4、备份 systemd-resolved 托管文件 resolv.conf

mv /etc/resolv.conf /etc/resolv.conf.bak

重新生成。

ln -s /run/systemd/resolve/resolv.conf /etc/

临时修改DNS方法

如果我们临时使用的话,也可以临时修改DNS。

修改下面文件:

vi /etc/resolv.conf

加入想要修改的DNS

nameserver 8.8.8.8
nameserver 8.8.4.4

如果多个DNS,就一行一个,修改之后保存退出即可;此方法修改后即刻生效,但重启后失效。