AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1072099
Accepted
Laurence Gonsalves
Laurence Gonsalves
Asked: 2018-09-05 10:31:23 +0800 CST2018-09-05 10:31:23 +0800 CST 2018-09-05 10:31:23 +0800 CST

如何设置 systemd-resolved 的搜索路径?

  • 772

手册页systemd-resolved.service说:

systemd-resolved维护/run/systemd/resolve/stub-resolv.conf文件以与传统的 Linux 程序兼容。该文件可能是从 /etc/resolv.conf. 此文件将 127.0.0.53 DNS 存根(见上文)列为唯一的 DNS 服务器。它还包含一个正在使用的搜索域列表 systemd-resolved。搜索域列表始终保持最新。

(强调我的。)“搜索域列表始终保持最新”似乎暗示该列表是从其他地方同步的,但没有说明在哪里。这个搜索域列表来自哪里?特别是,我该如何修改它?

dns systemd-resolved 18.04
  • 2 2 个回答
  • 13469 Views

2 个回答

  • Voted
  1. Francis Swasey
    2019-12-21T05:56:45+08:002019-12-21T05:56:45+08:00

    在我的 18.04.3 系统上, man resolved.conf 说要修改 /etc/systemd/resolved.conf 文件的 Domains= 行。摘录如下:

    Domains=
               A space-separated list of domains. These domains are used as search suffixes when resolving single-label host names
               (domain names which contain no dot), in order to qualify them into fully-qualified domain names (FQDNs). Search
               domains are strictly processed in the order they are specified, until the name with the suffix appended is found. For
               compatibility reasons, if this setting is not specified, the search domains listed in /etc/resolv.conf are used
               instead, if that file exists and any domains are configured in it. This setting defaults to the empty list.
    
               Specified domain names may optionally be prefixed with "~". In this case they do not define a search path, but
               preferably direct DNS queries for the indicated domains to the DNS servers configured with the system DNS= setting
               (see above), in case additional, suitable per-link DNS servers are known. If no per-link DNS servers are known using
               the "~" syntax has no effect. Use the construct "~."  (which is composed of "~" to indicate a routing domain and "."
               to indicate the DNS root domain that is the implied suffix of all DNS domains) to use the system DNS server defined
               with DNS= preferably for all domains.
    

    完成此操作并重新启动 systemd-resolved 后,我的 /etc/resolv.conf 现在包含我希望的搜索域(因为我已在此 Ubuntu 服务器上配置了静态地址 - 它不会从 DHCP 获取任何内容)

    • 8
  2. Best Answer
    Laurence Gonsalves
    2018-09-05T11:18:56+08:002018-09-05T11:18:56+08:00

    搜索路径从 DHCP 更新。在我的路由器中,此设置称为“域名”。

    为了更新搜索路径,我在路由器中设置了域,然后在我的 Ubuntu 机器上更新了 DHCP 租约(service network-manager restart或重新启动)。

    systemd-resolve --status然后将此域显示为“DNS 域”,它将/run/systemd/resolve/stub-resolv.conf作为search指令显示。

    注意该dig命令默认不使用搜索列表/etc/resolv.conf。添加+search选项以启用此功能:

    dig +search some-hostname
    
    • 2

相关问题

  • 将服务器从 DHCP 切换到静态 IP

  • “.local”有什么作用?

  • 如何在学校网络上配置域名[关闭]

  • 更改DNS IP的正确方法是什么?

  • 如何清除 DNS 缓存?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve