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 文件的软链接。

你可能感兴趣的:(Extension,ubuntu,linux,运维)