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

  • 相关阅读:
    Debezium报错处理系列之九十九:ConnectException: Source offset ‘file‘ parameter is missing
    Ubuntu:apt软件包管理工具
    CSS 计数器之 counter()
    【数据结构 二叉树 递归与非递归遍历】
    leetcode 刷题记录
    排列组合总结
    css溢出隐藏的五种方法
    ElasticSearch介绍和基本用法(一)
    7-2 友元类Cvector 武汉理工大学
    linux系统,确认账户密码正确
  • 原文地址:https://blog.csdn.net/liulilittle/article/details/134494212