Ubuntu 18.04/20.04 LTS 操作系统设置静态DNS

1、nano /etc/systemd/resolved.conf

2、修改配置

使用DNS服务器:223.5.5.5 223.6.6.6 

[Resolve]
DNS=223.5.5.5 223.6.6.6

3、重启服务

systemctl restart systemd-resolved.service

4、查看解析文件

cat /run/systemd/resolve/resolv.conf

# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 223.5.5.5
nameserver 223.6.6.6
nameserver 183.221.253.100
# Too many DNS servers configured, the following entries may be ignored.
nameserver 61.139.2.69
search DHCP HOST
 

5、查看临时解析文件

nano /etc/resolv.conf

  GNU nano 4.8                                                                             /etc/resolv.conf                                                                                        
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53
search DHCP HOST
 

如果操作系统使用的临时配置的DNS服务器不是127.0.0.53,那就说明你需要把现在的 /etc/resolv.conf 文件删除,然后重新 ln -sf 建立一个 /run/systemd/resolve/resolv.conf 到 /etc/resolv.conf 文件的软链接。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值