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

ubuntu18 修改dns服务器地址为google

域名解析被干扰的有点严重,直接使用谷歌dns服务器来解析ip

第一、永久修改DNS方法

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

vi  /etc/systemd/resolved.conf

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

# 指定 DNS 服务器,以空白分隔,支持 IPv4 或 IPv6 位置
DNS=8.8.8.8 114.114.114.114
# 备用 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,然后保存。
我的配置是

#  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=8.8.8.8 114.114.114.114
FallbackDNS=8.8.4.4
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
Cache=no
#DNSStubListener=yes

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,就一行一个,修改之后保存退出即可;此方法修改后即刻生效,但重启后失效。

清理现有dns缓存

sudo systemd-resolve --flush-caches
sudo systemctl restart systemd-resolved

查看现在的dns

 cat /etc/resolv.conf
http://www.lryc.cn/news/93769.html

相关文章:

  • RHCE shell 作业一
  • Qqis中采用栅格工具生成XYZ瓦片(目录)简介
  • 【Axure教程】根据标签数自动调整尺寸的多选下拉列表
  • 【python】js逆向基础案例——有道翻译
  • 面经系列.飞猪 Java开发工程师.杭州.2023.6.14一面面经
  • 基于物联网及云平台的光伏运维系统
  • Android kotlin 实现仿京东多个item向左自动排队(横向、动手滑动、没有首尾滑动)功能
  • 美团买菜基于 Flink 的实时数仓建设
  • 前端vue入门(纯代码)08
  • Xubuntu22.04之便签工具(一百八十)
  • Unity入门4——重要组件与API
  • NFS服务器安装及NFS制备程序安装
  • matlab+yalmip+cplex求解车辆路径优化问题(VRP)--matlab中yalmip函数介绍
  • 实战:用dockerfile创建镜像实现springboot项目容器化
  • 【Flask】配置项解析与加载
  • Dinky: 实时即未来,让 Flink SQL 纵享丝滑--如何本地编译、运行
  • 2023 Nature 健康系统规模的语言模型是通用预测引擎
  • 《2023 年 React 生态》
  • 武职302303笔记-day01
  • Python面试高频100题【11~15题】
  • Linux下Redis 存储
  • QML 快速上手3 - QuickControl2
  • QT Creator写一个简单的电压电流显示器
  • 前端需要的技能
  • Qt——Qt控件之基于模型的项目视图组-QTreeView树形视图控件的使用总结(Qt仿word标题列表的实现)
  • spring boot框架步骤
  • 动态创建select
  • linux-centos7操作系统查看系统未挂载的磁盘,挂载磁盘
  • STM32软件定时器
  • [论文阅读] (30)李沐老师视频学习——3.研究的艺术·讲好故事和论点