域名解析被干擾的有點(diǎn)嚴(yán)重,直接使用谷歌dns服務(wù)器來解析ip
第一、永久修改DNS方法
1、修改 /etc/systemd/resolved.conf 文件
vi /etc/systemd/resolved.conf
這里我們可以看到這些參數(shù):
# 指定 DNS 服務(wù)器,以空白分隔,支持 IPv4 或 IPv6 位置
DNS=8.8.8.8 114.114.114.114
# 備用 DNS 服務(wù)器
FallbackDNS=8.8.8.8
# 設(shè)置搜索域名
Domains=domain.com
# 設(shè)置 LLMNR 是否激活,可用的選項(xiàng)有 yes、no、resolve
LLMNR=yes
# 設(shè)置 MulticastDNS 是否激活,可用的選項(xiàng)有 yes、no、resolve
MulticastDNS=yes
# 設(shè)置 DNSSEC 是否激活,可用的選項(xiàng)有 yes、no、allow-downgrade
DNSSEC=yes
# 設(shè)置緩存是否激活,可用的選項(xiàng)有 yes、no、no-negative
Cache=no-negative
根據(jù)需要修改 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 服務(wù)
systemctl restart systemd-resolved
3、設(shè)置開機(jī)啟動(dòng) systemd-resolved 服務(wù)
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/
第二、臨時(shí)修改DNS方法
如果我們臨時(shí)使用的話,也可以臨時(shí)修改DNS。
修改下面文件:
vi /etc/resolv.conf
加入想要修改的DNS文章來源:http://www.zghlxwxcb.cn/news/detail-501337.html
nameserver 8.8.8.8
nameserver 8.8.4.4
如果多個(gè)DNS,就一行一個(gè),修改之后保存退出即可;此方法修改后即刻生效,但重啟后失效。文章來源地址http://www.zghlxwxcb.cn/news/detail-501337.html
清理現(xiàn)有dns緩存
sudo systemd-resolve --flush-caches
sudo systemctl restart systemd-resolved
查看現(xiàn)在的dns
cat /etc/resolv.conf
到了這里,關(guān)于ubuntu18 修改dns服務(wù)器地址為google的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!