亚马逊 - Day 1

选品 选品的原则 多SKU / 多新款 品牌并不重要 品牌集中度低 推荐品类 玩具 优点 SKU多 新款多 风险 易侵权 MRO ( Maintenance, Repair, and Operations) 维修件 风险 专利侵权 可能需要铺货(大批量上传产品) 单品销售量(PCS)低 装饰品 风险 专利侵权 店铺关联 重点:一个公司一个店铺 强关联 IP 公司信息 弱关联 品牌授权 法人姓名 站点选择 日 墨 德 法 消费力高 欧洲站点注意欧盟合规问题 VAT 进口 VAT 进口 VAT = (头程运费+申报货值+关税)×VAT税率 举例 头程运费 2欧 申报货值 10欧 关税 0.5欧 VAT税率 20% 进口 VAT = (2 + 10 + 0.5) × 20% = 2.5 × 20% = 0.5欧 ...

June 11, 2025

亚马逊 - Day 2

选品 目标 市场需求 市场上已经有了什么产品,哪些是我能拿起来就卖,并且卖得了的,我就卖。 错误思维 产品单一化

June 11, 2025

CSS 重温 - Day 1

选择器 标签选择器 <h1>标题</h1> h1 { color: blue; } 类选择器 <div class="header"> <h1>标题</h1> </div> .header { color: blue; } ID选择器 <div id="header"> <h1>标题</h1> </div> #header { color: blue; } 组合选择器 /* 会同时选中所有 h1 和 .special */ <h1 class="title">标题1</h1> <h1 class="title">标题2</h1> <div class="special"></div> h1, .special { color: blue; } 属性选择器 li[class] {/* 选择所有有 class 属性的 li 标签 */} li[class="a"] {/* 选择 class 属性值为 "a" 的 li 标签 */} li[class~="a"] {/* 选择 class 属性值包含 "a类" 的 li 标签 */} li[class|="zh"] {/* 选择 class 属性值以 "zh" 开头并且后面跟随一个连字符'-'的 li 标签 */} li[class^="a"] {/* 选择 class 属性值以 "a" 开头的 li 标签 */} li[class$="a"] {/* 选择 class 属性值以 "a" 结尾的 li 标签 */} li[class*="a"] {/* 选择 class 属性值包含 "a" 的 li 标签 */} 关系选择器 article p {/* 选择 article 下的所有 p 元素 */} article > p {/* 选择 article 下的直接子元素 p 元素, 不会选中嵌套的 p 元素 */} h1 + p { /* 选择 h1 元素的下一个兄弟元素 p 元素, 会选中紧接着 h1 的 p 元素 */ <article> <h1>A heading</h1> <p> Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic. </p> <p> Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini. </p> </article> } article ~ p { /* 选择 article 元素之后的所有兄弟元素 p 元素, 会选中下方所有的 p 元素 */ <article> <h1>A heading</h1> <p>I am a paragraph.</p> <div>I am a div</div> <p>I am another paragraph.</p> </article> } 伪类和伪元素 常用伪类 article p:first-child { /* 选择 article 下第一个 p 元素 */} article p:last-child { /* 选择 article 下最后一个 p 元素 */} article p:nth-child(2) { /* 选择 article 下第二个 p 元素 */} 伪元素 article p:first-child::first-line {/* 选择 article 下的第一个 p 元素的第一行 */} p::first-line {/* 选择 p 元素的第一行 */} p::first-letter { /* 选择 p 元素的第一个字符 */ font-size: 200%; color: red; } p::before { content: "前缀"; /* 在 p 元素前插入内容 */ } p::after { /* 在 p 元素后插入内容 */ content: "后缀"; } 盒模型 用display属性来控制盒子的显示类型。 ...

June 8, 2025

unbound 配置文件中文文档

unbound.conf(5) unbound 1.23.0 unbound.conf(5) NAME unbound.conf - Unbound 配置文件. SYNOPSIS unbound.conf DESCRIPTION unbound.conf 用于配置 unbound(8)。文件格式包含属性和值。某些属性内部包含其他属性。表示法为:attribute: value。 注释以 # 开头,并持续到行尾。空行和行首的空白将被忽略。 可以使用 unbound-checkconf(8) 工具在使用前检查 unbound.conf。 EXAMPLE 下面显示了一个示例配置文件。将其复制到 /etc/unbound/unbound.conf 并使用以下命令启动服务器: $ unbound -c /etc/unbound/unbound.conf 大多数设置都是默认值。使用以下命令停止服务器: $ kill `cat /etc/unbound/unbound.pid` 下面是一个最小的配置文件。源代码发行版包含一个带有所有选项的 extensive example.conf 文件。 # unbound.conf(5) unbound(8) 的配置文件。 server: directory: "/etc/unbound" username: unbound # 确保 unbound 可以从 chroot 内部访问熵。 # 例如在 Linux 上使用这些命令(在 BSD 上,使用 devfs(8)): # mount --bind -n /dev/urandom /etc/unbound/dev/urandom # 并且 mount --bind -n /dev/log /etc/unbound/dev/log chroot: "/etc/unbound" # logfile: "/etc/unbound/unbound.log" #取消注释以使用日志文件。 pidfile: "/etc/unbound/unbound.pid" # verbosity: 1 # 取消注释并增加以获取更多日志记录。 # 监听所有接口,应答来自本地子网的查询。 interface: 0.0.0.0 interface: ::0 access-control: 10.0.0.0/8 allow access-control: 2001:DB8::/64 allow FILE FORMAT 关键字之间必须有空格。属性关键字以冒号“:”结尾。 属性后面跟着一个值,或者包含它的属性(在这种情况下它被称为一个子句)。 子句可以在整个文件(或包含的文件)中重复,以将属性分组到同一个子句下。 可以使用 include: 指令包含文件。 它可以出现在任何地方,接受单个文件名作为参数。 处理将继续,就好像被包含文件中的文本被复制到配置文件的那个位置一样。 如果同时使用 chroot,则使用被包含文件的完整路径名有效; 如果守护进程启动的目录等于其 chroot/工作目录,或者在 include 语句之前用 directory: dir 指定了工作目录, 则被包含文件的相对路径名也有效。 可以使用通配符包含多个文件,请参阅 glob(7)。 对于更结构化的包含选项,可以使用 include-toplevel: 指令。 这将关闭当前活动的任何子句(如果有),并强制在被包含的文件中以及此指令之后使用子句。 Server Options 这些选项属于服务器配置中的`server:`部分。 verbosity: <number> 详细程度等级,0级表示无详细信息,仅显示错误。 1级提供操作信息。 2级则包含详细的操作信息,每条查询都有简短说明。 3级深入到查询层面,逐条输出查询信息。 4级揭示算法层面的信息。 5级记录缓存未命中时的客户端标识。 默认级别为1。详细程度也可通过命令行提升,详见unbound(8)手册。 statistics-interval: <seconds> 打印统计信息到日志的间隔秒数,针对每个线程。 设置为0或""以禁用此功能,默认情况下是禁用的。 直方图统计信息仅在统计间隔期间有回复发送时才会打印, 而请求列表统计信息则会在每个间隔打印(但可能为0)。 这是因为中位数计算需要存在数据。 statistics-cumulative: <yes or no> 若启用此选项,统计信息将自Unbound启动起累计, 且在记录统计后不清除统计计数器。默认设置为`no`。 extended-statistics: <yes or no> 若启用,将从unbound-control(8)打印扩展统计信息。 默认设置为`no`,因为跟踪更多统计信息需要时间。 计数器在unbound-control(8)中列出。 statistics-inhibit-zero: <yes or no> 若启用,值为0的选定扩展统计信息将被抑制 不会在unbound-control(8)中打印。这些包括 查询类型、查询类、查询操作码、回答rcodes(除了 NOERROR、FORMERR、SERVFAIL、NXDOMAIN、NOTIMPL、REFUSED)和RPZ 操作。默认设置为`yes`。 num-threads: <number> 创建用于服务客户端的线程数量。若无需多线程,请设置为1。 port: <port number> 服务器响应查询的端口号,默认为53。 interface: <ip address or interface name [@port]> 用于连接网络的接口。此接口用于监听来自客户端的查询, 并从中向客户端提供响应。可多次指定以在多个接口上工作。 若未指定,则默认监听本地主机。若使用接口名称而非IP地址, 则采用该接口上的所有IP地址列表。在重新加载(kill -HUP)时, 接口不会变更,仅重启时生效。可通过@端口号(接口与端口号间无空格)指定端口, 未指定时则使用默认端口(来自port设置)。 ip-address: <ip address or interface name [@port]> 与 interface 相同:(以便于与nsd.conf兼容)。 interface-automatic: <yes or no> 监听所有(当前及未来)接口上的所有地址, 检测UDP查询的源接口并将其复制到回复中。 这与ip-transparent非常相似,但此选项服务于所有接口, 而使用ip-transparent时,您可以选择Unbound在哪些(未来)接口上提供服务。 此功能尚处于实验阶段,需要您的操作系统支持特定的套接字选项。 默认值为`no`。 interface-automatic-ports: <string> 列出interface-automatic监听的端口号。 若为空,则默认监听默认端口。 端口号在字符串中以空格分隔,默认值为""。 此设置可用于让interface-automatic处理接口, 并通过在列表中包含正常端口号来监听该端口, 同时也可通过将HTTPS或DNS over TLS的端口号加入列表,实现对它们的监听。 outgoing-interface: <ip address or ip6 netblock> 用于连接网络的接口。 此接口用于向权威服务器发送查询并接收其回复。 可多次指定以在多个接口上工作。 若未指定,则默认使用所有接口。 您可以在`interface:`和`outgoing-interface:`行中指定相同的接口, 这些接口将同时用于两种目的。 为防止欺骗,出站查询会通过随机选择的出站接口发送。 若指定的是IPv6网段而非单个IPv6地址, 则外发的UDP查询将采用从该网段中随机选取的源地址,以应对欺骗攻击。 此功能要求该IPv6网段需路由至运行Unbound的主机, 并且操作系统需支持非特权非本地绑定(目前仅Linux支持)。 可通过多个`outgoing-interface:`选项指定多个网段, 但切勿同时指定单个IPv6地址与IPv6网段,否则随机化机制将失效。 建议结合`prefer-ip6: yes`使用,以提高选择IPv6域名服务器进行查询的可能性。 在Linux系统上,需执行以下两条命令, 以便利用`freebind`套接字选项接收指定IPv6网段的流量: `ip -6 addr add 你的网段/64 dev lo && ip -6 route add local 你的网段/64 dev lo`。 outgoing-range: <number> 要打开的端口数量。 每个线程可打开的文件描述符数量至少为1,默认值取决于编译选项。 较大的数值需要操作系统提供额外资源。 为了获得最佳性能,建议设置一个非常大的值,并利用libevent来实现这一目标。 outgoing-port-permit: <port number or range> 允许 Unbound 打开此端口或端口范围,用于发送查询。 允许更多的出站端口能增强抵御欺骗攻击的能力。 请确保这些端口不被其他守护进程占用。 默认情况下,仅使用 IANA 未分配的 1024 以上端口。 请提供一个端口号或“低-高”形式的范围,中间不要有空格。 `outgoing-port-permit` 和 `outgoing-port-avoid` 语句按照配置文件的顺序逐行处理, 将允许的端口加入并从允许的端口集合中减去避免的端口。 处理开始时,允许的端口集合包含非 IANA 分配的、高于 1024 的端口。 outgoing-port-avoid: <port number or range> 不允许Unbound打开此端口或端口范围用于发送查询。 使用此选项可确保Unbound不会占用其他守护进程所需的端口。 该端口在所有出站接口上均被避开,包括IPv4和IPv6。 默认情况下,仅使用IANA未分配的1024以上端口。 请提供一个端口号或“低-高”形式的范围,中间不要有空格。 outgoing-num-tcp: <number> 为每个线程分配的外发TCP缓冲区数量。 默认值为10。 若设置为0,或当do-tcp为“否”时,将不会向权威服务器发送TCP查询。 对于较大规模的部署,建议适当增加此值。 incoming-num-tcp: <number> 为每个线程分配的入站TCP缓冲区数量。 默认值为10。若设置为0,或当do-tcp为“否”时,将不会接受来自客户端的TCP查询。 对于较大规模的部署,建议适当增加此值。 edns-buffer-size: <number> 作为EDNS重组缓冲区大小通告的字节数。 此值用于通过UDP向对等方发送的数据报中。 实际缓冲区大小由msg-buffer-size决定(适用于TCP和UDP)。 请勿设置高于该值。默认值为1232,这是2020年DNS标志日的推荐值。 设置为512可以规避最严格的路径MTU问题,但被视为极端做法, 因为由此产生的TCP回退量过大(可能也适用于此解析器,建议调整出站TCP数量)。 max-udp-size: <number> 最大UDP响应大小(不适用于TCP响应)。 65536表示禁用UDP响应大小上限,始终采用客户端的选择。 建议值范围为512至4096。 默认值为1232,该默认值与edns-buffer-size的默认设置相同。 stream-wait-size: <number> 用于等待流缓冲区的最大字节数。默认值为4兆字节。 纯数字表示字节,可附加'k'、'm'或'g'分别表示千字节、兆字节或吉字节(1兆字节为1024*1024字节)。 由于TCP和TLS流会排队多个结果,这些缓冲区占用的内存总量不会超过此数值,否则将丢弃响应。 此设置用于管理服务器在高负载下的总内存使用量,同时每个连接上可排队的请求数量也受到限制, 额外的请求将在TCP缓冲区中等待。 msg-buffer-size: <number> 消息缓冲区的字节大小,默认设置为65552字节, 足以容纳64Kb的数据包,这是DNS消息的最大尺寸。 任何超过此大小的消息都无法发送或接收。 为了节省内存,可以减小此值,但某些对DNS数据的请求, 如针对大型资源记录的查询,可能会导致向客户端返回SERVFAIL(服务失败)响应。 msg-cache-size: <number> 消息缓存的大小字节数,默认值为4兆字节。 纯数字表示字节数,可附加'k'、'm'或'g'分别表示千字节、兆字节或吉字节(1兆字节等于1024*1024字节)。 msg-cache-slabs: <number> 消息缓存中的分片数量。分片通过减少线程间的锁争用来提升性能。 必须设置为2的幂次方。将其设置为接近CPU核心数的值是一个合理的估计。 num-queries-per-thread: <number> 每个线程同时处理的查询数量。若需服务的查询超出此限, 且无法通过竞争超时机制(参见jostle-timeout)移除已有查询,则新查询将被丢弃。 此举促使客户端在超时后重新发送请求,为服务器留出时间处理现有查询。 默认值依据编译选项而定,通常为512或1024。 jostle-timeout: <msec> 当服务器非常繁忙时使用的超时设置。该值通常设定为能确保一次往返权威服务器的时长。 若查询请求过多,则允许50%的查询完成执行,而另外50%若已超出其允许时间,则会被新到达的查询替换。 此机制旨在防止因慢查询或高查询率导致的服务拒绝。 默认值为200毫秒。 其效果是,对于耗时较长的查询,其每秒查询率(qps)大约为(每线程查询数/2)除以(此类长查询的平均时间)。 而对于短查询,其qps可达到(每线程查询数/2)除以(以整秒计的jostletimeout), 默认情况下约为(1024/2)* 5 = 2560 qps每线程。 delay-close: <msec> 在UDP端口因超时被关闭前,额外延迟时间以毫秒计。 默认值为0,即不启用此功能。 此设置旨在防止来自上游(递归)服务器的延迟响应数据包撞击已关闭的端口, 从而触发各种关闭端口的计数器,例如1500毫秒。 当发生超时时,系统需要额外的套接字来检查数据包的ID和远程IP, 不符合条件的数据包将被计入无效数据包计数器。 udp-connect: <yes or no> 为UDP套接字执行连接操作,以减轻ICMP侧信道泄露风险。默认设置为`yes`。 unknown-server-time-limit: <msec> 等待未知服务器响应的毫秒时间。 若您处于较慢的卫星链路环境下,可适当增加此值,例如设为1128毫秒。 这样能避免因超时导致每次初始查询都需要重新发起。默认值为376毫秒。 discard-timeout: <msec> 递归请求被丢弃的等待时间,以毫秒计。 此举旨在防止大量回复堆积。 这些请求不会收到回复,工作项将继续递归。 如果启用了服务过期客户端超时,建议此值稍大一些。 建议值为1900毫秒。值为0则禁用此功能。默认值为1900毫秒。 wait-limit: <number> 每个IP地址可等待递归回复的数量。 这为每个IP地址设置了等待递归回复的速率限制,防止大量查询积压等待返回至单一目的地。 若值为0,则禁用等待限制。默认值为1000。 wait-limit-cookie: <number> 对于发送带有有效DNS Cookie查询的IP地址,可等待递归处理的回复数量。 由于Cookie验证了客户端地址,此限制可适当提高,默认值为10000。 wait-limit-netblock: <netblock> <number> 网段等待限制。若未指定,则采用默认的等待限制值。 系统会根据最具体的网段来确定限制,这对于为特定组、个人或服务器覆盖默认设置非常有用。 值为-1时,表示该网段无等待限制。 默认情况下,回环地址的等待限制网段为-1,即不受限,因为它与网络其他部分隔离,防止伪造数据包。 回环地址127.0.0.0/8和::1/128默认设置为-1。 wait-limit-cookie-netblock: <netblock> <number> 当查询带有DNS cookie时,针对网段的等待限制。 若未指定,则采用wait-limit-cookie的值。值为-1时,该网段无等待限制。 默认情况下,回环地址127.0.0.0/8和::1/128的等待限制设置为-1。 so-rcvbuf: <number> 如果非零,则设置SO_RCVBUF套接字选项,以在UDP端口53的入站查询上获取更多缓冲区空间。 这样,在繁忙服务器上的短暂流量高峰不会导致丢包(参见netstat -su中的计数器)。 默认值为0(使用系统值)。否则,指定请求的字节数,在繁忙服务器上可尝试“4m”。 操作系统会设定一个上限, 在Linux上,Unbound需要root权限才能突破此限制,或者管理员可以使用sysctl net.core.rmem_max进行调整。 在BSD系统中,需修改/etc/sysctl.conf中的kern.ipc.maxsockbuf。 在OpenBSD上,需更改头文件并重新编译内核。 在Solaris上,使用ndd -set /dev/udp udp_max_buf 8388608进行设置。 so-sndbuf: <number> 若非0,则设置SO_SNDBUF套接字选项,以在UDP端口53的对外查询中获取更多缓冲区空间。 这对于非常繁忙的服务器而言,能有效应对应答流量的突发高峰, 否则可能会记录“发送:资源暂时不可用”的错误,且通过netstat -su也能观察到缓冲区溢出的情况。 默认值为0(使用系统设定值)。指定请求的字节数,在极其繁忙的服务器上可尝试“4m”。 操作系统会设定一个上限, 在Linux上,Unbound需要root权限才能突破此限制,或者管理员可以使用sysctl net.core.wmem_max进行调整。 在BSD和Solaris系统中,更改方式与so-rcvbuf类似。 so-reuseport: <yes or no> 若选择`yes`,则为每个线程开启专用的监听套接字以接收查询, 并尝试在每个套接字上设置SO_REUSEPORT选项。 此举可能更均匀地分配查询至各线程。 默认设置为`yes`。 在Linux系统中,此功能支持内核版本>=3.9。 其他系统如FreeBSD、OSX也可能适用。您可在任何平台及内核上启用此功能, 系统将尝试打开端口并在编译时若该选项可用则传递之; 若成功则使用,失败则静默继续(除非详细级别为3),不采用该选项。 在极高负载情况下,关闭此选项可能更利于查询的均匀分配,此现象在Linux系统(4.4.x版本)中有报告。 ip-transparent: <yes or no> 如果是,则在Unbound监听入站流量的套接字上使用IP_TRANSPARENT套接字选项。 默认情况下为`no`。此选项允许您绑定到非本地接口, 例如,对于将来会存在但目前不存在的IP地址,配合主机故障转移配置使用。 这与interface-automatic非常相似,但后者服务于所有接口, 而通过此选项,您可以选择Unbound将在哪些(未来)接口上提供服务。 在某些系统上,此选项需要Unbound以root权限启动。 在FreeBSD系统上,该选项使用IP_BINDANY,在OpenBSD系统上则使用SO_BINDANY。 ip-freebind: <yes or no> 如果是,则在监听未绑定地址的套接字上使用IP_FREEBIND选项。 默认情况下为`no`。此选项允许您绑定到非本地或不存在的IP地址,例如当网络接口或IP地址不可用时。 该选项仅存在于Linux系统中,同时也可使用类似的ip-transparent选项。 ip-dscp: <number> 传出IP数据包头中区分服务字段(DS)内的区分服务代码点(DSCP)值。 该字段取代了过时的IPv4服务类型字段及IPv6流量类别字段。 rrset-cache-size: <number> RRset缓存的大小以字节数计,默认值为4兆字节。 纯数字表示字节,可附加'k'、'm'或'g'分别表示千字节、兆字节或吉字节(1兆字节等于1024*1024字节)。 rrset-cache-slabs: <number> RRset缓存中的slab数量。slab通过减少线程间的锁争用来提升性能。必须设置为2的幂次方。 cache-max-ttl: <seconds> RRsets和消息在缓存中的最大生存时间(TTL),默认值为86400秒(1天)。 当TTL到期时,缓存项即视为过期。 可通过设置更低的TTL值,强制解析器频繁查询数据,而不依赖(过大的)TTL值。 下游客户端同样会看到这一较低的TTL设置。 cache-min-ttl: <seconds> RRsets和消息在缓存中的最小生存时间。默认值为0。 若启用最小值,数据将被缓存超过域名所有者预期的时间,从而减少查询次数以查找数据。 设置为零确保缓存中的数据符合域名所有者的意图, 而较高的值,尤其是超过一小时左右,可能导致缓存数据与实际数据不再匹配,从而引发问题。 cache-max-negative-ttl: <seconds> 负响应的生存时间上限,这些响应在授权部分包含一个时间受限的SOA记录。 默认值为3600秒。此设置适用于nxdomain(域名不存在)和nodata(无数据)类型的应答。 cache-min-negative-ttl: <seconds> 负面响应的最小生存时间,这些响应在权威部分包含一个有时间限制的SOA记录。 默认值为0(禁用)。如果此功能被禁用且配置了cache-min-ttl,则后者将生效。 在这种情况下,您可以将其设置为1以遵循上游的TTL。 此设置适用于nxdomain和nodata类型的应答。 infra-host-ttl: <seconds> 主机缓存中条目的生存时间。该缓存包含往返时间、故障状态及EDNS支持信息。默认值为900。 infra-cache-slabs: <number> 基础设施缓存中的slab数量。slab通过减少线程间的锁争用来提升性能,必须设置为2的幂次方。 infra-cache-numhosts: <number> 缓存信息的主机数量,默认值为10000。 infra-cache-min-rtt: <msec> 基础设施缓存中动态重传超时计算的下限值,默认设置为50毫秒。 若使用需更长时间进行递归名称解析的转发器,请适当增加此值。 infra-cache-max-rtt: <msec> 基础设施缓存中动态重传超时计算的上限值,默认设置为2分钟。 infra-keep-probing: <yes or no> 若启用此功能,服务器将持续对已宕机的主机进行探测,采用一次一探的模式。 默认设置为`no`。 对于已宕机的主机,例如在单次探测期间未响应者,将被标记为宕机状态, 并可能需要等待 infra-host-ttl 时间后才会再次被探测。 define-tag: <"list of tags"> 定义可与本地区域(local-zone)和访问控制(access-control)一同使用的标签。 将列表用引号("")括起,并在标签之间留出空格。 do-ip4: <yes or no> 启用或禁用是否响应或发起ip4查询。默认设置为`yes`。 do-ip6: <yes or no> 启用或禁用是否响应或发起IPv6查询。默认设置为`yes`。 若禁用,则不会在IPv6上响应查询,也不会通过IPv6向互联网域名服务器发送查询。 此选项可用于关闭IPv6传输以发送DNS流量,但不会影响DNS流量的内容,其中可能包含IPv4和IPv6地址。 prefer-ip4: <yes or no> 若启用此选项,将优先使用IPv4传输向互联网域名服务器发送DNS查询。 默认设置为`no`。 当服务器所在的IPv6网段(整个/64)并非由单一运营商所有, 且该网段/64的信誉存在问题时,此选项尤为有用, 此时使用IPv4可利用上游服务器已有的IPv4过滤机制。 prefer-ip6: <yes or no> 若启用,将优先使用IPv6传输向互联网域名服务器发送DNS查询。默认设置为否。 do-udp: <yes or no> 启用或禁用是否响应或发起UDP查询。默认设置为`yes`。 do-tcp: <yes or no> 启用或禁用TCP查询的应答与发起,默认设置为`yes`。 tcp-mss: <number> 服务器响应查询时,TCP套接字的最大段大小(MSS)。 设置低于以太网常见MSS的值(例如1220)可解决路径MTU问题。 需注意,并非所有平台都支持通过套接字选项设置MSS(TCP_MAXSEG)。 默认情况下,MSS由接口MTU及服务器与客户端之间的协商决定,采用系统默认值。 outgoing-tcp-mss: <number> TCP套接字用于发出查询(从Unbound到其他服务器)的最大段大小(MSS)。 设置低于以太网常见MSS的值(例如1220)可解决路径MTU问题。 需要注意的是,并非所有平台都支持通过套接字选项设置MSS(TCP_MAXSEG)。 默认情况下,MSS由接口MTU及Unbound与其他服务器之间的协商决定,采用系统默认值。 tcp-idle-timeout: <msec> Unbound在TCP连接上等待查询的时长,若超时则关闭连接。 此选项默认值为30000毫秒。 当空闲的入站TCP缓冲区数量低于配置总数的50%时,该选项值会逐步降低: 首先降至配置值的1%,若空闲缓冲区进一步低于总数的35%,则降至配置值的0.2%, 最终若空闲缓冲区低于总数的20%,则降至0。 无论采用何种选项值,最小超时时间均保持为200毫秒。 若启用了edns-tcp-keepalive,此设置将被edns-tcp-keepalive-timeout覆盖。 tcp-reuse-timeout: <msec> Unbound 期间将保持与权威服务器的 TCP 持久连接开启。此选项默认值为 60000 毫秒。 max-reuse-tcp-queries: <number> 在持久TCP连接上可发送的最大查询数量,此选项默认设置为200次查询。 tcp-auth-query-timeout: <number> TCP查询认证服务器的超时时间,以毫秒为单位。此选项默认值为3000毫秒。 edns-tcp-keepalive: <yes or no> 启用或禁用EDNS TCP保持连接功能。默认设置为`no`。 edns-tcp-keepalive-timeout: <msec> 当启用edns-tcp-keepalive时,此设置将覆盖tcp-idle-timeout。 若客户端支持EDNS TCP保持连接选项,Unbound会向客户端发送超时值, 以促使客户端在服务器超时前关闭连接。 此选项默认值为120000毫秒。 sock-queue-timeout: <sec> 在套接字缓冲区中等待过久的UDP查询可被丢弃。 默认值为0,即禁用此功能。 时间以秒为单位设置,3秒可能是一个合适的值,用于忽略那些客户端可能已不再需要回复的旧查询。 这种情况可能发生在主机暂时无法处理查询时,例如Unbound未运行,之后又重新启用。 该功能利用了时间戳套接字选项。 tcp-upstream: <yes or no> 启用或禁用上游查询是否仅使用TCP进行传输。 默认设置为`no`。在隧道场景中非常有用。 如果设置为否,您可以通过分别使用forward-tcp-upstream或stub-tcp-upstream, 仅为选定的转发区域或存根区域指定TCP传输。 udp-upstream-without-downstream: <yes or no> 即使do-udp设置为否,也启用UDP上行。 默认情况下为否,此设置不会改变任何现有配置。 对于TLS服务提供商而言,若希望禁止UDP下行但需通过UDP获取上行数据,此功能尤为实用。 tls-upstream: <yes or no> 启用或禁用上游查询是否仅使用TLS进行传输。 默认值为`no`。在隧道场景中非常有用。 TLS包含以TCP线格式传输的纯DNS数据。 另一台服务器必须支持此功能(参见tls-service-key)。 如果启用此选项,还需配置tls-cert-bundle或使用tls-win-cert、tls-system-cert加载CA证书, 否则连接无法进行身份验证。 此选项为所有上游查询启用TLS,但如果不设置此选项, 可以通过forward-tls-upstream为特定转发区域单独配置TLS, 同样适用于stub-tls-upstream。如果启用了tls-upstream选项, 则对所有转发和存根区域生效,此时forward-tls-upstream和stub-tls-upstream选项将被忽略, 视为已设置为`yes`。 ssl-upstream: <yes or no> tls-upstream 的替代语法。若配置文件中两者均存在,则以最后一项为准。 tls-service-key: <file> 若启用此功能,服务器将在通过tls-port或https-port隐式或显式标记的TCP端口上 提供DNS-over-TLS或DNS-over-HTTPS服务。 配置文件必须包含TLS会话的私钥,公钥证书则位于tls-service-pem文件中,且若指定了tls-service-key, 也必须同时指定。 默认值为空,即关闭状态。 启用或禁用此服务需重启服务器(仅重载配置不够),因为密钥读取需在持有root权限及chroot(如有)之前进行。 通过tls-port:和https-port:隐式或显式启用的端口不提供常规的DNS TCP服务。 Unbound需编译时包含libnghttp2以支持DNS-over-HTTPS。 ssl-service-key: <file> tls-service-key 的替代语法。 tls-service-pem: <file> 用于TLS服务的公钥证书pem文件。默认值为"",表示关闭。 ssl-service-pem: <file> tls-service-pem 的替代语法。 tls-port: <number> 提供TCP TLS服务的端口号,默认为853,只有配置了该端口号作为@number的接口才能获得TLS服务。 ssl-port: <number> tls端口的替代语法。 tls-cert-bundle: <file> 若为空或"",则不使用任何文件。 请将其设置为证书包文件,例如"/etc/pki/tls/certs/ca-bundle.crt"。 这些证书用于验证与外部对等方建立的连接,如认证区域URL及DNS over TLS连接。 该文件在启动时、权限降级和chroot之前被读取。 ssl-cert-bundle: <file> tls-cert-bundle 的替代语法。 tls-win-cert: <yes or no> 将系统证书添加到认证所需的证书包中。 若无证书包,则仅使用这些证书。 默认情况下不启用此功能。 在Windows系统上,此选项会使用证书存储中的证书。 在其他系统上,请使用`tls-cert-bundle`选项来启用系统证书。 tls-system-cert: <yes or no> 此设置与tls-win-cert设置相同,只是名称不同,因为它并非专为Windows设计。 tls-additional-port: <portnr> 将端口号列为tls-additional-port,并在定义接口时(例如使用@port后缀), 作为此端口号,它们将提供DNS over TLS服务。 可列出多个,每个端口号单独一行声明。 tls-session-ticket-keys: <file> 若非空,则列出包含80字节随机内容的文件, 这些文件用于为使用Unbound服务器的客户端执行TLS会话恢复。 这些文件内含有TLS会话票据的密钥。 首个密钥用于加密和解密TLS会话票据,其余密钥仅用于解密。 通过生成新的首个文件,并在其后暂时保留旧文件以允许解密,可以实现密钥的轮换。 待客户端不再使用旧密钥后,即可移除旧密钥。 创建此类文件的一种方法是使用命令`dd if=/dev/random bs=1 count=80 of=ticket.dat`。 若需创建第二个密钥,其前16字节应与旧密钥不同,这部分用于标识密钥。 随后是32字节的随机数据作为AES密钥,再接着32字节的随机数据作为HMAC密钥。 tls-ciphers: <string with cipher list> 设置服务TLS时允许的加密套件列表。使用""表示默认值,且此为默认设置。 tls-ciphersuites: <string with ciphersuites list> 设置服务TLS时允许的加密套件列表,适用于较新的TLS 1.3连接。 使用""表示采用默认值,这也是默认设置。 pad-responses: <yes or no> 若启用此功能,包含EDNS填充选项的TLS服务查询将导致响应被填充至最接近pad-responses-block-size指定大小的倍数。默认设置为`yes`。 pad-responses-block-size: <number> 用于填充通过TLS服务的响应的块大小。仅对填充查询的响应进行填充。默认值为468。 pad-queries: <yes or no> 若启用此功能,所有通过TLS上游发送的查询将被填充至最接近pad-queries-block-size指定大小的倍数。 默认设置为`yes`。 pad-queries-block-size: <number> 用于填充通过TLS上游发送的查询的块大小,默认值为128。 tls-use-sni: <yes or no> 启用或禁用在TLS连接上发送SNI扩展。默认值为`yes`。更改此值需重新加载配置。 https-port: <number> 提供DNS-over-HTTPS服务的端口号,默认443,只有配置了该端口号作为@number的接口才能获得HTTPS服务。 http-endpoint: <endpoint string> 提供DNS-over-HTTPS服务的HTTP端点,默认为"/dns-query"。 http-max-streams: <number of streams> 用于DNS-over-HTTPS连接的HTTP/2 SETTINGS帧中SETTINGS_MAX_CONCURRENT_STREAMS参数的数值,默认设置为100。 http-query-buffer-size: <size in bytes> 所有HTTP/2查询缓冲区合并使用的最大字节数。 这些缓冲区包含等待请求流完成的(部分)DNS查询。 对于超出此限制的流,将发送RST_STREAM帧。 默认值为4兆字节。纯数字表示字节,可附加'k'、'm'或'g'分别表示千字节、兆字节或吉字节(1兆字节等于1024*1024字节)。 http-response-buffer-size: <size in bytes> 所有HTTP/2响应缓冲区合并使用的最大字节数。 这些缓冲区包含等待写回客户端的DNS响应。 对于超出此限制的流,将发送RST_STREAM帧。默认值为4兆字节。 纯数字表示字节,可附加'k'、'm'或'g'分别表示千字节、兆字节或吉字节(1兆字节等于1024*1024字节)。 http-nodelay: <yes or no> 在用于提供DNS-over-HTTPS服务的套接字上设置TCP_NODELAY选项。若该选项不可用,则忽略。默认值为`yes`。 http-notls-downstream: <yes or no> 禁用下游DNS-over-HTTP连接的TLS使用。适用于本地后端服务器。默认设置为`no`。 proxy-protocol-port: <portnr> 将端口号列为代理协议端口(proxy-protocol-port), 并在定义接口时,如使用@port后缀,指定为此端口号, 这些接口将支持并预期接收PROXYv2协议。 在此情况下,代理地址仅用于网络通信及初始的访问控制列表(ACL,检查代理本身是否被配置拒绝)。 随后,被代理的地址(如有)将作为真实客户端地址, 并在日志记录、ACL、DNSTAP、RPZ及IP限速等适用场景中使用。 PROXYv2协议支持UDP和TCP/TLS监听接口,但在DoH、DoQ或DNSCrypt监听接口上不支持PROXYv2。 可列出多个端口,每个端口单独一行声明。 quic-port: <number> The port number on which to provide DNS-over-QUIC service, de- fault 853, only interfaces configured with that port number as @number get the QUIC service. The interface uses QUIC for the UDP traffic on that port number. quic-size: <size in bytes> Maximum number of bytes for all QUIC buffers and data combined. Default is 8 megabytes. A plain number is in bytes, append 'k', 'm' or 'g' for kilobytes, megabytes or gigabytes (1024*1024 bytes in a megabyte). New connections receive connection refused when the limit is exceeded. New streams are reset when the limit is exceeded. use-systemd: <yes or no> Enable or disable systemd socket activation. Default is no. do-daemonize: <yes or no> Enable or disable whether the Unbound server forks into the background as a daemon. Set the value to no when Unbound runs as systemd service. Default is yes. tcp-connection-limit: <IP netblock> <limit> Allow up to limit simultaneous TCP connections from the given netblock. When at the limit, further connections are accepted but closed immediately. This option is experimental at this time. access-control: <IP netblock> <action> Specify treatment of incoming queries from their originating IP address. Queries can be allowed to have access to this server that gives DNS answers, or refused, with other actions possible. The IP address range can be specified as a netblock, it is pos- sible to give the statement several times in order to specify the treatment of different netblocks. The netblock is given as an IP4 or IP6 address with /size ap- pended for a classless network block. The action can be deny, refuse, allow, allow_setrd, allow_snoop, allow_cookie, deny_non_local or refuse_non_local. The most specific netblock match is used, if none match refuse is used. The order of the access-control statements therefore does not matter. The deny action stops queries from hosts from that netblock. The refuse action stops queries too, but sends a DNS rcode RE- FUSED error message back. The allow action gives access to clients from that netblock. It gives only access for recursion clients (which is what almost all clients need). Nonrecursive queries are refused. The allow action does allow nonrecursive queries to access the local-data that is configured. The reason is that this does not involve the Unbound server recursive lookup algorithm, and sta- tic data is served in the reply. This supports normal opera- tions where nonrecursive queries are made for the authoritative data. For nonrecursive queries any replies from the dynamic cache are refused. The allow_setrd action ignores the recursion desired (RD) bit and treats all requests as if the recursion desired bit is set. Note that this behavior violates RFC 1034 which states that a name server should never perform recursive service unless asked via the RD bit since this interferes with trouble shooting of name servers and their databases. This prohibited behavior may be useful if another DNS server must forward requests for spe- cific zones to a resolver DNS server, but only supports stub do- mains and sends queries to the resolver DNS server with the RD bit cleared. The allow_snoop action gives nonrecursive access too. This give both recursive and non recursive access. The name allow_snoop refers to cache snooping, a technique to use nonrecursive queries to examine the cache contents (for malicious acts). However, nonrecursive queries can also be a valuable debugging tool (when you want to examine the cache contents). In that case use allow_snoop for your administration host. The allow_cookie action allows access only to UDP queries that contain a valid DNS Cookie as specified in RFC 7873 and RFC 9018, when the answer-cookie option is enabled. UDP queries containing only a DNS Client Cookie and no Server Cookie, or an invalid DNS Cookie, will receive a BADCOOKIE response including a newly generated DNS Cookie, allowing clients to retry with that DNS Cookie. The allow_cookie action will also accept re- quests over stateful transports, regardless of the presence of an DNS Cookie and regardless of the answer-cookie setting. UDP queries without a DNS Cookie receive REFUSED responses with the TC flag set, that may trigger fall back to TCP for those clients. By default only localhost (the 127.0.0.0/8 IP netblock, not the loopback interface) is implicitly allowed, the rest is refused. The default is refused, because that is protocol-friendly. The DNS protocol is not designed to handle dropped packets due to policy, and dropping may result in (possibly excessive) retried queries. The deny_non_local and refuse_non_local settings are for hosts that are only allowed to query for the authoritative local-data, they are not allowed full recursion but only the static data. With deny_non_local, messages that are disallowed are dropped, with refuse_non_local they receive error code REFUSED. access-control-tag: <IP netblock> <"list of tags"> Assign tags to access-control elements. Clients using this ac- cess control element use localzones that are tagged with one of these tags. Tags must be defined in define-tags. Enclose list of tags in quotes ("") and put spaces between tags. If ac- cess-control-tag is configured for a netblock that does not have an access-control, an access-control element with action allow is configured for this netblock. access-control-tag-action: <IP netblock> <tag> <action> Set action for particular tag for given access control element. If you have multiple tag values, the tag used to lookup the ac- tion is the first tag match between access-control-tag and lo- cal-zone-tag where "first" comes from the order of the define- tag values. access-control-tag-data: <IP netblock> <tag> <"resource record string"> Set redirect data for particular tag for given access control element. access-control-view: <IP netblock> <view name> Set view for given access control element. interface-action: <ip address or interface name [@port]> <action> Similar to access-control: but for interfaces. The action is the same as the ones defined under access-con- trol:. Interfaces are refused by default. By default only lo- calhost (the 127.0.0.0/8 IP netblock, not the loopback inter- face) is implicitly allowed through the default access-control: behavior. This also means that any attempt to use the inter- face-*: options for the loopback interface will not work as they will be overridden by the implicit default "access-control: 127.0.0.0/8 allow" option. Note that the interface needs to be already specified with in- terface: and that any access-control*: setting overrides all in- terface-*: settings for targeted clients. interface-tag: <ip address or interface name [@port]> <"list of tags"> Similar to access-control-tag: but for interfaces. Note that the interface needs to be already specified with in- terface: and that any access-control*: setting overrides all in- terface-*: settings for targeted clients. interface-tag-action: <ip address or interface name [@port]> <tag> <ac- tion> Similar to access-control-tag-action: but for interfaces. Note that the interface needs to be already specified with in- terface: and that any access-control*: setting overrides all in- terface-*: settings for targeted clients. interface-tag-data: <ip address or interface name [@port]> <tag> <"re- source record string"> Similar to access-control-tag-data: but for interfaces. Note that the interface needs to be already specified with in- terface: and that any access-control*: setting overrides all in- terface-*: settings for targeted clients. interface-view: <ip address or interface name [@port]> <view name> Similar to access-control-view: but for interfaces. Note that the interface needs to be already specified with in- terface: and that any access-control*: setting overrides all in- terface-*: settings for targeted clients. chroot: <directory> If chroot is enabled, you should pass the configfile (from the commandline) as a full path from the original root. After the chroot has been performed the now defunct portion of the config file path is removed to be able to reread the config after a re- load. All other file paths (working dir, logfile, roothints, and key files) can be specified in several ways: as an absolute path relative to the new root, as a relative path to the working di- rectory, or as an absolute path relative to the original root. In the last case the path is adjusted to remove the unused por- tion. The pidfile can be either a relative path to the working direc- tory, or an absolute path relative to the original root. It is written just prior to chroot and dropping permissions. This al- lows the pidfile to be /var/run/unbound.pid and the chroot to be /var/unbound, for example. Note that Unbound is not able to re- move the pidfile after termination when it is located outside of the chroot directory. Additionally, Unbound may need to access /dev/urandom (for en- tropy) from inside the chroot. If given a chroot is done to the given directory. The chroot is by default set to "/usr/local/etc/unbound". If you give "" no chroot is performed. username: <name> If given, after binding the port the user privileges are dropped. Default is "unbound". If you give username: "" no user change is performed. If this user is not capable of binding the port, reloads (by signal HUP) will still retain the opened ports. If you change the port number in the config file, and that new port number re- quires privileges, then a reload will fail; a restart is needed. directory: <directory> Sets the working directory for the program. Default is "/usr/lo- cal/etc/unbound". On Windows the string "%EXECUTABLE%" tries to change to the directory that unbound.exe resides in. If you give a server: directory: dir before include: file statements then those includes can be relative to the working directory. logfile: <filename> If "" is given, logging goes to stderr, or nowhere once daemo- nized. The logfile is appended to, in the following format: [seconds since 1970] unbound[pid:tid]: type: message. If this option is given, the use-syslog is option is set to "no". The logfile is reopened (for append) when the config file is reread, on SIGHUP. use-syslog: <yes or no> Sets Unbound to send log messages to the syslogd, using sys- log(3). The log facility LOG_DAEMON is used, with identity "un- bound". The logfile setting is overridden when use-syslog is turned on. The default is to log to syslog. log-identity: <string> If "" is given (default), then the name of the executable, usu- ally "unbound" is used to report to the log. Enter a string to override it with that, which is useful on systems that run more than one instance of Unbound, with different configurations, so that the logs can be easily distinguished against. log-time-ascii: <yes or no> Sets logfile lines to use a timestamp in UTC ascii. Default is no, which prints the seconds since 1970 in brackets. No effect if using syslog, in that case syslog formats the timestamp printed into the log files. log-time-iso: <yes or no> Log time in ISO8601 format, if log-time-ascii: yes is also set. Default is no. log-queries: <yes or no> Prints one line per query to the log, with the log timestamp and IP address, name, type and class. Default is no. Note that it takes time to print these lines which makes the server (signifi- cantly) slower. Odd (nonprintable) characters in names are printed as '?'. log-replies: <yes or no> Prints one line per reply to the log, with the log timestamp and IP address, name, type, class, return code, time to resolve, from cache and response size. Default is no. Note that it takes time to print these lines which makes the server (signifi- cantly) slower. Odd (nonprintable) characters in names are printed as '?'. log-tag-queryreply: <yes or no> Prints the word 'query' and 'reply' with log-queries and log-replies. This makes filtering logs easier. The default is off (for backwards compatibility). log-destaddr: <yes or no> Prints the destination address, port and type in the log-replies output. This disambiguates what type of traffic, eg. udp or tcp, and to what local port the traffic was sent to. log-local-actions: <yes or no> Print log lines to inform about local zone actions. These lines are like the local-zone type inform prints out, but they are also printed for the other types of local zones. log-servfail: <yes or no> Print log lines that say why queries return SERVFAIL to clients. This is separate from the verbosity debug logs, much smaller, and printed at the error level, not the info level of debug info from verbosity. pidfile: <filename> The process id is written to the file. Default is "/usr/lo- cal/etc/unbound/unbound.pid". So, kill -HUP `cat /usr/local/etc/unbound/unbound.pid` triggers a reload, kill -TERM `cat /usr/local/etc/unbound/unbound.pid` gracefully terminates. root-hints: <filename> Read the root hints from this file. Default is nothing, using builtin hints for the IN class. The file has the format of zone files, with root nameserver names and addresses only. The de- fault may become outdated, when servers change, therefore it is good practice to use a root-hints file. hide-identity: <yes or no> If enabled id.server and hostname.bind queries are refused. identity: <string> Set the identity to report. If set to "", the default, then the hostname of the server is returned. hide-version: <yes or no> If enabled version.server and version.bind queries are refused. version: <string> Set the version to report. If set to "", the default, then the package version is returned. hide-http-user-agent: <yes or no> If enabled the HTTP header User-Agent is not set. Use with cau- tion as some webserver configurations may reject HTTP requests lacking this header. If needed, it is better to explicitly set the http-user-agent below. http-user-agent: <string> Set the HTTP User-Agent header for outgoing HTTP requests. If set to "", the default, then the package name and version are used. nsid: <string> Add the specified nsid to the EDNS section of the answer when queried with an NSID EDNS enabled packet. As a sequence of hex characters or with ascii_ prefix and then an ascii string. hide-trustanchor: <yes or no> If enabled trustanchor.unbound queries are refused. target-fetch-policy: <"list of numbers"> Set the target fetch policy used by Unbound to determine if it should fetch nameserver target addresses opportunistically. The policy is described per dependency depth. The number of values determines the maximum dependency depth that Unbound will pursue in answering a query. A value of -1 means to fetch all targets opportunistically for that dependency depth. A value of 0 means to fetch on demand only. A positive value fetches that many targets opportunistically. Enclose the list between quotes ("") and put spaces between num- bers. The default is "3 2 1 0 0". Setting all zeroes, "0 0 0 0 0" gives behaviour closer to that of BIND 9, while setting "-1 -1 -1 -1 -1" gives behaviour rumoured to be closer to that of BIND 8. harden-short-bufsize: <yes or no> Very small EDNS buffer sizes from queries are ignored. Default is yes, as described in the standard. harden-large-queries: <yes or no> Very large queries are ignored. Default is no, since it is legal protocol wise to send these, and could be necessary for opera- tion if TSIG or EDNS payload is very large. harden-glue: <yes or no> Will trust glue only if it is within the servers authority. De- fault is yes. harden-unverified-glue: <yes or no> Will trust only in-zone glue. Will try to resolve all out of zone (<unverfied>) glue. Will fallback to the original glue if unable to resolve. Default is no. harden-dnssec-stripped: <yes or no> Require DNSSEC data for trust-anchored zones, if such data is absent, the zone becomes bogus. If turned off, and no DNSSEC data is received (or the DNSKEY data fails to validate), then the zone is made insecure, this behaves like there is no trust anchor. You could turn this off if you are sometimes behind an intrusive firewall (of some sort) that removes DNSSEC data from packets, or a zone changes from signed to unsigned to badly signed often. If turned off you run the risk of a downgrade at- tack that disables security for a zone. Default is yes. harden-below-nxdomain: <yes or no> From RFC 8020 (with title "NXDOMAIN: There Really Is Nothing Un- derneath"), returns nxdomain to queries for a name below another name that is already known to be nxdomain. DNSSEC mandates no- error for empty nonterminals, hence this is possible. Very old software might return nxdomain for empty nonterminals (that usu- ally happen for reverse IP address lookups), and thus may be in- compatible with this. To try to avoid this only DNSSEC-secure nxdomains are used, because the old software does not have DNSSEC. Default is yes. The nxdomain must be secure, this means nsec3 with optout is insufficient. harden-referral-path: <yes or no> Harden the referral path by performing additional queries for infrastructure data. Validates the replies if trust anchors are configured and the zones are signed. This enforces DNSSEC vali- dation on nameserver NS sets and the nameserver addresses that are encountered on the referral path to the answer. Default no, because it burdens the authority servers, and it is not RFC standard, and could lead to performance problems because of the extra query load that is generated. Experimental option. If you enable it consider adding more numbers after the tar- get-fetch-policy to increase the max depth that is checked to. harden-algo-downgrade: <yes or no> Harden against algorithm downgrade when multiple algorithms are advertised in the DS record. This works by first choosing only the strongest DS digest type as per RFC 4509 (Unbound treats the highest algorithm as the strongest) and then expecting signa- tures from all the advertised signing algorithms from the chosen DS(es) to be present. If no, allows any one supported algorithm to validate the zone, even if other advertised algorithms are broken. Default is no. RFC 6840 mandates that zone signers must produce zones signed with all advertised algorithms, but sometimes they do not. RFC 6840 also clarifies that this re- quirement is not for validators and validators should accept any single valid path. It should thus be explicitly noted that this option violates RFC 6840 for DNSSEC validation and should only be used to perform a signature completeness test to support troubleshooting. Using this option may break DNSSEC resolution with non-RFC6840-conforming signers and/or in multi-signer con- figurations that don't send all the advertised signatures. harden-unknown-additional: <yes or no> Harden against unknown records in the authority section and ad- ditional section. Default is no. If no, such records are copied from the upstream and presented to the client together with the answer. If yes, it could hamper future protocol developments that want to add records. use-caps-for-id: <yes or no> Use 0x20-encoded random bits in the query to foil spoof at- tempts. This perturbs the lowercase and uppercase of query names sent to authority servers and checks if the reply still has the correct casing. Disabled by default. This feature is an experimental implementation of draft dns-0x20. caps-exempt: <domain> Exempt the domain so that it does not receive caps-for-id per- turbed queries. For domains that do not support 0x20 and also fail with fallback because they keep sending different answers, like some load balancers. Can be given multiple times, for dif- ferent domains. caps-whitelist: <domain> Alternate syntax for caps-exempt. qname-minimisation: <yes or no> Send minimum amount of information to upstream servers to en- hance privacy. Only send minimum required labels of the QNAME and set QTYPE to A when possible. Best effort approach; full QNAME and original QTYPE will be sent when upstream replies with a RCODE other than NOERROR, except when receiving NXDOMAIN from a DNSSEC signed zone. Default is yes. qname-minimisation-strict: <yes or no> QNAME minimisation in strict mode. Do not fall-back to sending full QNAME to potentially broken nameservers. A lot of domains will not be resolvable when this option in enabled. Only use if you know what you are doing. This option only has effect when qname-minimisation is enabled. Default is no. aggressive-nsec: <yes or no> Aggressive NSEC uses the DNSSEC NSEC chain to synthesize NXDO- MAIN and other denials, using information from previous NXDO- MAINs answers. Default is yes. It helps to reduce the query rate towards targets that get a very high nonexistent name lookup rate. private-address: <IP address or subnet> Give IPv4 of IPv6 addresses or classless subnets. These are ad- dresses on your private network, and are not allowed to be re- turned for public internet names. Any occurrence of such ad- dresses are removed from DNS answers. Additionally, the DNSSEC validator may mark the answers bogus. This protects against so-called DNS Rebinding, where a user browser is turned into a network proxy, allowing remote access through the browser to other parts of your private network. Some names can be allowed to contain your private addresses, by default all the local-data that you configured is allowed to, and you can specify addi- tional names using private-domain. No private addresses are en- abled by default. We consider to enable this for the RFC1918 private IP address space by default in later releases. That would enable private addresses for 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 169.254.0.0/16 fd00::/8 and fe80::/10, since the RFC standards say these addresses should not be visible on the public internet. Turning on 127.0.0.0/8 would hinder many spam- blocklists as they use that. Adding ::ffff:0:0/96 stops IPv4-mapped IPv6 addresses from bypassing the filter. private-domain: <domain name> Allow this domain, and all its subdomains to contain private ad- dresses. Give multiple times to allow multiple domain names to contain private addresses. Default is none. unwanted-reply-threshold: <number> If set, a total number of unwanted replies is kept track of in every thread. When it reaches the threshold, a defensive action is taken and a warning is printed to the log. The defensive ac- tion is to clear the rrset and message caches, hopefully flush- ing away any poison. A value of 10 million is suggested. De- fault is 0 (turned off). do-not-query-address: <IP address> Do not query the given IP address. Can be IP4 or IP6. Append /num to indicate a classless delegation netblock, for example like 10.2.3.4/24 or 2001::11/64. do-not-query-localhost: <yes or no> If yes, localhost is added to the do-not-query-address entries, both IP6 ::1 and IP4 127.0.0.1/8. If no, then localhost can be used to send queries to. Default is yes. prefetch: <yes or no> If yes, cache hits on message cache elements that are on their last 10 percent of their TTL value trigger a prefetch to keep the cache up to date. Default is no. Turning it on gives about 10 percent more traffic and load on the machine, but popular items do not expire from the cache. prefetch-key: <yes or no> If yes, fetch the DNSKEYs earlier in the validation process, when a DS record is encountered. This lowers the latency of re- quests. It does use a little more CPU. Also if the cache is set to 0, it is no use. Default is no. deny-any: <yes or no> If yes, deny queries of type ANY with an empty response. De- fault is no. If disabled, Unbound responds with a short list of resource records if some can be found in the cache and makes the upstream type ANY query if there are none. rrset-roundrobin: <yes or no> If yes, Unbound rotates RRSet order in response (the random num- ber is taken from the query ID, for speed and thread safety). Default is yes. minimal-responses: <yes or no> If yes, Unbound does not insert authority/additional sections into response messages when those sections are not required. This reduces response size significantly, and may avoid TCP fallback for some responses which may cause a slight speedup. The default is yes, even though the DNS protocol RFCs mandate these sections, and the additional content could save roundtrips for clients that use the additional content. However these sec- tions are hardly used by clients. Enabling prefetch can benefit clients that need the additional content by trying to keep that content fresh in the cache. disable-dnssec-lame-check: <yes or no> If true, disables the DNSSEC lameness check in the iterator. This check sees if RRSIGs are present in the answer, when dnssec is expected, and retries another authority if RRSIGs are unex- pectedly missing. The validator will insist in RRSIGs for DNSSEC signed domains regardless of this setting, if a trust an- chor is loaded. module-config: <"module names"> Module configuration, a list of module names separated by spaces, surround the string with quotes (""). The modules can be respip, validator, or iterator (and possibly more, see below). Setting this to just "iterator" will result in a non-validating server. Setting this to "validator iterator" will turn on DNSSEC validation. The ordering of the modules is significant, the order decides the order of processing. You must also set trust-anchors for validation to be useful. Adding respip to the front will cause RPZ processing to be done on all queries. The default is "validator iterator". Most modules that need to be listed here have to be listed at the beginning of the line. The subnetcachedb module has to be listed just before the iterator. The python module can be listed in different places, it then processes the output of the module it is just before. The dynlib module can be listed pretty much anywhere, it is only a very thin wrapper that allows dy- namic libraries to run in its place. trust-anchor-file: <filename> File with trusted keys for validation. Both DS and DNSKEY en- tries can appear in the file. The format of the file is the standard DNS Zone file format. Default is "", or no trust an- chor file. auto-trust-anchor-file: <filename> File with trust anchor for one zone, which is tracked with RFC5011 probes. The probes are run several times per month, thus the machine must be online frequently. The initial file can be one with contents as described in trust-anchor-file. The file is written to when the anchor is updated, so the Unbound user must have write permission. Write permission to the file, but also to the directory it is in (to create a temporary file, which is necessary to deal with filesystem full events), it must also be inside the chroot (if that is used). trust-anchor: <"Resource Record"> A DS or DNSKEY RR for a key to use for validation. Multiple en- tries can be given to specify multiple trusted keys, in addition to the trust-anchor-files. The resource record is entered in the same format as 'dig' or 'drill' prints them, the same format as in the zone file. Has to be on a single line, with "" around it. A TTL can be specified for ease of cut and paste, but is ig- nored. A class can be specified, but class IN is default. trusted-keys-file: <filename> File with trusted keys for validation. Specify more than one file with several entries, one file per entry. Like trust-an- chor-file but has a different file format. Format is BIND-9 style format, the trusted-keys { name flag proto algo "key"; }; clauses are read. It is possible to use wildcards with this statement, the wildcard is expanded on start and on reload. trust-anchor-signaling: <yes or no> Send RFC8145 key tag query after trust anchor priming. Default is yes. root-key-sentinel: <yes or no> Root key trust anchor sentinel. Default is yes. domain-insecure: <domain name> Sets domain name to be insecure, DNSSEC chain of trust is ig- nored towards the domain name. So a trust anchor above the do- main name can not make the domain secure with a DS record, such a DS record is then ignored. Can be given multiple times to specify multiple domains that are treated as if unsigned. If you set trust anchors for the domain they override this setting (and the domain is secured). This can be useful if you want to make sure a trust anchor for external lookups does not affect an (unsigned) internal domain. A DS record externally can create validation failures for that internal domain. val-override-date: <rrsig-style date spec> Default is "" or "0", which disables this debugging feature. If enabled by giving a RRSIG style date, that date is used for ver- ifying RRSIG inception and expiration dates, instead of the cur- rent date. Do not set this unless you are debugging signature inception and expiration. The value -1 ignores the date alto- gether, useful for some special applications. val-sig-skew-min: <seconds> Minimum number of seconds of clock skew to apply to validated signatures. A value of 10% of the signature lifetime (expira- tion - inception) is used, capped by this setting. Default is 3600 (1 hour) which allows for daylight savings differences. Lower this value for more strict checking of short lived signa- tures. val-sig-skew-max: <seconds> Maximum number of seconds of clock skew to apply to validated signatures. A value of 10% of the signature lifetime (expira- tion - inception) is used, capped by this setting. Default is 86400 (24 hours) which allows for timezone setting problems in stable domains. Setting both min and max very low disables the clock skew allowances. Setting both min and max very high makes the validator check the signature timestamps less strictly. val-max-restart: <number> The maximum number the validator should restart validation with another authority in case of failed validation. Default is 5. val-bogus-ttl: <number> The time to live for bogus data. This is data that has failed validation; due to invalid signatures or other checks. The TTL from that data cannot be trusted, and this value is used in- stead. The value is in seconds, default 60. The time interval prevents repeated revalidation of bogus data. val-clean-additional: <yes or no> Instruct the validator to remove data from the additional sec- tion of secure messages that are not signed properly. Messages that are insecure, bogus, indeterminate or unchecked are not af- fected. Default is yes. Use this setting to protect the users that rely on this validator for authentication from potentially bad data in the additional section. val-log-level: <number> Have the validator print validation failures to the log. Re- gardless of the verbosity setting. Default is 0, off. At 1, for every user query that fails a line is printed to the logs. This way you can monitor what happens with validation. Use a diagnosis tool, such as dig or drill, to find out why validation is failing for these queries. At 2, not only the query that failed is printed but also the reason why Unbound thought it was wrong and which server sent the faulty data. val-permissive-mode: <yes or no> Instruct the validator to mark bogus messages as indeterminate. The security checks are performed, but if the result is bogus (failed security), the reply is not withheld from the client with SERVFAIL as usual. The client receives the bogus data. For messages that are found to be secure the AD bit is set in replies. Also logging is performed as for full validation. The default value is "no". ignore-cd-flag: <yes or no> Instruct Unbound to ignore the CD flag from clients and refuse to return bogus answers to them. Thus, the CD (Checking Dis- abled) flag does not disable checking any more. This is useful if legacy (w2008) servers that set the CD flag but cannot vali- date DNSSEC themselves are the clients, and then Unbound pro- vides them with DNSSEC protection. The default value is "no". disable-edns-do: <yes or no> Disable the EDNS DO flag in upstream requests. It breaks DNSSEC validation for Unbound's clients. This results in the upstream name servers to not include DNSSEC records in their replies and could be helpful for devices that cannot handle DNSSEC informa- tion. When the option is enabled, clients that set the DO flag receive no EDNS record in the response to indicate the lack of support to them. If this option is enabled but Unbound is al- ready configured for DNSSEC validation (i.e., the validator mod- ule is enabled; default) this option is implicitly turned off with a warning as to not break DNSSEC validation in Unbound. Default is no. serve-expired: <yes or no> If enabled, Unbound attempts to serve old responses from cache with a TTL of serve-expired-reply-ttl in the response. By de- fault the expired answer will be used after a resolution attempt errored out or is taking more than serve-expired-client-timeout to resolve. Default is "no". serve-expired-ttl: <seconds> Limit serving of expired responses to configured seconds after expiration. 0 disables the limit. This option only applies when serve-expired is enabled. A suggested value per RFC 8767 is between 86400 (1 day) and 259200 (3 days). The default is 86400. serve-expired-ttl-reset: <yes or no> Set the TTL of expired records to the serve-expired-ttl value after a failed attempt to retrieve the record from upstream. This makes sure that the expired records will be served as long as there are queries for it. Default is "no". serve-expired-reply-ttl: <seconds> TTL value to use when replying with expired data. If serve-ex- pired-client-timeout is also used then it is RECOMMENDED to use 30 as the value (RFC 8767). The default is 30. serve-expired-client-timeout: <msec> Time in milliseconds before replying to the client with expired data. This essentially enables the serve-stale behavior as specified in RFC 8767 that first tries to resolve before immedi- ately responding with expired data. Setting this to 0 will dis- able this behavior and instead serve the expired record immedi- ately from the cache before attempting to refresh it via resolu- tion. Default is 1800. serve-original-ttl: <yes or no> If enabled, Unbound will always return the original TTL as re- ceived from the upstream name server rather than the decrement- ing TTL as stored in the cache. This feature may be useful if Unbound serves as a front-end to a hidden authoritative name server. Enabling this feature does not impact cache expiry, it only changes the TTL Unbound embeds in responses to queries. Note that enabling this feature implicitly disables enforcement of the configured minimum and maximum TTL, as it is assumed users who enable this feature do not want Unbound to change the TTL obtained from an upstream server. Thus, the values set us- ing cache-min-ttl and cache-max-ttl are ignored. Default is "no". val-nsec3-keysize-iterations: <"list of values"> List of keysize and iteration count values, separated by spaces, surrounded by quotes. Default is "1024 150 2048 150 4096 150". This determines the maximum allowed NSEC3 iteration count before a message is simply marked insecure instead of performing the many hashing iterations. The list must be in ascending order and have at least one entry. If you set it to "1024 65535" there is no restriction to NSEC3 iteration values. This table must be kept short; a very long list could cause slower operation. zonemd-permissive-mode: <yes or no> If enabled the ZONEMD verification failures are only logged and do not cause the zone to be blocked and only return servfail. Useful for testing out if it works, or if the operator only wants to be notified of a problem without disrupting service. Default is no. add-holddown: <seconds> Instruct the auto-trust-anchor-file probe mechanism for RFC5011 autotrust updates to add new trust anchors only after they have been visible for this time. Default is 30 days as per the RFC. del-holddown: <seconds> Instruct the auto-trust-anchor-file probe mechanism for RFC5011 autotrust updates to remove revoked trust anchors after they have been kept in the revoked list for this long. Default is 30 days as per the RFC. keep-missing: <seconds> Instruct the auto-trust-anchor-file probe mechanism for RFC5011 autotrust updates to remove missing trust anchors after they have been unseen for this long. This cleans up the state file if the target zone does not perform trust anchor revocation, so this makes the auto probe mechanism work with zones that perform regular (non-5011) rollovers. The default is 366 days. The value 0 does not remove missing anchors, as per the RFC. permit-small-holddown: <yes or no> Debug option that allows the autotrust 5011 rollover timers to assume very small values. Default is no. key-cache-size: <number> Number of bytes size of the key cache. Default is 4 megabytes. A plain number is in bytes, append 'k', 'm' or 'g' for kilo- bytes, megabytes or gigabytes (1024*1024 bytes in a megabyte). key-cache-slabs: <number> Number of slabs in the key cache. Slabs reduce lock contention by threads. Must be set to a power of 2. Setting (close) to the number of cpus is a reasonable guess. neg-cache-size: <number> Number of bytes size of the aggressive negative cache. Default is 1 megabyte. A plain number is in bytes, append 'k', 'm' or 'g' for kilobytes, megabytes or gigabytes (1024*1024 bytes in a megabyte). unblock-lan-zones: <yes or no> Default is disabled. If enabled, then for private address space, the reverse lookups are no longer filtered. This allows Unbound when running as dns service on a host where it provides service for that host, to put out all of the queries for the 'lan' upstream. When enabled, only localhost, 127.0.0.1 reverse and ::1 reverse zones are configured with default local zones. Disable the option when Unbound is running as a (DHCP-) DNS net- work resolver for a group of machines, where such lookups should be filtered (RFC compliance), this also stops potential data leakage about the local network to the upstream DNS servers. insecure-lan-zones: <yes or no> Default is disabled. If enabled, then reverse lookups in pri- vate address space are not validated. This is usually required whenever unblock-lan-zones is used. local-zone: <zone> <type> Configure a local zone. The type determines the answer to give if there is no match from local-data. The types are deny, refuse, static, transparent, redirect, nodefault, typetranspar- ent, inform, inform_deny, inform_redirect, always_transparent, block_a, always_refuse, always_nxdomain, always_null, noview, and are explained below. After that the default settings are listed. Use local-data: to enter data into the local zone. An- swers for local zones are authoritative DNS answers. By default the zones are class IN. If you need more complicated authoritative data, with referrals, wildcards, CNAME/DNAME support, or DNSSEC authoritative service, setup a stub-zone for it as detailed in the stub zone section below. A stub-zone can be used to have unbound send queries to another server, an authoritative server, to fetch the informa- tion. With a forward-zone, unbound sends queries to a server that is a recursive server to fetch the information. With an auth-zone a zone can be loaded from file and used, it can be used like a local-zone for users downstream, or the auth-zone information can be used to fetch information from when resolving like it is an upstream server. The forward-zone and auth-zone options are described in their sections below. If you want to perform filtering of the information that the users can fetch, the local-zone and local-data statements allow for this, but also the rpz functionality can be used, described in the RPZ section. deny Do not send an answer, drop the query. If there is a match from local data, the query is answered. refuse Send an error message reply, with rcode REFUSED. If there is a match from local data, the query is answered. static If there is a match from local data, the query is answered. Otherwise, the query is answered with nodata or nxdomain. For a negative answer a SOA is included in the answer if present as local-data for the zone apex domain. transparent If there is a match from local data, the query is answered. Otherwise if the query has a different name, the query is re- solved normally. If the query is for a name given in local- data but no such type of data is given in localdata, then a noerror nodata answer is returned. If no local-zone is given local-data causes a transparent zone to be created by de- fault. typetransparent If there is a match from local data, the query is answered. If the query is for a different name, or for the same name but for a different type, the query is resolved normally. So, similar to transparent but types that are not listed in local data are resolved normally, so if an A record is in the local data that does not cause a nodata reply for AAAA queries. redirect The query is answered from the local data for the zone name. There may be no local data beneath the zone name. This an- swers queries for the zone, and all subdomains of the zone with the local data for the zone. It can be used to redirect a domain to return a different address record to the end user, with local-zone: "example.com." redirect and lo- cal-data: "example.com. A 127.0.0.1" queries for www.exam- ple.com and www.foo.example.com are redirected, so that users with web browsers cannot access sites with suffix exam- ple.com. inform The query is answered normally, same as transparent. The client IP address (@portnumber) is printed to the logfile. The log message is: timestamp, unbound-pid, info: zonename inform IP@port queryname type class. This option can be used for normal resolution, but machines looking up infected names are logged, eg. to run antivirus on them. inform_deny The query is dropped, like 'deny', and logged, like 'inform'. Ie. find infected machines without answering the queries. inform_redirect The query is redirected, like 'redirect', and logged, like 'inform'. Ie. answer queries with fixed data and also log the machines that ask. always_transparent Like transparent, but ignores local data and resolves nor- mally. block_a Like transparent, but ignores local data and resolves nor- mally all query types excluding A. For A queries it uncondi- tionally returns NODATA. Useful in cases when there is a need to explicitly force all apps to use IPv6 protocol and avoid any queries to IPv4. always_refuse Like refuse, but ignores local data and refuses the query. always_nxdomain Like static, but ignores local data and returns nxdomain for the query. always_nodata Like static, but ignores local data and returns nodata for the query. always_deny Like deny, but ignores local data and drops the query. always_null Always returns 0.0.0.0 or ::0 for every name in the zone. Like redirect with zero data for A and AAAA. Ignores local data in the zone. Used for some block lists. noview Breaks out of that view and moves towards the global local zones for answer to the query. If the view first is no, it'll resolve normally. If view first is enabled, it'll break perform that step and check the global answers. For when the view has view specific overrides but some zone has to be answered from global local zone contents. nodefault Used to turn off default contents for AS112 zones. The other types also turn off default contents for the zone. The 'node- fault' option has no other effect than turning off default contents for the given zone. Use nodefault if you use ex- actly that zone, if you want to use a subzone, use transpar- ent. The default zones are localhost, reverse 127.0.0.1 and ::1, the home.arpa, the resolver.arpa, the service.arpa, the onion, test, in- valid and the AS112 zones. The AS112 zones are reverse DNS zones for private use and reserved IP addresses for which the servers on the in- ternet cannot provide correct answers. They are configured by default to give nxdomain (no reverse information) answers. The defaults can be turned off by specifying your own local-zone of that name, or using the 'nodefault' type. Below is a list of the default zone contents. localhost The IP4 and IP6 localhost information is given. NS and SOA records are provided for completeness and to satisfy some DNS update tools. Default content: local-zone: "localhost." redirect local-data: "localhost. 10800 IN NS localhost." local-data: "localhost. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800" local-data: "localhost. 10800 IN A 127.0.0.1" local-data: "localhost. 10800 IN AAAA ::1" reverse IPv4 loopback Default content: local-zone: "127.in-addr.arpa." static local-data: "127.in-addr.arpa. 10800 IN NS localhost." local-data: "127.in-addr.arpa. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800" local-data: "1.0.0.127.in-addr.arpa. 10800 IN PTR localhost." reverse IPv6 loopback Default content: local-zone: "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0. 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." static local-data: "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0. 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa. 10800 IN NS localhost." local-data: "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0. 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800" local-data: "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0. 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa. 10800 IN PTR localhost." home.arpa (RFC 8375) Default content: local-zone: "home.arpa." static local-data: "home.arpa. 10800 IN NS localhost." local-data: "home.arpa. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800" resolver.arpa (RFC 9462) Default content: local-zone: "resolver.arpa." static local-data: "resolver.arpa. 10800 IN NS localhost." local-data: "resolver.arpa. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800" service.arpa (draft-ietf-dnssd-srp-25) Default content: local-zone: "service.arpa." static local-data: "service.arpa. 10800 IN NS localhost." local-data: "service.arpa. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800" onion (RFC 7686) Default content: local-zone: "onion." static local-data: "onion. 10800 IN NS localhost." local-data: "onion. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800" test (RFC 6761) Default content: local-zone: "test." static local-data: "test. 10800 IN NS localhost." local-data: "test. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800" invalid (RFC 6761) Default content: local-zone: "invalid." static local-data: "invalid. 10800 IN NS localhost." local-data: "invalid. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800" reverse RFC1918 local use zones Reverse data for zones 10.in-addr.arpa, 16.172.in-addr.arpa to 31.172.in-addr.arpa, 168.192.in-addr.arpa. The lo- cal-zone: is set static and as local-data: SOA and NS records are provided. reverse RFC3330 IP4 this, link-local, testnet and broadcast Reverse data for zones 0.in-addr.arpa, 254.169.in-addr.arpa, 2.0.192.in-addr.arpa (TEST NET 1), 100.51.198.in-addr.arpa (TEST NET 2), 113.0.203.in-addr.arpa (TEST NET 3), 255.255.255.255.in-addr.arpa. And from 64.100.in-addr.arpa to 127.100.in-addr.arpa (Shared Address Space). reverse RFC4291 IP6 unspecified Reverse data for zone 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0. 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa. reverse RFC4193 IPv6 Locally Assigned Local Addresses Reverse data for zone D.F.ip6.arpa. reverse RFC4291 IPv6 Link Local Addresses Reverse data for zones 8.E.F.ip6.arpa to B.E.F.ip6.arpa. reverse IPv6 Example Prefix Reverse data for zone 8.B.D.0.1.0.0.2.ip6.arpa. This zone is used for tutorials and examples. You can remove the block on this zone with: local-zone: 8.B.D.0.1.0.0.2.ip6.arpa. nodefault You can also selectively unblock a part of the zone by making that part transparent with a local-zone statement. This also works with the other default zones. local-data: "<resource record string>" Configure local data, which is served in reply to queries for it. The query has to match exactly unless you configure the local-zone as redirect. If not matched exactly, the local-zone type deter- mines further processing. If local-data is configured that is not a subdomain of a local-zone, a transparent local-zone is config- ured. For record types such as TXT, use single quotes, as in lo- cal-data: 'example. TXT "text"'. If you need more complicated authoritative data, with referrals, wildcards, CNAME/DNAME support, or DNSSEC authoritative service, setup a stub-zone for it as detailed in the stub zone section be- low. local-data-ptr: "IPaddr name" Configure local data shorthand for a PTR record with the reversed IPv4 or IPv6 address and the host name. For example "192.0.2.4 www.example.com". TTL can be inserted like this: "2001:DB8::4 7200 www.example.com" local-zone-tag: <zone> <"list of tags"> Assign tags to localzones. Tagged localzones will only be applied when the used access-control element has a matching tag. Tags must be defined in define-tags. Enclose list of tags in quotes ("") and put spaces between tags. When there are multiple tags it checks if the intersection of the list of tags for the query and local-zone-tag is non-empty. local-zone-override: <zone> <IP netblock> <type> Override the localzone type for queries from addresses matching netblock. Use this localzone type, regardless the type configured for the local-zone (both tagged and untagged) and regardless the type configured using access-control-tag-action. response-ip: <IP-netblock> <action> This requires use of the "respip" module. If the IP address in an AAAA or A RR in the answer section of a response matches the specified IP netblock, the specified action will apply. <action> has generally the same semantics as that for access-control-tag-action, but there are some exceptions. Actions for response-ip are different from those for local-zone in that in case of the former there is no point of such conditions as "the query matches it but there is no local data". Because of this difference, the semantics of response-ip actions are modified or simplified as follows: The static, refuse, transparent, type- transparent, and nodefault actions are invalid for response-ip. Using any of these will cause the configuration to be rejected as faulty. The deny action is non-conditional, i.e. it always results in dropping the corresponding query. The resolution result before applying the deny action is still cached and can be used for other queries. response-ip-data: <IP-netblock> <"resource record string"> This requires use of the "respip" module. This specifies the action data for response-ip with action being to redirect as specified by "resource record string". "Resource record string" is similar to that of access-control-tag-action, but it must be of either AAAA, A or CNAME types. If the IP-net- block is an IPv6/IPv4 prefix, the record must be AAAA/A respec- tively, unless it is a CNAME (which can be used for both versions of IP netblocks). If it is CNAME there must not be more than one response-ip-data for the same IP-netblock. Also, CNAME and other types of records must not coexist for the same IP-netblock, fol- lowing the normal rules for CNAME records. The textual domain name for the CNAME does not have to be explicitly terminated with a dot ("."); the root name is assumed to be the origin for the name. response-ip-tag: <IP-netblock> <"list of tags"> This requires use of the "respip" module. Assign tags to response IP-netblocks. If the IP address in an AAAA or A RR in the answer section of a response matches the spec- ified IP-netblock, the specified tags are assigned to the IP ad- dress. Then, if an access-control-tag is defined for the client and it includes one of the tags for the response IP, the corre- sponding access-control-tag-action will apply. Tag matching rule is the same as that for access-control-tag and local-zones. Un- like local-zone-tag, response-ip-tag can be defined for an IP-net- block even if no response-ip is defined for that netblock. If multiple response-ip-tag options are specified for the same IP- netblock in different statements, all but the first will be ig- nored. However, this will not be flagged as a configuration er- ror, but the result is probably not what was intended. Actions specified in an access-control-tag-action that has a matching tag with response-ip-tag can be those that are "invalid" for response-ip listed above, since access-control-tag-actions can be shared with local zones. For these actions, if they behave differently depending on whether local data exists or not in case of local zones, the behavior for response-ip-data will generally result in NOERROR/NODATA instead of NXDOMAIN, since the response- ip data are inherently type specific, and non-existence of data does not indicate anything about the existence or non-existence of the qname itself. For example, if the matching tag action is sta- tic but there is no data for the corresponding response-ip config- uration, then the result will be NOERROR/NODATA. The only case where NXDOMAIN is returned is when an always_nxdomain action ap- plies. ratelimit: <number or 0> Enable ratelimiting of queries sent to nameserver for performing recursion. If 0, the default, it is disabled. This option is ex- perimental at this time. The ratelimit is in queries per second that are allowed. More queries are turned away with an error (servfail). This stops recursive floods, eg. random query names, but not spoofed reflection floods. Cached responses are not rate- limited by this setting. The zone of the query is determined by examining the nameservers for it, the zone name is used to keep track of the rate. For example, 1000 may be a suitable value to stop the server from being overloaded with random names, and keeps Unbound from sending traffic to the nameservers for those zones. Configured forwarders are excluded from ratelimiting. ratelimit-size: <memory size> Give the size of the data structure in which the current ongoing rates are kept track in. Default 4m. In bytes or use m(mega), k(kilo), g(giga). The ratelimit structure is small, so this data structure likely does not need to be large. ratelimit-slabs: <number> Give power of 2 number of slabs, this is used to reduce lock con- tention in the ratelimit tracking data structure. Close to the number of cpus is a fairly good setting. ratelimit-factor: <number> Set the amount of queries to rate limit when the limit is ex- ceeded. If set to 0, all queries are dropped for domains where the limit is exceeded. If set to another value, 1 in that number is allowed through to complete. Default is 10, allowing 1/10 traffic to flow normally. This can make ordinary queries complete (if repeatedly queried for), and enter the cache, whilst also mit- igating the traffic flow by the factor given. ratelimit-backoff: <yes or no> If enabled, the ratelimit is treated as a hard failure instead of the default maximum allowed constant rate. When the limit is reached, traffic is ratelimited and demand continues to be kept track of for a 2 second rate window. No traffic is allowed, ex- cept for ratelimit-factor, until demand decreases below the con- figured ratelimit for a 2 second rate window. Useful to set rate- limit to a suspicious rate to aggressively limit unusually high traffic. Default is off. ratelimit-for-domain: <domain> <number qps or 0> Override the global ratelimit for an exact match domain name with the listed number. You can give this for any number of names. For example, for a top-level-domain you may want to have a higher limit than other names. A value of 0 will disable ratelimiting for that domain. ratelimit-below-domain: <domain> <number qps or 0> Override the global ratelimit for a domain name that ends in this name. You can give this multiple times, it then describes differ- ent settings in different parts of the namespace. The closest matching suffix is used to determine the qps limit. The rate for the exact matching domain name is not changed, use rate- limit-for-domain to set that, you might want to use different set- tings for a top-level-domain and subdomains. A value of 0 will disable ratelimiting for domain names that end in this name. ip-ratelimit: <number or 0> Enable global ratelimiting of queries accepted per IP address. This option is experimental at this time. The ratelimit is in queries per second that are allowed. More queries are completely dropped and will not receive a reply, SERVFAIL or otherwise. IP ratelimiting happens before looking in the cache. This may be use- ful for mitigating amplification attacks. Clients with a valid DNS Cookie will bypass the ratelimit. If a ratelimit for such clients is still needed, ip-ratelimit-cookie can be used instead. Default is 0 (disabled). ip-ratelimit-cookie: <number or 0> Enable global ratelimiting of queries accepted per IP address with a valid DNS Cookie. This option is experimental at this time. The ratelimit is in queries per second that are allowed. More queries are completely dropped and will not receive a reply, SERV- FAIL or otherwise. IP ratelimiting happens before looking in the cache. This option could be useful in combination with al- low_cookie in an attempt to mitigate other amplification attacks than UDP reflections (e.g., attacks targeting Unbound itself) which are already handled with DNS Cookies. If used, the value is suggested to be higher than ip-ratelimit e.g., tenfold. Default is 0 (disabled). ip-ratelimit-size: <memory size> Give the size of the data structure in which the current ongoing rates are kept track in. Default 4m. In bytes or use m(mega), k(kilo), g(giga). The ip ratelimit structure is small, so this data structure likely does not need to be large. ip-ratelimit-slabs: <number> Give power of 2 number of slabs, this is used to reduce lock con- tention in the ip ratelimit tracking data structure. Close to the number of cpus is a fairly good setting. ip-ratelimit-factor: <number> Set the amount of queries to rate limit when the limit is ex- ceeded. If set to 0, all queries are dropped for addresses where the limit is exceeded. If set to another value, 1 in that number is allowed through to complete. Default is 10, allowing 1/10 traffic to flow normally. This can make ordinary queries complete (if repeatedly queried for), and enter the cache, whilst also mit- igating the traffic flow by the factor given. ip-ratelimit-backoff: <yes or no> If enabled, the ratelimit is treated as a hard failure instead of the default maximum allowed constant rate. When the limit is reached, traffic is ratelimited and demand continues to be kept track of for a 2 second rate window. No traffic is allowed, ex- cept for ip-ratelimit-factor, until demand decreases below the configured ratelimit for a 2 second rate window. Useful to set ip-ratelimit to a suspicious rate to aggressively limit unusually high traffic. Default is off. outbound-msg-retry: <number> The number of retries, per upstream nameserver in a delegation, that Unbound will attempt in case a throwaway response is re- ceived. No response (timeout) contributes to the retry counter. If a forward/stub zone is used, this is the number of retries per nameserver in the zone. Default is 5. max-sent-count: <number> Hard limit on the number of outgoing queries Unbound will make while resolving a name, making sure large NS sets do not loop. Results in SERVFAIL when reached. It resets on query restarts (e.g., CNAME) and referrals. Default is 32. max-query-restarts: <number> Hard limit on the number of times Unbound is allowed to restart a query upon encountering a CNAME record. Results in SERVFAIL when reached. Changing this value needs caution as it can allow long CNAME chains to be accepted, where Unbound needs to verify (re- solve) each link individually. Default is 11. iter-scrub-ns: <number> Limit on the number of NS records allowed in an rrset of type NS, from the iterator scrubber. This protects the internals of the re- solver from overly large NS sets. Default is 20. iter-scrub-cname: <number> Limit on the number of CNAME, DNAME records in an answer, from the iterator scrubber. This protects the internals of the resolver from overly long indirection chains. Clips off the remainder of the reply packet at that point. Default is 11. max-global-quota: <number> Limit on the number of upstream queries sent out for an incoming query and its subqueries from recursion. It is not reset during the resolution. When it is exceeded the query is failed and the lookup process stops. Default is 200. fast-server-permil: <number> Specify how many times out of 1000 to pick from the set of fastest servers. 0 turns the feature off. A value of 900 would pick from the fastest servers 90 percent of the time, and would perform nor- mal exploration of random servers for the remaining time. When prefetch is enabled (or serve-expired), such prefetches are not sped up, because there is no one waiting for it, and it presents a good moment to perform server exploration. The fast-server-num op- tion can be used to specify the size of the fastest servers set. The default for fast-server-permil is 0. fast-server-num: <number> Set the number of servers that should be used for fast server se- lection. Only use the fastest specified number of servers with the fast-server-permil option, that turns this on or off. The default is to use the fastest 3 servers. answer-cookie: <yes or no> If enabled, Unbound will answer to requests containing DNS Cookies as specified in RFC 7873 and RFC 9018. Default is no. cookie-secret: <128 bit hex string> Server's secret for DNS Cookie generation. Useful to explicitly set for servers in an anycast deployment that need to share the secret in order to verify each other's Server Cookies. An example hex string would be "000102030405060708090a0b0c0d0e0f". Default is a 128 bits random secret generated at startup time. This op- tion is ignored if a cookie-secret-file is present. In that case the secrets from that file are used in DNS Cookie calculations. cookie-secret-file: <filename> File from which the secrets are read used in DNS Cookie calcula- tions. When this file exists, the secrets in this file are used and the secret specified by the cookie-secret option is ignored. Enable it by setting a filename, like "/usr/local/etc/un- bound_cookiesecrets.txt". The content of this file must be manip- ulated with the add_cookie_secret, drop_cookie_secret and acti- vate_cookie_secret commands to the unbound-control(8) tool. Please see that manpage on how to perform a safe cookie secret rollover. Default is "" (disabled). edns-client-string: <IP netblock> <string> Include an EDNS0 option containing configured ascii string in queries with destination address matching the configured IP net- block. This configuration option can be used multiple times. The most specific match will be used. edns-client-string-opcode: <opcode> EDNS0 option code for the edns-client-string option, from 0 to 1. A value from the `Reserved for Local/Experimental` range (65001-65534) should be used. Default is 65001. ede: <yes or no> If enabled, Unbound will respond with Extended DNS Error codes (RFC8914). These EDEs provide additional information with a re- sponse mainly for, but not limited to, DNS and DNSSEC errors. When the val-log-level option is also set to 2, responses with Ex- tended DNS Errors concerning DNSSEC failures will also contain a descriptive text message about the reason for the failure. De- fault is "no". ede-serve-expired: <yes or no> If enabled, Unbound will attach an Extended DNS Error (RFC8914) Code 3 - Stale Answer as EDNS0 option to the expired response. The ede option needs to be enabled as well for this to work. De- fault is "no". dns-error-reporting: <yes or no> If enabled, Unbound will send DNS Error Reports (RFC9567). The name servers need to express support by attaching the Report-Chan- nel EDNS0 option on their replies specifying the reporting agent for the zone. Any errors encountered during resolution that would result in Unbound generating an Extended DNS Error (RFC8914) will be reported to the zone's reporting agent. The ede option does not need to be enabled for this to work. It is advised that the qname-minimisation option is also enabled to increase privacy on the outgoing reports. Default is "no". Remote Control Options In the remote-control: clause are the declarations for the remote con- trol facility. If this is enabled, the unbound-control(8) utility can be used to send commands to the running Unbound server. The server uses these clauses to setup TLSv1 security for the connection. The un- bound-control(8) utility also reads the remote-control section for op- tions. To setup the correct self-signed certificates use the un- bound-control-setup(8) utility. control-enable: <yes or no> The option is used to enable remote control, default is "no". If turned off, the server does not listen for control commands. control-interface: <ip address or interface name or path> Give IPv4 or IPv6 addresses or local socket path to listen on for control commands. If an interface name is used instead of an ip address, the list of ip addresses on that interface are used. By default localhost (127.0.0.1 and ::1) is listened to. Use 0.0.0.0 and ::0 to listen to all interfaces. If you change this and per- missions have been dropped, you must restart the server for the change to take effect. If you set it to an absolute path, a unix domain socket is used. This socket does not use the certificates and keys, so those files need not be present. To restrict access, Unbound sets permissions on the file to the user and group that is configured, the access bits are set to allow the group members to access the control socket file. Put users that need to access the socket in the that group. To restrict access further, create a directory to put the control socket in and restrict access to that directory. control-port: <port number> The port number to listen on for IPv4 or IPv6 control interfaces, default is 8953. If you change this and permissions have been dropped, you must restart the server for the change to take ef- fect. control-use-cert: <yes or no> For localhost control-interface you can disable the use of TLS by setting this option to "no", default is "yes". For local sockets, TLS is disabled and the value of this option is ignored. server-key-file: <private key file> Path to the server private key, by default unbound_server.key. This file is generated by the unbound-control-setup utility. This file is used by the Unbound server, but not by unbound-control. server-cert-file: <certificate file.pem> Path to the server self signed certificate, by default un- bound_server.pem. This file is generated by the unbound-con- trol-setup utility. This file is used by the Unbound server, and also by unbound-control. control-key-file: <private key file> Path to the control client private key, by default unbound_con- trol.key. This file is generated by the unbound-control-setup utility. This file is used by unbound-control. control-cert-file: <certificate file.pem> Path to the control client certificate, by default unbound_con- trol.pem. This certificate has to be signed with the server cer- tificate. This file is generated by the unbound-control-setup utility. This file is used by unbound-control. Stub Zone Options There may be multiple stub-zone: clauses. Each with a name: and zero or more hostnames or IP addresses. For the stub zone this list of name- servers is used. Class IN is assumed. The servers should be authority servers, not recursors; Unbound performs the recursive processing it- self for stub zones. The stub zone can be used to configure authoritative data to be used by the resolver that cannot be accessed using the public internet servers. This is useful for company-local data or private zones. Setup an au- thoritative server on a different host (or different port). Enter a config entry for Unbound with stub-addr: <ip address of host[@port]>. The Unbound resolver can then access the data, without referring to the public internet for it. This setup allows DNSSEC signed zones to be served by that authorita- tive server, in which case a trusted key entry with the public key can be put in config, so that Unbound can validate the data and set the AD bit on replies for the private zone (authoritative servers do not set the AD bit). This setup makes Unbound capable of answering queries for the private zone, and can even set the AD bit ('authentic'), but the AA ('authoritative') bit is not set on these replies. Consider adding server: statements for domain-insecure: and for lo- cal-zone: name nodefault for the zone if it is a locally served zone. The insecure clause stops DNSSEC from invalidating the zone. The local zone nodefault (or transparent) clause makes the (reverse-) zone bypass Unbound's filtering of RFC1918 zones. name: <domain name> Name of the stub zone. This is the full domain name of the zone. stub-host: <domain name> Name of stub zone nameserver. Is itself resolved before it is used. To use a nondefault port for DNS communication append '@' with the port number. If tls is enabled, then you can append a '#' and a name, then it'll check the tls authentication certifi- cates with that name. If you combine the '@' and '#', the '@' comes first. If only '#' is used the default port is the con- figured tls-port. stub-addr: <IP address> IP address of stub zone nameserver. Can be IP 4 or IP 6. To use a nondefault port for DNS communication append '@' with the port number. If tls is enabled, then you can append a '#' and a name, then it'll check the tls authentication certificates with that name. If you combine the '@' and '#', the '@' comes first. If only '#' is used the default port is the configured tls-port. stub-prime: <yes or no> This option is by default no. If enabled it performs NS set priming, which is similar to root hints, where it starts using the list of nameservers currently published by the zone. Thus, if the hint list is slightly outdated, the resolver picks up a correct list online. stub-first: <yes or no> If enabled, a query is attempted without the stub clause if it fails. The data could not be retrieved and would have caused SERVFAIL because the servers are unreachable, instead it is tried without this clause. The default is no. stub-tls-upstream: <yes or no> Enabled or disable whether the queries to this stub use TLS for transport. Default is no. stub-ssl-upstream: <yes or no> Alternate syntax for stub-tls-upstream. stub-tcp-upstream: <yes or no> If it is set to "yes" then upstream queries use TCP only for transport regardless of global flag tcp-upstream. Default is no. stub-no-cache: <yes or no> Default is no. If enabled, data inside the stub is not cached. This is useful when you want immediate changes to be visible. Forward Zone Options There may be multiple forward-zone: clauses. Each with a name: and zero or more hostnames or IP addresses. For the forward zone this list of nameservers is used to forward the queries to. The servers listed as forward-host: and forward-addr: have to handle further recursion for the query. Thus, those servers are not authority servers, but are (just like Unbound is) recursive servers too; Unbound does not perform recursion itself for the forward zone, it lets the remote server do it. Class IN is assumed. CNAMEs are chased by Unbound itself, asking the remote server for every name in the indirection chain, to protect the local cache from illegal indirect referenced items. A forward-zone en- try with name "." and a forward-addr target will forward all queries to that other server (unless it can answer from the cache). name: <domain name> Name of the forward zone. This is the full domain name of the zone. forward-host: <domain name> Name of server to forward to. Is itself resolved before it is used. To use a nondefault port for DNS communication append '@' with the port number. If tls is enabled, then you can append a '#' and a name, then it'll check the tls authentication certifi- cates with that name. If you combine the '@' and '#', the '@' comes first. If only '#' is used the default port is the con- figured tls-port. forward-addr: <IP address> IP address of server to forward to. Can be IP 4 or IP 6. To use a nondefault port for DNS communication append '@' with the port number. If tls is enabled, then you can append a '#' and a name, then it'll check the tls authentication certificates with that name. If you combine the '@' and '#', the '@' comes first. If only '#' is used the default port is the configured tls-port. At high verbosity it logs the TLS certificate, with TLS enabled. If you leave out the '#' and auth name from the forward-addr, any name is accepted. The cert must also match a CA from the tls-cert-bundle. forward-first: <yes or no> If a forwarded query is met with a SERVFAIL error, and this op- tion is enabled, Unbound will fall back to normal recursive res- olution for this query as if no query forwarding had been speci- fied. The default is "no". forward-tls-upstream: <yes or no> Enabled or disable whether the queries to this forwarder use TLS for transport. Default is no. If you enable this, also config- ure a tls-cert-bundle or use tls-win-cert to load CA certs, oth- erwise the connections cannot be authenticated. forward-ssl-upstream: <yes or no> Alternate syntax for forward-tls-upstream. forward-tcp-upstream: <yes or no> If it is set to "yes" then upstream queries use TCP only for transport regardless of global flag tcp-upstream. Default is no. forward-no-cache: <yes or no> Default is no. If enabled, data inside the forward is not cached. This is useful when you want immediate changes to be visible. Authority Zone Options Authority zones are configured with auth-zone:, and each one must have a name:. There can be multiple ones, by listing multiple auth-zone clauses, each with a different name, pertaining to that part of the namespace. The authority zone with the name closest to the name looked up is used. Authority zones can be processed on two distinct, non-ex- clusive, configurable stages. With for-downstream: yes (default), authority zones are processed after local-zones and before cache. When used in this manner, Unbound re- sponds like an authority server with no further processing other than returning an answer from the zone contents. A notable example, in this case, is CNAME records which are returned verbatim to downstream clients without further resolution. With for-upstream: yes (default), authority zones are processed after the cache lookup, just before going to the network to fetch information for recursion. When used in this manner they provide a local copy of an authority server that speeds up lookups for that data during resolv- ing. If both options are enabled (default), client queries for an authority zone are answered authoritatively from Unbound, while internal queries that require data from the authority zone consult the local zone data instead of going to the network. An interesting configuration is for-downstream: no, for-upstream: yes that allows for hyperlocal behavior where both client and internal queries consult the local zone data while resolving. In this case, the aforementioned CNAME example will result in a thoroughly resolved an- swer. Authority zones can be read from zonefile. And can be kept updated via AXFR and IXFR. After update the zonefile is rewritten. The update mechanism uses the SOA timer values and performs SOA UDP queries to de- tect zone changes. If the update fetch fails, the timers in the SOA record are used to time another fetch attempt. Until the SOA expiry timer is reached. Then the zone is expired. When a zone is expired, queries are SERV- FAIL, and any new serial number is accepted from the primary (even if older), and if fallback is enabled, the fallback activates to fetch from the upstream instead of the SERVFAIL. name: <zone name> Name of the authority zone. primary: <IP address or host name> Where to download a copy of the zone from, with AXFR and IXFR. Multiple primaries can be specified. They are all tried if one fails. To use a nondefault port for DNS communication append '@' with the port number. You can append a '#' and a name, then AXFR over TLS can be used and the tls authentication certifi- cates will be checked with that name. If you combine the '@' and '#', the '@' comes first. If you point it at another Un- bound instance, it would not work because that does not support AXFR/IXFR for the zone, but if you used url: to download the zonefile as a text file from a webserver that would work. If you specify the hostname, you cannot use the domain from the zonefile, because it may not have that when retrieving that data, instead use a plain IP address to avoid a circular depen- dency on retrieving that IP address. master: <IP address or host name> Alternate syntax for primary. url: <url to zonefile> Where to download a zonefile for the zone. With http or https. An example for the url is "http://www.example.com/exam- ple.org.zone". Multiple url statements can be given, they are tried in turn. If only urls are given the SOA refresh timer is used to wait for making new downloads. If also primaries are listed, the primaries are first probed with UDP SOA queries to see if the SOA serial number has changed, reducing the number of downloads. If none of the urls work, the primaries are tried with IXFR and AXFR. For https, the tls-cert-bundle and the hostname from the url are used to authenticate the connection. If you specify a hostname in the URL, you cannot use the domain from the zonefile, because it may not have that when retrieving that data, instead use a plain IP address to avoid a circular dependency on retrieving that IP address. Avoid dependencies on name lookups by using a notation like "http://192.0.2.1/unbound- primaries/example.com.zone", with an explicit IP address. allow-notify: <IP address or host name or netblockIP/prefix> With allow-notify you can specify additional sources of noti- fies. When notified, the server attempts to first probe and then zone transfer. If the notify is from a primary, it first attempts that primary. Otherwise other primaries are attempted. If there are no primaries, but only urls, the file is downloaded when notified. The primaries from primary: and url: statements are allowed notify by default. fallback-enabled: <yes or no> Default no. If enabled, Unbound falls back to querying the in- ternet as a resolver for this zone when lookups fail. For exam- ple for DNSSEC validation failures. for-downstream: <yes or no> Default yes. If enabled, Unbound serves authority responses to downstream clients for this zone. This option makes Unbound be- have, for the queries with names in this zone, like one of the authority servers for that zone. Turn it off if you want Un- bound to provide recursion for the zone but have a local copy of zone data. If for-downstream is no and for-upstream is yes, then Unbound will DNSSEC validate the contents of the zone be- fore serving the zone contents to clients and store validation results in the cache. for-upstream: <yes or no> Default yes. If enabled, Unbound fetches data from this data collection for answering recursion queries. Instead of sending queries over the internet to the authority servers for this zone, it'll fetch the data directly from the zone data. Turn it on when you want Unbound to provide recursion for downstream clients, and use the zone data as a local copy to speed up lookups. zonemd-check: <yes or no> Enable this option to check ZONEMD records in the zone. Default is disabled. The ZONEMD record is a checksum over the zone data. This includes glue in the zone and data from the zone file, and excludes comments from the zone file. When there is a DNSSEC chain of trust, DNSSEC signatures are checked too. zonemd-reject-absence: <yes or no> Enable this option to reject the absence of the ZONEMD record. Without it, when zonemd is not there it is not checked. It is useful to enable for a nonDNSSEC signed zone where the operator wants to require the verification of a ZONEMD, hence a missing ZONEMD is a failure. The action upon failure is controlled by the zonemd-permissive-mode option, for log only or also block the zone. The default is no. Without the option absence of a ZONEMD is only a failure when the zone is DNSSEC signed, and we have a trust anchor, and the DNSSEC verification of the absence of the ZONEMD fails. With the option enabled, the absence of a ZONEMD is always a failure, also for nonDNSSEC signed zones. zonefile: <filename> The filename where the zone is stored. If not given then no zonefile is used. If the file does not exist or is empty, Un- bound will attempt to fetch zone data (eg. from the primary servers). View Options There may be multiple view: clauses. Each with a name: and zero or more local-zone and local-data elements. Views can also contain view-first, response-ip, response-ip-data and local-data-ptr elements. View can be mapped to requests by specifying the view name in an access-con- trol-view element. Options from matching views will override global op- tions. Global options will be used if no matching view is found, or when the matching view does not have the option specified. name: <view name> Name of the view. Must be unique. This name is used in ac- cess-control-view elements. local-zone: <zone> <type> View specific local-zone elements. Has the same types and behav- iour as the global local-zone elements. When there is at least one local-zone specified and view-first is no, the default lo- cal-zones will be added to this view. Defaults can be disabled using the nodefault type. When view-first is yes or when a view does not have a local-zone, the global local-zone will be used including it's default zones. local-data: "<resource record string>" View specific local-data elements. Has the same behaviour as the global local-data elements. local-data-ptr: "IPaddr name" View specific local-data-ptr elements. Has the same behaviour as the global local-data-ptr elements. view-first: <yes or no> If enabled, it attempts to use the global local-zone and lo- cal-data if there is no match in the view specific options. The default is no. Python Module Options The python: clause gives the settings for the python(1) script module. This module acts like the iterator and validator modules do, on queries and answers. To enable the script module it has to be compiled into the daemon, and the word "python" has to be put in the module-config: option (usually first, or between the validator and iterator). Multiple instances of the python module are supported by adding the word "python" more than once. If the chroot: option is enabled, you should make sure Python's library directory structure is bind mounted in the new root environment, see mount(8). Also the python-script: path should be specified as an ab- solute path relative to the new root, or as a relative path to the working directory. python-script: <python file> The script file to load. Repeat this option for every python module instance added to the module-config: option. Dynamic Library Module Options The dynlib: clause gives the settings for the dynlib module. This mod- ule is only a very small wrapper that allows dynamic modules to be loaded on runtime instead of being compiled into the application. To enable the dynlib module it has to be compiled into the daemon, and the word "dynlib" has to be put in the module-config: option. Multiple in- stances of dynamic libraries are supported by adding the word "dynlib" more than once. The dynlib-file: path should be specified as an absolute path relative to the new path set by chroot: option, or as a relative path to the working directory. dynlib-file: <dynlib file> The dynamic library file to load. Repeat this option for every dynlib module instance added to the module-config: option. DNS64 Module Options The dns64 module must be configured in the module-config: directive e.g., "dns64 validator iterator" and be compiled into the daemon to be enabled. These settings go in the server: section. dns64-prefix: <IPv6 prefix> This sets the DNS64 prefix to use to synthesize AAAA records with. It must be /96 or shorter. The default prefix is 64:ff9b::/96. dns64-synthall: <yes or no> Debug option, default no. If enabled, synthesize all AAAA records despite the presence of actual AAAA records. dns64-ignore-aaaa: <name> List domain for which the AAAA records are ignored and the A record is used by dns64 processing instead. Can be entered mul- tiple times, list a new domain for which it applies, one per line. Applies also to names underneath the name given. NAT64 Operation NAT64 operation allows using a NAT64 prefix for outbound requests to IPv4-only servers. It is controlled by two options in the server: sec- tion: do-nat64: <yes or no> Use NAT64 to reach IPv4-only servers. Consider also enabling prefer-ip6 to prefer native IPv6 connections to nameservers. Default no. nat64-prefix: <IPv6 prefix> Use a specific NAT64 prefix to reach IPv4-only servers. De- faults to using the prefix configured in dns64-prefix, which in turn defaults to 64:ff9b::/96. The prefix length must be one of /32, /40, /48, /56, /64 or /96. DNSCrypt Options The dnscrypt: clause gives the settings of the dnscrypt channel. While those options are available, they are only meaningful if Unbound was compiled with --enable-dnscrypt. Currently certificate and secret/pub- lic keys cannot be generated by Unbound. You can use dnscrypt-wrapper to generate those: <https://github.com/cofyc/dnscrypt-wrapper/blob/mas-> ter/README.md#usage dnscrypt-enable: <yes or no> Whether or not the dnscrypt config should be enabled. You may define configuration but not activate it. The default is no. dnscrypt-port: <port number> On which port should dnscrypt should be activated. Note that you should have a matching interface option defined in the server section for this port. dnscrypt-provider: <provider name> The provider name to use to distribute certificates. This is of the form: 2.dnscrypt-cert.example.com.. The name MUST end with a dot. dnscrypt-secret-key: <path to secret key file> Path to the time limited secret key file. This option may be specified multiple times. dnscrypt-provider-cert: <path to cert file> Path to the certificate related to the dnscrypt-secret-keys. This option may be specified multiple times. dnscrypt-provider-cert-rotated: <path to cert file> Path to a certificate that we should be able to serve existing connection from but do not want to advertise over dnscrypt-provider's TXT record certs distribution. A typical use case is when rotating certificates, existing clients may still use the client magic from the old cert in their queries until they fetch and update the new cert. Likewise, it would al- low one to prime the new cert/key without distributing the new cert yet, this can be useful when using a network of servers us- ing anycast and on which the configuration may not get updated at the exact same time. By priming the cert, the servers can handle both old and new certs traffic while distributing only one. This option may be specified multiple times. dnscrypt-shared-secret-cache-size: <memory size> Give the size of the data structure in which the shared secret keys are kept in. Default 4m. In bytes or use m(mega), k(kilo), g(giga). The shared secret cache is used when a same client is making multiple queries using the same public key. It saves a substantial amount of CPU. dnscrypt-shared-secret-cache-slabs: <number> Give power of 2 number of slabs, this is used to reduce lock contention in the dnscrypt shared secrets cache. Close to the number of cpus is a fairly good setting. dnscrypt-nonce-cache-size: <memory size> Give the size of the data structure in which the client nonces are kept in. Default 4m. In bytes or use m(mega), k(kilo), g(giga). The nonce cache is used to prevent dnscrypt message replaying. Client nonce should be unique for any pair of client pk/server sk. dnscrypt-nonce-cache-slabs: <number> Give power of 2 number of slabs, this is used to reduce lock contention in the dnscrypt nonce cache. Close to the number of cpus is a fairly good setting. EDNS Client Subnet Module Options The ECS module must be configured in the module-config: directive e.g., "subnetcache validator iterator" and be compiled into the daemon to be enabled. These settings go in the server: section. If the destination address is allowed in the configuration Unbound will add the EDNS0 option to the query containing the relevant part of the client's address. When an answer contains the ECS option the response and the option are placed in a specialized cache. If the authority in- dicated no support, the response is stored in the regular cache. Additionally, when a client includes the option in its queries, Unbound will forward the option when sending the query to addresses that are explicitly allowed in the configuration using send-client-subnet. The option will always be forwarded, regardless the allowed addresses, if client-subnet-always-forward is set to yes. In this case the lookup in the regular cache is skipped. The maximum size of the ECS cache is controlled by 'msg-cache-size' in the configuration file. On top of that, for each query only 100 differ- ent subnets are allowed to be stored for each address family. Exceeding that number, older entries will be purged from cache. Note that due to the nature of how EDNS Client Subnet works, by segre- gating the client IP space in order to try and have tailored responses for prefixes of unknown sizes, resolution and cache response perfor- mance are impacted as a result. Usage of the subnetcache module should only be enabled in installations that require such functionality where the resolver and the clients belong to different networks. An example of that is an open resolver installation. This module does not interact with the serve-expired* and prefetch: op- tions. send-client-subnet: <IP address> Send client source address to this authority. Append /num to in- dicate a classless delegation netblock, for example like 10.2.3.4/24 or 2001::11/64. Can be given multiple times. Author- ities not listed will not receive edns-subnet information, un- less domain in query is specified in client-subnet-zone. client-subnet-zone: <domain> Send client source address in queries for this domain and its subdomains. Can be given multiple times. Zones not listed will not receive edns-subnet information, unless hosted by authority specified in send-client-subnet. client-subnet-always-forward: <yes or no> Specify whether the ECS address check (configured using send-client-subnet) is applied for all queries, even if the triggering query contains an ECS record, or only for queries for which the ECS record is generated using the querier address (and therefore did not contain ECS data in the client query). If en- abled, the address check is skipped when the client query con- tains an ECS record. And the lookup in the regular cache is skipped. Default is no. max-client-subnet-ipv6: <number> Specifies the maximum prefix length of the client source address we are willing to expose to third parties for IPv6. Defaults to 56. max-client-subnet-ipv4: <number> Specifies the maximum prefix length of the client source address we are willing to expose to third parties for IPv4. Defaults to 24. min-client-subnet-ipv6: <number> Specifies the minimum prefix length of the IPv6 source mask we are willing to accept in queries. Shorter source masks result in REFUSED answers. Source mask of 0 is always accepted. Default is 0. min-client-subnet-ipv4: <number> Specifies the minimum prefix length of the IPv4 source mask we are willing to accept in queries. Shorter source masks result in REFUSED answers. Source mask of 0 is always accepted. Default is 0. max-ecs-tree-size-ipv4: <number> Specifies the maximum number of subnets ECS answers kept in the ECS radix tree. This number applies for each qname/qclass/qtype tuple. Defaults to 100. max-ecs-tree-size-ipv6: <number> Specifies the maximum number of subnets ECS answers kept in the ECS radix tree. This number applies for each qname/qclass/qtype tuple. Defaults to 100. Opportunistic IPsec Support Module Options The IPsec module must be configured in the module-config: directive e.g., "ipsecmod validator iterator" and be compiled into Unbound by us- ing --enable-ipsecmod to be enabled. These settings go in the server: section. When Unbound receives an A/AAAA query that is not in the cache and finds a valid answer, it will withhold returning the answer and instead will generate an IPSECKEY subquery for the same domain name. If an an- swer was found, Unbound will call an external hook passing the follow- ing arguments: QNAME Domain name of the A/AAAA and IPSECKEY query. In string for- mat. IPSECKEY TTL TTL of the IPSECKEY RRset. A/AAAA String of space separated IP addresses present in the A/AAAA RRset. The IP addresses are in string format. IPSECKEY String of space separated IPSECKEY RDATA present in the IPSECKEY RRset. The IPSECKEY RDATA are in DNS presentation format. The A/AAAA answer is then cached and returned to the client. If the external hook was called the TTL changes to ensure it doesn't surpass ipsecmod-max-ttl. The same procedure is also followed when prefetch: is used, but the A/AAAA answer is given to the client before the hook is called. ipsec- mod-max-ttl ensures that the A/AAAA answer given from cache is still relevant for opportunistic IPsec. ipsecmod-enabled: <yes or no> Specifies whether the IPsec module is enabled or not. The IPsec module still needs to be defined in the module-config: direc- tive. This option facilitates turning on/off the module without restarting/reloading Unbound. Defaults to yes. ipsecmod-hook: <filename> Specifies the external hook that Unbound will call with sys- tem(3). The file can be specified as an absolute/relative path. The file needs the proper permissions to be able to be executed by the same user that runs Unbound. It must be present when the IPsec module is defined in the module-config: directive. ipsecmod-strict: <yes or no> If enabled Unbound requires the external hook to return a suc- cess value of 0. Failing to do so Unbound will reply with SERV- FAIL. The A/AAAA answer will also not be cached. Defaults to no. ipsecmod-max-ttl: <seconds> Time to live maximum for A/AAAA cached records after calling the external hook. Defaults to 3600. ipsecmod-ignore-bogus: <yes or no> Specifies the behaviour of Unbound when the IPSECKEY answer is bogus. If set to yes, the hook will be called and the A/AAAA answer will be returned to the client. If set to no, the hook will not be called and the answer to the A/AAAA query will be SERVFAIL. Mainly used for testing. Defaults to no. ipsecmod-allow: <domain> Allow the ipsecmod functionality for the domain so that the mod- ule logic will be executed. Can be given multiple times, for different domains. If the option is not specified, all domains are treated as being allowed (default). ipsecmod-whitelist: <domain> Alternate syntax for ipsecmod-allow. Cache DB Module Options The Cache DB module must be configured in the module-config: directive e.g., "validator cachedb iterator" and be compiled into the daemon with --enable-cachedb. If this module is enabled and configured, the speci- fied backend database works as a second level cache: When Unbound can- not find an answer to a query in its built-in in-memory cache, it con- sults the specified backend. If it finds a valid answer in the back- end, Unbound uses it to respond to the query without performing itera- tive DNS resolution. If Unbound cannot even find an answer in the backend, it resolves the query as usual, and stores the answer in the backend. This module interacts with the serve-expired-* options and will reply with expired data if Unbound is configured for that. If Unbound was built with --with-libhiredis on a system that has in- stalled the hiredis C client library of Redis, then the "redis" backend can be used. This backend communicates with the specified Redis server over a TCP connection to store and retrieve cache data. It can be used as a persistent and/or shared cache backend. It should be noted that Unbound never removes data stored in the Redis server, even if some data have expired in terms of DNS TTL or the Redis server has cached too much data; if necessary the Redis server must be configured to limit the cache size, preferably with some kind of least-recently-used eviction policy. Additionally, the redis-expire-records option can be used in order to set the relative DNS TTL of the message as timeout to the Redis records; keep in mind that some additional memory is used per key and that the expire information is stored as absolute Unix time- stamps in Redis (computer time must be stable). This backend uses syn- chronous communication with the Redis server based on the assumption that the communication is stable and sufficiently fast. The thread waiting for a response from the Redis server cannot handle other DNS queries. Although the backend has the ability to reconnect to the server when the connection is closed unexpectedly and there is a con- figurable timeout in case the server is overly slow or hangs up, these cases are assumed to be very rare. If connection close or timeout hap- pens too often, Unbound will be effectively unusable with this backend. It's the administrator's responsibility to make the assumption hold. The cachedb: clause gives custom settings of the cache DB module. backend: <backend name> Specify the backend database name. The default database is the in-memory backend named "testframe", which, as the name sug- gests, is not of any practical use. Depending on the build-time configuration, "redis" backend may also be used as described above. secret-seed: <"secret string"> Specify a seed to calculate a hash value from query information. This value will be used as the key of the corresponding answer for the backend database and can be customized if the hash should not be predictable operationally. If the backend data- base is shared by multiple Unbound instances, all instances must use the same secret seed. This option defaults to "default". cachedb-no-store: <yes or no> If the backend should be read from, but not written to. This makes this instance not store dns messages in the backend. But if data is available it is retrieved. The default is no. cachedb-check-when-serve-expired: <yes or no> If enabled, the cachedb is checked before an expired response is returned. When serve-expired is enabled, without serve-ex- pired-client-timeout, it then does not immediately respond with an expired response from cache, but instead first checks the cachedb for valid contents, and if so returns it. If the cachedb also has no valid contents, the serve expired response is sent. If also serve-expired-client-timeout is enabled, the expired re- sponse is delayed until the timeout expires. Unless the lookup succeeds within the timeout. The default is yes. The following cachedb options are specific to the redis backend. redis-server-host: <server address or name> The IP (either v6 or v4) address or domain name of the Redis server. In general an IP address should be specified as other- wise Unbound will have to resolve the name of the server every time it establishes a connection to the server. This option de- faults to "127.0.0.1". redis-server-port: <port number> The TCP port number of the Redis server. This option defaults to 6379. redis-server-path: <unix socket path> The unix socket path to connect to the Redis server. Off by de- fault, and it can be set to "" to turn this off. Unix sockets may have better throughput than the IP address option. redis-server-password: "<password>" The Redis AUTH password to use for the Redis server. Only rele- vant if Redis is configured for client password authorisation. Off by default, and it can be set to "" to turn this off. redis-timeout: <msec> The period until when Unbound waits for a response from the Re- dis sever. If this timeout expires Unbound closes the connec- tion, treats it as if the Redis server does not have the re- quested data, and will try to re-establish a new connection later. This option defaults to 100 milliseconds. redis-command-timeout: <msec> The timeout to use for Redis commands, in milliseconds. If 0, it uses the redis-timeout value. The default is 0. redis-connect-timeout: <msec> The timeout to use for Redis connection set up, in milliseconds. If 0, it uses the redis-timeout value. The default is 0. redis-expire-records: <yes or no> If Redis record expiration is enabled. If yes, Unbound sets timeout for Redis records so that Redis can evict keys that have expired automatically. If Unbound is configured with serve-ex- pired and serve-expired-ttl is 0, this option is internally re- verted to "no". Redis SETEX support is required for this option (Redis >= 2.0.0). This option defaults to no. redis-logical-db: <logical database index> The logical database in Redis to use. These are databases in the same Redis instance sharing the same configuration and per- sisted in the same RDB/AOF file. If unsure about using this op- tion, Redis documentation (https://redis.io/commands/select/) suggests not to use a single Redis instance for multiple unre- lated applications. The default database in Redis is 0 while other logical databases need to be explicitly SELECT'ed upon connecting. This option defaults to 0. redis-replica-server-host: <server address or name> The IP (either v6 or v4) address or domain name of the Redis replica server. In general an IP address should be specified as otherwise Unbound will have to resolve the name of the server every time it establishes a connection to the server. This server is treated as a read-only replica server (https://re- dis.io/docs/management/replication/#read-only-replica). If specified, all Redis read commands will go to this replica server, while the write commands will go to the redis-server- host. This option defaults to "" (disabled). redis-replica-server-port: <port number> The TCP port number of the Redis replica server. This option defaults to 6379. redis-replica-server-path: <unix socket path> The unix socket path to connect to the Redis server. Off by de- fault, and it can be set to "" to turn this off. Unix sockets may have better throughput than the IP address option. redis-replica-server-password: "<password>" The Redis AUTH password to use for the Redis replica server. Only relevant if Redis is configured for client password autho- risation. Off by default, and it can be set to "" to turn this off. redis-replica-timeout: <msec> The period until when Unbound waits for a response from the Re- dis replica sever. If this timeout expires Unbound closes the connection, treats it as if the Redis replica server does not have the requested data, and will try to re-establish a new con- nection later. This option defaults to 100 milliseconds. redis-replica-command-timeout: <msec> The timeout to use for Redis replica commands, in milliseconds. If 0, it uses the redis-replica-timeout value. The default is 0. redis-replica-connect-timeout: <msec> The timeout to use for Redis replica connection set up, in mil- liseconds. If 0, it uses the redis-replica-timeout value. The default is 0. redis-replica-logical-db: <logical database index> Same as redis-logical-db but for the Redis replica server. This option defaults to 0. DNSTAP Logging Options DNSTAP support, when compiled in by using --enable-dnstap, is enabled in the dnstap: section. This starts an extra thread (when compiled with threading) that writes the log information to the destination. If Unbound is compiled without threading it does not spawn a thread, but connects per-process to the destination. dnstap-enable: <yes or no> If dnstap is enabled. Default no. If yes, it connects to the dnstap server and if any of the dnstap-log-..-messages options is enabled it sends logs for those messages to the server. dnstap-bidirectional: <yes or no> Use frame streams in bidirectional mode to transfer DNSTAP mes- sages. Default is yes. dnstap-socket-path: <file name> Sets the unix socket file name for connecting to the server that is listening on that socket. Default is "". dnstap-ip: <IPaddress[@port]> If "", the unix socket is used, if set with an IP address (IPv4 or IPv6) that address is used to connect to the server. dnstap-tls: <yes or no> Set this to use TLS to connect to the server specified in dnstap-ip. The default is yes. If set to no, TCP is used to connect to the server. dnstap-tls-server-name: <name of TLS authentication> The TLS server name to authenticate the server with. Used when dnstap-tls is enabled. If "" it is ignored, default "". dnstap-tls-cert-bundle: <file name of cert bundle> The pem file with certs to verify the TLS server certificate. If "" the server default cert bundle is used, or the windows cert bundle on windows. Default is "". dnstap-tls-client-key-file: <file name> The client key file for TLS client authentication. If "" client authentication is not used. Default is "". dnstap-tls-client-cert-file: <file name> The client cert file for TLS client authentication. Default is "". dnstap-send-identity: <yes or no> If enabled, the server identity is included in the log messages. Default is no. dnstap-send-version: <yes or no> If enabled, the server version if included in the log messages. Default is no. dnstap-identity: <string> The identity to send with messages, if "" the hostname is used. Default is "". dnstap-version: <string> The version to send with messages, if "" the package version is used. Default is "". dnstap-sample-rate: <number> The sample rate for log of messages, it logs only 1/N messages. With 0 it is disabled. Default is 0. This is useful in a high volume environment, where log functionality would otherwise not be reliable. For example 10 would spend only 1/10th time on log- ging, and 100 would only spend a hundredth of the time on log- ging. dnstap-log-resolver-query-messages: <yes or no> Enable to log resolver query messages. Default is no. These are messages from Unbound to upstream servers. dnstap-log-resolver-response-messages: <yes or no> Enable to log resolver response messages. Default is no. These are replies from upstream servers to Unbound. dnstap-log-client-query-messages: <yes or no> Enable to log client query messages. Default is no. These are client queries to Unbound. dnstap-log-client-response-messages: <yes or no> Enable to log client response messages. Default is no. These are responses from Unbound to clients. dnstap-log-forwarder-query-messages: <yes or no> Enable to log forwarder query messages. Default is no. dnstap-log-forwarder-response-messages: <yes or no> Enable to log forwarder response messages. Default is no. Response Policy Zone Options Response Policy Zones are configured with rpz:, and each one must have a name:. There can be multiple ones, by listing multiple RPZ clauses, each with a different name. RPZ clauses are applied in order of config- uration and any match from an earlier RPZ zone will terminate the RPZ lookup. Note that a PASSTHRU action is still considered a match. The respip module needs to be added to the module-config, e.g.: module-con- fig: "respip validator iterator". QNAME, Response IP Address, nsdname, nsip and clientip triggers are supported. Supported actions are: NXDOMAIN, NODATA, PASSTHRU, DROP, Local Data, tcp-only and drop. RPZ QNAME triggers are applied after local-zones and before auth-zones. The RPZ zone is a regular DNS zone formatted with a SOA start record as usual. The items in the zone are entries, that specify what to act on (the trigger) and what to do (the action). The trigger to act on is recorded in the name, the action to do is recorded as the resource record. The names all end in the zone name, so you could type the trigger names without a trailing dot in the zonefile. An example RPZ record, that answers example.com with NXDOMAIN example.com CNAME . The triggers are encoded in the name on the left name query name netblock.rpz-client-ip client IP address netblock.rpz-ip response IP address in the answer name.rpz-nsdname nameserver name netblock.rpz-nsip nameserver IP address The netblock is written as <netblocklen>.<ip address in reverse>. For IPv6 use 'zz' for '::'. Specify individual addresses with scope length of 32 or 128. For example, 24.10.100.51.198.rpz-ip is 198.51.100.10/24 and 32.10.zz.db8.2001.rpz-ip is 2001:db8:0:0:0:0:0:10/32. The actions are specified with the record on the right CNAME . nxdomain reply CNAME *. nodata reply CNAME rpz-passthru. do nothing, allow to continue CNAME rpz-drop. the query is dropped CNAME rpz-tcp-only. answer over TCP A 192.0.2.1 answer with this IP address Other records like AAAA, TXT and other CNAMEs (not rpz-..) can also be used to answer queries with that content. The RPZ zones can be configured in the config file with these settings in the rpz: block. name: <zone name> Name of the authority zone. primary: <IP address or host name> Where to download a copy of the zone from, with AXFR and IXFR. Multiple primaries can be specified. They are all tried if one fails. To use a nondefault port for DNS communication append '@' with the port number. You can append a '#' and a name, then AXFR over TLS can be used and the tls authentication certifi- cates will be checked with that name. If you combine the '@' and '#', the '@' comes first. If you point it at another Un- bound instance, it would not work because that does not support AXFR/IXFR for the zone, but if you used url: to download the zonefile as a text file from a webserver that would work. If you specify the hostname, you cannot use the domain from the zonefile, because it may not have that when retrieving that data, instead use a plain IP address to avoid a circular depen- dency on retrieving that IP address. master: <IP address or host name> Alternate syntax for primary. url: <url to zonefile> Where to download a zonefile for the zone. With http or https. An example for the url is "http://www.example.com/exam- ple.org.zone". Multiple url statements can be given, they are tried in turn. If only urls are given the SOA refresh timer is used to wait for making new downloads. If also primaries are listed, the primaries are first probed with UDP SOA queries to see if the SOA serial number has changed, reducing the number of downloads. If none of the urls work, the primaries are tried with IXFR and AXFR. For https, the tls-cert-bundle and the hostname from the url are used to authenticate the connection. allow-notify: <IP address or host name or netblockIP/prefix> With allow-notify you can specify additional sources of noti- fies. When notified, the server attempts to first probe and then zone transfer. If the notify is from a primary, it first attempts that primary. Otherwise other primaries are attempted. If there are no primaries, but only urls, the file is downloaded when notified. The primaries from primary: and url: statements are allowed notify by default. zonefile: <filename> The filename where the zone is stored. If not given then no zonefile is used. If the file does not exist or is empty, Un- bound will attempt to fetch zone data (eg. from the primary servers). rpz-action-override: <action> Always use this RPZ action for matching triggers from this zone. Possible action are: nxdomain, nodata, passthru, drop, disabled and cname. rpz-cname-override: <domain> The CNAME target domain to use if the cname action is configured for rpz-action-override. rpz-log: <yes or no> Log all applied RPZ actions for this RPZ zone. Default is no. rpz-log-name: <name> Specify a string to be part of the log line, for easy referenc- ing. rpz-signal-nxdomain-ra: <yes or no> Signal when a query is blocked by the RPZ with NXDOMAIN with an unset RA flag. This allows certain clients, like dnsmasq, to infer that the domain is externally blocked. Default is no. for-downstream: <yes or no> If enabled the zone is authoritatively answered for and queries for the RPZ zone information are answered to downstream clients. This is useful for monitoring scripts, that can then access the SOA information to check if the RPZ information is up to date. Default is no. tags: <list of tags> Limit the policies from this RPZ clause to clients with a match- ing tag. Tags need to be defined in define-tag and can be as- signed to client addresses using access-control-tag. Enclose list of tags in quotes ("") and put spaces between tags. If no tags are specified the policies from this clause will be applied for all clients. MEMORY CONTROL EXAMPLE In the example config settings below memory usage is reduced. Some ser- vice levels are lower, notable very large data and a high TCP load are no longer supported. Very large data and high TCP loads are exceptional for the DNS. DNSSEC validation is enabled, just add trust anchors. If you do not have to worry about programs using more than 3 Mb of memory, the below example is not for you. Use the defaults to receive full ser- vice, which on BSD-32bit tops out at 30-40 Mb after heavy usage. # example settings that reduce memory usage server: num-threads: 1 outgoing-num-tcp: 1 # this limits TCP service, uses less buffers. incoming-num-tcp: 1 outgoing-range: 60 # uses less memory, but less performance. msg-buffer-size: 8192 # note this limits service, 'no huge stuff'. msg-cache-size: 100k msg-cache-slabs: 1 rrset-cache-size: 100k rrset-cache-slabs: 1 infra-cache-numhosts: 200 infra-cache-slabs: 1 key-cache-size: 100k key-cache-slabs: 1 neg-cache-size: 10k num-queries-per-thread: 30 target-fetch-policy: "2 1 0 0 0 0" harden-large-queries: "yes" harden-short-bufsize: "yes" FILES /usr/local/etc/unbound default Unbound working directory. /usr/local/etc/unbound default chroot(2) location. /usr/local/etc/unbound/unbound.conf Unbound configuration file. /usr/local/etc/unbound/unbound.pid default Unbound pidfile with process ID of the running daemon. unbound.log Unbound log file. default is to log to syslog(3). SEE ALSO unbound(8), unbound-checkconf(8). AUTHORS Unbound was written by NLnet Labs. Please see CREDITS file in the dis- tribution for further details. NLnet Labs Apr 24, 2025 unbound.conf(5)

May 22, 2025

Debian 编译安装 unbound

unbound 简介 Unbound是一款验证型、递归式、带缓存的DNS解析器,旨在实现快速与轻量化,并融合了基于开放标准的现代特性。 为增强在线隐私保护,Unbound支持DNS-over-TLS和DNS-over-HTTPS,使客户端能够加密通信。此外,它还支持多种现代标准,这些标准不仅减少了与权威服务器交换的数据量,提升了隐私性,还增强了DNS的健壮性。其中最为关键的技术包括查询名称最小化、积极利用DNSSEC验证缓存,以及对权威区域的支持,后者可用于加载根区域副本。 Unbound兼容所有Linux和BSD发行版,以及macOS,大多数平台均有现成安装包。它已被纳入所有主要BSD操作系统的基础系统,以及大多数Linux发行版的标准软件库中,安装与配置简便易行,仅需几行配置即可为单机或网络设置解析器。 作为遵循BSD许可证的自由开源软件,Unbound的产品开发路线图首要关注用户的安全与隐私。同时,所有功能均需依托成熟的开放标准。我们持续为所有用户优化Unbound的功能,这意味着我们不会为付费客户定制构建或提供专属功能。我们的优先级由用户反馈,特别是拥有支持合同的用户,以及更广泛的互联网社区所引导。在可能的情况下,赞助功能将获得更高优先级,并会逐案评估。 Source 安装必要的依赖 sudo apt update sudo apt install -y build-essential libssl-dev bison flex libhiredis-dev libevent-dev libsystemd-dev pkg-config make dns-root-data 下载并编译安装 unbound git clone https://github.com/NLnetLabs/unbound cd unbound ./configure --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ --runstatedir=/run \ --with-username=unbound \ --with-ssl \ --with-libevent \ --enable-systemd \ --enable-subnet \ --enable-tfo-client \ --enable-tfo-server \ --enable-cachedb \ --with-libhiredis \ --disable-rpath \ --with-pidfile=/run/unbound/unbound.pid \ --with-rootkey-file=/var/lib/unbound/root.key \ --with-libnghttp2 \ --with-libsodium \ --with-pthreads \ --with-chroot-dir= make && make install 说明 `configure' 配置 unbound 1.23.1 以适应多种类型的系统。 用法: ./configure [选项]... [变量=值]... 要分配环境变量 (例如 CC, CFLAGS...), 请将它们指定为 变量=值。有关一些有用变量的描述,请参见下文。 选项的默认值在中括号内指定。 配置: -h, --help 显示此帮助信息并退出 --help=short 显示此软件包特有的选项 --help=recursive 显示所有包含的软件包的简短帮助信息 -V, --version 显示版本信息并退出 -q, --quiet, --silent 不打印 `checking ...' 消息 --cache-file=FILE 将测试结果缓存在 FILE 中 [禁用] -C, --config-cache `--cache-file=config.cache' 的别名 -n, --no-create 不创建输出文件 --srcdir=DIR 在 DIR 中查找源代码 [配置目录或 `..'] 安装目录: --prefix=PREFIX 将与体系结构无关的文件安装在 PREFIX 中 [/usr/local] --exec-prefix=EPREFIX 将与体系结构相关的文件安装在 EPREFIX 中 [PREFIX] 默认情况下, `make install' 会将所有文件安装在 `/usr/local/bin', `/usr/local/lib' 等目录中。您可以使用 `--prefix` 指定一个不同于 `/usr/local' 的安装前缀, 例如 `--prefix=$HOME'。 为了更好地控制,请使用以下选项。 微调安装目录: --bindir=DIR 用户可执行文件 [EPREFIX/bin] --sbindir=DIR 系统管理员可执行文件 [EPREFIX/sbin] --libexecdir=DIR 程序可执行文件 [EPREFIX/libexec] --sysconfdir=DIR 只读的单机数据 [PREFIX/etc] --sharedstatedir=DIR 可修改的与体系结构无关的数据 [PREFIX/com] --localstatedir=DIR 可修改的单机数据 [PREFIX/var] --runstatedir=DIR 可修改的每进程数据 [LOCALSTATEDIR/run] --libdir=DIR 目标代码库 [EPREFIX/lib] --includedir=DIR C 头文件 [PREFIX/include] --oldincludedir=DIR 非 gcc 的 C 头文件 [/usr/include] --datarootdir=DIR 只读的与体系结构无关的数据根目录 [PREFIX/share] --datadir=DIR 只读的与体系结构无关的数据 [DATAROOTDIR] --infodir=DIR info 文档 [DATAROOTDIR/info] --localedir=DIR 区域设置相关的数据 [DATAROOTDIR/locale] --mandir=DIR man 文档 [DATAROOTDIR/man] --docdir=DIR 文档根目录 [DATAROOTDIR/doc/unbound] --htmldir=DIR html 文档 [DOCDIR] --dvidir=DIR dvi 文档 [DOCDIR] --pdfdir=DIR pdf 文档 [DOCDIR] --psdir=DIR ps 文档 [DOCDIR] 系统类型: --build=BUILD 为在 BUILD 上构建进行配置 [猜测值] --host=HOST 交叉编译以构建在 HOST 上运行的程序 [BUILD] 可选特性: --disable-option-checking 忽略无法识别的 --enable/--with 选项 --disable-FEATURE 不包含 FEATURE (等同于 --enable-FEATURE=no) --enable-FEATURE[=ARG] 包含 FEATURE [ARG=yes] --enable-checking 启用警告、断言、makefile 依赖关系 --enable-debug 等同于 enable-checking --disable-flto 禁用链接时优化 (gcc 特定选项) --enable-pie 启用位置无关可执行文件 (例如,为了充分 利用 ASLR,会有少量性能损失) --enable-relro-now 在加载时启用完全重定位绑定 (RELRO NOW, 以保护 GOT 和 .dtor 区域) --enable-shared[=PKGS] 构建共享库 [默认=yes] --enable-static[=PKGS] 构建静态库 [默认=yes] --enable-fast-install[=PKGS] 为快速安装进行优化 [默认=yes] --disable-libtool-lock 避免锁定 (可能会破坏并行构建) --disable-rpath 禁用硬编码的 rpath (默认=启用) --disable-largefile 忽略对大文件的支持 --enable-systemd 编译时支持 systemd (需要 libsystemd, pkg-config) --enable-alloc-checks 启用内存分配统计信息,用于调试 --enable-alloc-lite 启用轻量级分配断言,用于调试 --enable-alloc-nonregional 启用非区域分配,速度较慢但会将区域分配暴露给其他内存净化器,用于调试 --disable-swig-version-check 禁用 swig 版本检查,以使用较旧的 swig 构建 python 模块即使这样做不可靠 --disable-sha1 禁用 SHA1 RRSIG 支持,不会禁用 nsec3 支持 --disable-sha2 禁用 SHA256 和 SHA512 RRSIG 支持 --enable-subnet 启用客户端子网 --disable-gost 禁用 GOST 支持 --disable-ecdsa 禁用 ECDSA 支持 --disable-dsa 禁用 DSA 支持 --disable-ed25519 禁用 ED25519 支持 --disable-ed448 禁用 ED448 支持 --enable-event-api 启用 (实验性的) 可插拔事件基础 libunbound API,安装到 unbound-event.h --enable-tfo-client 为客户端模式启用 TCP Fast Open --enable-tfo-server 为服务器模式启用 TCP Fast Open --enable-static-exe 启用以针对未安装的 (事件) 库静态编译 可执行文件,用于调试 --enable-fully-static 启用以完全静态编译 --enable-lock-checks 启用以检查锁定和解锁调用,用于调试 --enable-allsymbols 从 libunbound 导出所有符号并将二进制文件链接到它,安装尺寸更小但 libunbound 导出表会被内部符号污染 --enable-dnstap 启用 dnstap 支持 (需要 protobuf-c) --enable-dnscrypt 启用 dnscrypt 支持 (需要 libsodium) --enable-cachedb 启用 cachedb 模块,可以使用外部缓存存储 --enable-ipsecmod 启用 ipsecmod 模块,以促进机会性 IPsec --enable-ipset 启用 ipset 模块 --disable-explicit-port-randomisation 禁用显式源端口随机化,并依赖 内核提供随机源端口 --enable-linux-ip-local-port-range 定义此项以启用 /proc/sys/net/ipv4/ip_local_port_range 作为默认传出端口范围。这仅适用于 Linux 上的 libunbound 并且不影响 unbound 解析守护进程本身。这可能会严重限制可用的传出端口数量,从而降低随机性。仅当目标系统限制 (例如某些启用 SELinux 的发行版) 使用非临时端口时才定义此项。 可选软件包: --with-PACKAGE[=ARG] 使用 PACKAGE [ARG=yes] --without-PACKAGE 不使用 PACKAGE (等同于 --with-PACKAGE=no) --with-conf-file=path Unbound 配置文件的路径名 --with-run-dir=path 设置 chdir 到的默认目录 (默认为 cfg 文件所在的目录) --with-chroot-dir=path 设置 chroot 到的默认目录 (默认为与 run-dir 相同) --with-share-dir=path 设置共享数据的默认目录 (默认为 share/unbound) --with-pidfile=filename 设置 unbound pid 文件的默认路径名 (默认 run-dir/unbound.pid) --with-rootkey-file=filename 设置根密钥文件的默认路径名 (默认 run-dir/root.key)。此文件会被读取和写入。 --with-rootcert-file=filename 设置根更新证书文件的默认路径名(默认 run-dir/icannbundle.pem)。如果您对内置证书满意,则此文件不必存在。 --with-username=user 设置 unbound 更改到的默认用户 (默认用户是 unbound) --with-pic[=PKGS] 尝试仅使用 PIC/非 PIC 对象 [默认=两者都使用] --with-aix-soname=aix|svr4|both 在 AIX 上提供的共享库版本控制(又名 "SONAME")变体, [默认=aix]。 --with-gnu-ld 假设 C 编译器使用 GNU ld [默认=no] --with-sysroot[=DIR] 在 DIR 中搜索依赖库 (如果未指定,则为编译器的 sysroot)。 --with-pthreads 使用 pthreads 库,或使用 --without-pthreads禁用线程支持。 --with-solaris-threads 使用 solaris 原生线程库。 --with-syslog-facility=LOCAL0 - LOCAL7 设置 SYSLOG_FACILITY, 默认 DAEMON --with-dynlibmodule 构建动态库模块,或使用 --without-dynlibmodule 禁用它。(默认=no) --with-pyunbound 构建 PyUnbound,或使用 --without-pyunbound 跳过它。 (默认=no) --with-pythonmodule 构建 Python 模块,或使用 --without-pythonmodule 禁用脚本引擎。(默认=no) --with-nss=path 使用 libnss 代替 openssl,安装在 path。 --with-nettle=path 使用 libnettle 作为加密库,安装在 path。 --with-ssl=pathname 启用 SSL (将检查 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr 或指定类似 /usr/include/openssl11) --with-libbsd 使用可移植的 libbsd 函数 --with-deprecate-rsa-1024 弃用 RSA 1024 位长度,使其成为不受支持的密钥,用于 OpenSSL FIPS 拒绝 1024 位验证的情况 --with-libevent=pathname 使用 libevent (将检查 /usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr 或您可以指定一个显式路径)。速度较慢,但允许使用大的传出端口范围。 --with-libexpat=path 为 libexpat 指定显式路径。 --with-libhiredis=path 为 libhiredis 指定显式路径。 --with-libnghttp2=path 为 libnghttp2 指定显式路径。 --with-libngtcp2=path 为 libngtcp2 指定显式路径,用于 QUIC。 --with-dnstap-socket-path=pathname 设置默认 dnstap 套接字路径 --with-protobuf-c=path protobuf-c 的安装路径,用于 dnstap --with-libsodium=path libsodium 的安装路径,用于 dnscrypt --with-libmnl=path 为 libmnl 指定显式路径。 --with-libunbound-only 不构建守护进程和工具程序 一些有影响的环境变量: CC C 编译器命令 CFLAGS C 编译器标志 LDFLAGS 链接器标志, 例如 -L<lib dir> 如果您的库在非标准目录 <lib dir> 中 LIBS 传递给链接器的库, 例如 -l<library> CPPFLAGS (Objective) C/C++ 预处理器标志, 例如 -I<include dir> 如果您的头文件在非标准目录 <include dir> 中 YACC 要使用的 `Yet Another Compiler Compiler' 实现。默认为找到的第一个程序: `bison -y', `byacc', `yacc'。 YFLAGS 默认传递给 $YACC 的参数列表。此脚本将 YFLAGS 默认为空字符串,以避免某些 make 应用程序给出的默认值 `-d'。 LT_SYS_LIBRARY_PATH 用户定义的运行时库搜索路径。 PKG_CONFIG pkg-config 工具的路径 PKG_CONFIG_PATH 添加到 pkg-config 搜索路径的目录 PKG_CONFIG_LIBDIR 覆盖 pkg-config 内置搜索路径的路径 CPP C 预处理器 SYSTEMD_CFLAGS SYSTEMD 的 C 编译器标志, 覆盖 pkg-config SYSTEMD_LIBS SYSTEMD 的链接器标志, 覆盖 pkg-config SYSTEMD_DAEMON_CFLAGS SYSTEMD_DAEMON 的 C 编译器标志, 覆盖 pkg-config SYSTEMD_DAEMON_LIBS SYSTEMD_DAEMON 的链接器标志, 覆盖 pkg-config PYTHON_VERSION 要使用的已安装 Python 版本,例如 '2.3'。此字符串将附加到 Python 解释器的规范名称。 SOURCE_DATE_EPOCH 如果设置了此变量,则使用该变量的值而不是当前时间作为构建时间戳。格式为 unix时间戳。这可以实现可重现的构建输出。 PROTOBUFC_CFLAGS PROTOBUFC 的 C 编译器标志, 覆盖 pkg-config PROTOBUFC_LIBS PROTOBUFC 的链接器标志, 覆盖 pkg-config 使用这些变量来覆盖 `configure' 所做的选择,或帮助 它找到具有非标准名称/位置的库和程序。 将错误报告给 <unbound-bugs@nlnetlabs.nl 或 https://github.com/NLnetLabs/unbound/issues>。 创建 unbound 用户和组并配置 groupadd --system unbound useradd --no-create-home --system --shell /usr/sbin/nologin unbound mkdir -p /var/lib/unbound cp /usr/share/dns/root.key /var/lib/unbound/root.key chown -R unbound:unbound /var/lib/unbound 创建 unbound 的 systemd 服务文件 cat <<EOF > /etc/systemd/system/unbound.service [Unit] Description=Unbound DNS Resolver (Experimental Build) Documentation=man:unbound(8) man:unbound.conf(5) https://www.nlnetlabs.nl/projects/unbound/documentation.html Wants=network-online.target After=network-online.target # 如果您的 auto-trust-anchor-file 或 cachedb 路径位于 /var/lib/unbound, # 确保 /var 在此服务启动前已挂载。 RequiresMountsFor=/var/lib/unbound /run [Service] # === 基本配置 === Type=notify # Unbound 在 '--enable-systemd' 编译时支持 notify 类型,它会在服务完全准备好后通知 systemd。 # 指定运行 Unbound 的用户和组。 # 您在 ./configure 时使用了 --with-username=unbound。 # 您需要确保 'unbound' 用户和组在系统上存在。 # 例如: # sudo groupadd --system unbound # sudo useradd --system -g unbound -d /var/lib/unbound -s /bin/false -c "Unbound DNS Resolver" unbound User=unbound Group=unbound # 预启动检查配置文件 ExecStartPre=/usr/sbin/unbound-checkconf /etc/unbound/unbound.conf # 启动命令 # -d: 不进行后台守护进程化 (systemd 处理) # -p: 创建 PID 文件 (与 --with-pidfile 编译选项匹配) # -c: 指定配置文件路径 ExecStart=/usr/sbin/unbound -d -p -c /etc/unbound/unbound.conf # 重载配置 (需要 unbound.conf 中启用 remote-control) ExecReload=/usr/sbin/unbound-control reload # 重启策略 Restart=on-failure RestartSec=5s # PID 文件路径 (与 --with-pidfile 编译选项匹配) # RuntimeDirectory 会自动创建 /run/unbound 并设置权限给指定用户 PIDFile=/run/unbound/unbound.pid # === 资源和权限管理 === # 运行时目录,systemd 会创建 /run/unbound 并设置所有权为 User 和 Group 指定的用户/组 RuntimeDirectory=unbound RuntimeDirectoryMode=0750 # 能力绑定 # CAP_NET_BIND_SERVICE 允许 'unbound' 用户绑定到特权端口 (如53) AmbientCapabilities=CAP_NET_BIND_SERVICE CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID # 如果在 unbound.conf 中启用了 chroot,并且 Unbound 在降权为 'unbound' 用户后才执行 chroot, # 则可能还需要 CAP_SYS_CHROOT。但通常 chroot 在降权前由root完成,或者Unbound启动时即为'unbound'用户,则无法chroot到任意目录。 # 您的 --with-username=unbound 意味着Unbound会自行处理权限。 # --- 安全强化选项 --- #NoNewPrivileges=yes #ProtectSystem=no # 如果 ProtectSystem=strict 导致 Unbound 无法写入其管理的 root.key 或 cachedb (通常在 /var/lib/unbound/): # 您需要添加 ReadWritePaths 指令。例如: # ReadWritePaths=/var/lib/unbound # 如果您在 unbound.conf 中使用了 chroot: "/etc/unbound" 并且需要在其中写入 (如 root.key): # ReadWritePaths=/etc/unbound #ProtectHome=no #PrivateTmp=no #PrivateDevices=yes # MemoryDenyWriteExecute=yes # 如果系统和Unbound版本支持,可增强安全性 [Install] WantedBy=multi-user.target EOF 创建 unbound 的配置文件 cat <<EOF > /etc/unbound/unbound.conf # Unbound configuration file # # See unbound.conf(5) man page for more information. # # 注意: 路径 (例如 logfile, root-hints, auto-trust-anchor-file) # 可能需要根据您的操作系统和Unbound安装方式进行调整。 # 确保Unbound进程对指定的日志文件和自动信任锚点文件具有写入权限(或对其目录)。 server: # --- 基本服务器设置 --- verbosity: 0 # 日志详细级别 (0=仅错误, 1=操作信息, 2=详细操作, ... 5=非常详细) #logfile: "/var/log/unbound/unbound.log" # 日志文件路径。如果注释掉或为空,则可能记录到syslog。 # 例如: FreeBSD: /var/unbound/unbound.log, OpenBSD: Unbound chroots and logs via syslog # Linux (from package): often /var/log/unbound.log or uses systemd journal use-syslog: no # 如果指定了 logfile,设为 no 则仅记录到文件。设为 yes 则也发送到 syslog。 module-config: "validator cachedb iterator" interface: 0.0.0.0 # 监听所有 IPv4 地址 interface: ::0 # 监听所有 IPv6 地址 (如果您的系统支持IPv6) port: 54 # 监听的端口 (DNS标准端口) do-ip4: yes # 允许 IPv4 do-ip6: yes # 允许 IPv6 (如果网络支持) do-udp: yes # 允许 UDP do-tcp: yes # 允许 TCP # --- 访问控制 --- # 定义哪些客户端IP地址或子网可以查询此服务器。 # 强烈建议配置此项以防止滥用。 access-control: 127.0.0.0/8 allow # 允许本地回环地址 (IPv4) access-control: ::1/128 allow # 允许本地回环地址 (IPv6) # 示例:允许常见的私有网络范围。根据您的网络调整或添加。 access-control: 192.168.0.0/16 allow access-control: 10.0.0.0/8 allow access-control: 172.16.0.0/12 allow # access-control: ::ffff:127.0.0.1/128 allow # IPv4-mapped IPv6 localhost # --- 性能和缓存设置 --- msg-cache-size: 10m # DNS消息缓存大小 (查询和应答) rrset-cache-size: 20m # RRset缓存大小 (DNS资源记录) # 缓存相关的 slab 数量,通常可以设为接近 num-threads 的值或者2的幂次方。 msg-cache-slabs: 4 rrset-cache-slabs: 4 num-threads: 2 # 创建的线程数。理想情况下,设置为CPU核心数。 # 对于较小的部署,1或2通常足够。 # 增加传出查询可用的端口范围,有助于防止某些类型的攻击。 outgoing-range: 1024 # 每个线程可以并发处理的查询数上限。 num-queries-per-thread: 2048 # --- 过期缓存与预取功能 (Requested "过期缓存功能") --- prefetch: yes # 在缓存条目过期前主动获取更新,保持常用条目新鲜。 prefetch-key: yes # 在验证DS记录时,提前获取DNSKEY记录,加速后续DNSSEC验证。 serve-expired: yes # 在尝试获取新记录的同时,从缓存中提供已过期的记录。 # 这可以提高当上游权威服务器缓慢或无响应时的可用性。 serve-expired-ttl: 3600 # (1小时) 提供已过期记录时,该记录的TTL值。 serve-expired-reply-ttl: 30 # (30秒) 当提供过期数据时,客户端应该缓存这条过期数据的TTL。 serve-expired-client-timeout: 1000 # (1秒) 在提供过期数据之前,等待新答案的最长时间(毫秒)。 # --- 安全设置 --- harden-glue: yes # 强化对胶水记录的验证。 harden-dnssec-stripped: yes # 防止DNSSEC剥离攻击。 harden-algo-downgrade: yes # 防止算法降级攻击。 use-caps-for-id: yes # 在查询ID中使用随机大小写混合(0x20技巧)来增加欺骗难度。 edns-buffer-size: 1232 # EDNS0 UDP包的建议大小,以减少IP分片。 hide-identity: yes # 拒绝回应 id.server 和 hostname.bind 的查询。 hide-version: yes # 拒绝回应 version.server 和 version.bind 的查询。 # 定义私有地址范围,Unbound会从DNS响应中剥离这些地址,以防止DNS重绑定攻击。 private-address: 10.0.0.0/8 private-address: 172.16.0.0/12 private-address: 192.168.0.0/16 private-address: 169.254.0.0/16 private-address: fd00::/8 private-address: fe80::/10 # private-domain: "example.com" # 如果您有不想被外部解析的内部域名,可以在这里声明。 # 不查询回环地址上的公共域名,防止潜在的循环或安全问题。 do-not-query-localhost: yes # --- DNSSEC 验证 --- # 自动管理和更新根信任锚点。Unbound需要对该文件的目录有写权限,或者您可以手动管理此文件。 # 路径可能为: /var/lib/unbound/root.key (Debian/Ubuntu), /usr/local/etc/unbound/root.key (FreeBSD ports), # /etc/unbound/root.key (generic from source), /opt/homebrew/etc/unbound/root.key (macOS Homebrew) auto-trust-anchor-file: "/var/lib/unbound/root.key" val-log-level: 1 # DNSSEC验证失败时的日志级别 (1=基本信息, 2=详细信息)。 # --- 根提示文件 (Root Hints) --- # 如果Unbound作为递归解析器直接从根服务器开始解析 (而不是转发模式),则需要此文件。 # 确保此文件存在并且保持最新。 # 路径可能为: /usr/share/dns/root.hints (common on Linux), /etc/unbound/root.hints, # /usr/local/etc/unbound/root.hints root-hints: "/usr/share/dns/root.hints" # --- 转发模式 (可选) --- # 如果您希望Unbound将所有查询转发到其他上游DNS服务器,而不是自己从根进行递归解析, # 请取消注释并配置以下部分。如果启用了转发,则上面的 root-hints 通常不再需要。 # forward-zone: # name: "." # 转发所有查询 # # 常用的公共DNS服务器示例: # forward-addr: 8.8.8.8@53 # Google # forward-addr: 8.8.4.4@53 # Google # forward-addr: 1.1.1.1@53 # Cloudflare # forward-addr: 1.0.0.1@53 # Cloudflare # # 如果您的上游服务器支持DNS-over-TLS (DoT): # # forward-tls-upstream: yes # # forward-addr: 1.1.1.1@853#cloudflare-dns.com # DoT示例,主机名用于证书验证 # --- 远程控制 (可选) --- # 允许使用 unbound-control 工具管理Unbound服务。 # 如果启用,请确保使用 unbound-control-setup 生成密钥和证书文件。 # remote-control: # control-enable: yes # control-interface: 127.0.0.1 # 监听远程控制连接的IP地址 # control-port: 8953 # 监听远程控制连接的端口 # # 以下文件路径也需要根据您的安装进行调整 # server-key-file: "/etc/unbound/unbound_server.key" # server-cert-file: "/etc/unbound/unbound_server.pem" # control-key-file: "/etc/unbound/unbound_control.key" # control-cert-file: "/etc/unbound/unbound_control.pem" # cachedb: # backend: "redis" # 指定后端为 redis (这通常也适用于Valkey) # --- Redis/Valkey 服务器连接参数 --- # redis-server-host: 192.168.2.11 # redis-server-port: 6379 #redis-server-path: "/run/valkey/valkey-server.sock" # redis-server-password: "your_valkey_password" # 如果Valkey设置了密码 # redis-database: 0 # 可选,Valkey/Redis数据库编号 (默认为0) # --- 可选的 Redis/Valkey 相关超时设置 (如果后端驱动支持) --- # redis-timeout: 100 # 连接和操作超时 (毫秒) # --- 缓存数据密钥前缀 (可选) --- # redis-key-prefix: "unbound_cache:" # 避免与其他应用在同一Valkey实例中的键冲突 # --- 其他 cachedb 通用设置 (可能适用) --- # cachedb-no-store: no # 是否存储否定缓存条目 (默认为no,即存储) EOF 启动 unbound 服务 sudo systemctl daemon-reload sudo systemctl enable unbound sudo systemctl start unbound 检查 unbound 服务状态 sudo systemctl status unbound

May 20, 2025

ffmpeg 将视频转码至 h265 编码

ffmpeg 简介 FFmpeg是一个开源的音视频处理工具,支持录制、转换数字音频、视频,并能将其转化为流。它包含了一个完整的解决方案,能够处理几乎所有的音视频格式。 FFmpeg的核心是libavcodec库,它提供了多种音视频编解码器,支持从简单的音频转码到复杂的视频处理任务。FFmpeg还提供了丰富的命令行工具,用户可以通过命令行轻松实现音视频的转换、剪辑、合并等操作。 FFmpeg的跨平台特性使其能够在Linux、Windows和macOS等多种操作系统上运行。它的强大功能和灵活性使其成为音视频处理领域的事实标准。 Source 必要条件 安装FFmpeg:确保你的系统上已经安装了FFmpeg。 转码命令 # Intel QuickSync (hevc_qsv) # 参数: # -global_quality: 1–51(类似 CRF,数值越大质量越低,文件越小,默认23) # -preset: ultrafast | fast | medium | slow | slower | veryslow(速度↑/压缩率↓,默认medium) ffmpeg -y -i input.mp4 \ -c:v hevc_qsv -global_quality 23 -preset medium \ -c:a copy -c:s copy \ output_h265_intel.mp4 # AMD AMF (hevc_amf) # 参数: # -qp: 0–51(质量参数,数值越大压缩越强,默认23) # -quality: speed | balanced | quality(speed=最快最低质;balanced=中;quality=最高质,默认balanced) ffmpeg -y -i input.mp4 \ -c:v hevc_amf -rc cqp -qp 23 -quality balanced \ -c:a copy -c:s copy \ output_h265_amd.mp4 # NVIDIA NVENC (hevc_nvenc) # 参数: # -cq: 0–51(质量参数,数值越大质量越低,文件越小,默认23) # -preset: ultrafast | fast | medium | slow | slower | veryslow(同x265预设,默认medium) ffmpeg -y -i input.mp4 \ -c:v hevc_nvenc -cq 23 -preset medium \ -c:a copy -c:s copy \ output_h265_nvidia.mp4 # 软件 x265 (libx265) # 参数: # -crf: 0–51(数值越大压缩越强,默认23) # -preset: ultrafast | fast | medium | slow | slower | veryslow(速度↑/压缩率↓,默认medium) ffmpeg -y -i input.mp4 \ -c:v libx265 -crf 23 -preset medium \ -c:a copy -c:s copy \ output_h265_x265.mp4 Python 脚本 #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 将视频文件转码为H.265编码。 用法: python convert_to_h265.py <视频文件路径> [--intel] [--amd] [--nvidia] 使用 --intel 参数启用 Intel QuickSync 硬件加速 使用 --amd 参数启用 AMD AMF 硬件加速 使用 --nvidia 参数启用 NVIDIA NVENC 硬件加速 """ import argparse import os import subprocess import sys def convert_to_h265( input_file, use_intel=False, use_amd=False, use_nvidia=False, crf=23, preset="medium", bitrate=None, ): """ 使用ffmpeg将视频转码为H.265格式 参数: input_file: 输入视频文件路径 use_intel: 是否使用Intel QuickSync硬件加速 use_amd: 是否使用AMD AMF硬件加速 use_nvidia: 是否使用NVIDIA NVENC硬件加速 """ # 检查文件是否存在 if not os.path.isfile(input_file): print(f"错误: 文件不存在 - {input_file}") return False # 构建输出文件路径 file_dir = os.path.dirname(input_file) file_name, file_ext = os.path.splitext(os.path.basename(input_file)) output_file = os.path.join(file_dir, f"{file_name}_h265{file_ext}") # 将 Windows 路径反斜杠改为正斜杠,避免 \0 被误识别 input_file = input_file.replace("\\", "/") output_file = output_file.replace("\\", "/") # 构建 ffmpeg 命令 ffmpeg_cmd = [ "ffmpeg", "-y", # 如果目标已存在则强制覆盖 "-i", input_file, ] # 硬件/软件编码选择 if use_intel: ffmpeg_cmd.extend( [ "-c:v", "hevc_qsv", # Intel QuickSync HEVC/H.265编码器 "-global_quality", str(crf), # QSV 对应的质量参数 "-preset", preset, ] ) elif use_amd: # 将 --preset 映射到 AMF 的 quality 参数 amf_quality = { "ultrafast": "speed", "fast": "speed", "medium": "balanced", "slow": "quality", "slower": "quality", "veryslow": "quality", }.get(preset, "balanced") ffmpeg_cmd.extend( [ "-c:v", "hevc_amf", # AMD HEVC/H.265编码器 "-rc", "cqp", # AMF 使用 CQP 模式 "-qp", str(crf), # AMF 的质量参数 "-quality", amf_quality, # AMF 支持的 quality 选项 ] ) elif use_nvidia: ffmpeg_cmd.extend( [ "-c:v", "hevc_nvenc", # NVIDIA NVENC H.265编码器 "-cq", str(crf), # NVENC 的质量参数 "-preset", preset, ] ) else: # 软件 x265 编码 ffmpeg_cmd.extend( [ "-c:v", "libx265", # 软件x265编码器 "-crf", str(crf), "-preset", preset, ] ) # 如果指定了固定码率,则覆盖质量参数 if bitrate: ffmpeg_cmd.extend(["-b:v", bitrate]) # 添加通用的编码参数 ffmpeg_cmd.extend( [ "-c:a", "copy", # 复制音频流 "-c:s", "copy", # 复制字幕流 (如果有) output_file, ] ) print(f"正在转码: {input_file}") print(f"输出文件: {output_file}") print("转码中,请稍候...") try: # 执行ffmpeg命令 process = subprocess.Popen( ffmpeg_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, ) # 安全地处理并显示进度信息 if process.stdout: # 确保stdout不是None for line in process.stdout: # 仅显示包含关键字的行以减少输出量 if "frame=" in line or "speed=" in line or "error" in line.lower(): print(f"\r{line.strip()}", end="") else: # 如果无法获取输出流,提供一个替代方案 print("正在处理中,请等待...") # 等待进程完成 return_code = process.wait() if return_code == 0: print(f"\n\n转码完成!输出文件: {output_file}") print(f"原始文件大小: {os.path.getsize(input_file) / (1024*1024):.2f} MB") print( f"转码后文件大小: {os.path.getsize(output_file) / (1024*1024):.2f} MB" ) return True else: print(f"\n转码失败,ffmpeg返回错误代码: {return_code}") return False except FileNotFoundError: print("错误: 找不到ffmpeg。请确保ffmpeg已安装并添加到系统PATH中。") return False except Exception as e: print(f"发生错误: {str(e)}") return False if __name__ == "__main__": parser = argparse.ArgumentParser(description="将视频转码为H.265格式") parser.add_argument("input_file", help="输入视频文件路径") parser.add_argument( "--intel", action="store_true", help="使用 Intel QuickSync硬件加速", ) parser.add_argument( "--amd", action="store_true", help="使用 AMD GPU 硬件加速", ) parser.add_argument( "--nvidia", action="store_true", help="使用 NVIDIA NVENC 硬件加速", ) # 新增质量/码率可调参数 parser.add_argument( "--crf", type=int, default=23, help="质量参数(CRF或等效值,数值越大文件越小)", ) parser.add_argument( "--preset", default="medium", choices=[ "ultrafast", "fast", "medium", "slow", "slower", "veryslow", ], help="编码preset", ) parser.add_argument( "--bitrate", help="目标码率,如2000k,优先于CRF/质量参数", ) args = parser.parse_args() if sum(bool(x) for x in (args.intel, args.amd, args.nvidia)) > 1: print("错误: 只能指定一个硬件加速选项") sys.exit(1) convert_to_h265( args.input_file, use_intel=args.intel, use_amd=args.amd, use_nvidia=args.nvidia, crf=args.crf, preset=args.preset, bitrate=args.bitrate, )

May 20, 2025

reqwest请求被cloudflare拦截

问题描述 在使用 reqwest 请求时,即使是最简的请求也会出发 cloudflare 的拦截,导致请求失败。例如以下代码: let res = match self .client .get("https://api.bgm.tv/v0/subjects/12") .send() .await { Ok(res) => res, Err(e) => { return Err(e.to_string()); } }; 临时解决方法 添加 native-tls-alpn feature [dependencies] reqwest = { version = "0.11", features = ["native-tls-alpn"] } 参考链接 Request made with reqwest blocked by Cloudflare’s protection but succeeds with curl

April 26, 2025

CPU 线程数只有实际的一半解决方法

问题描述 Windows 任务管理器中显示 CPU 线程数只有实际的一半 如下图,实际 CPU 线程数为 16,但任务管理器中显示的线程数为 8。 问题原因 在 CPU 管理工具,例如 Ryzen Master 中,开启了同步多线程 (SMT) 功能,导致 Windows 任务管理器中显示的线程数只有实际的一半。 解决方法 关闭 CPU 管理工具中的同步多线程 (SMT) 功能,重启计算机后,Windows 任务管理器中显示的线程数应该恢复正常。 你需要关闭 SMT 吗? 这应该是一个经常被讨论的问题了,我个人的建议是,对于一般消费者,除非你追求极致的单核表现,不然没必要关闭 SMT,多数时候打开 SMT 并不会带来负面的影响。 现代的操作系统在调度上都考虑到了 SMT 的特性,比如你有 8 个核心 16 线程,那么在多任务要求不是很大的情况下,操作系统会尽量避免让一个核心同时执行两个线程。那么那些单核倒退、资源冲突的情况就基本不会发生了。而当多任务要求很高的时候,操作系统让一个核心跑多个线程,这时候虽然可能会发生冲突导致效率反向降低,但是更多的时候是增加效率,所以从期望上来说,是没必要的。 如果追求极致性能且自己确切不需要那么多多线程性能,自然可以关掉。反正也用不到那么多线程,享受不到 SMT 的好处,还不如索性关了,杜绝一切可能的开销,也更容易超频了。所以其实核心越多的,越适合关闭 SMT,至于还在用 4 核心之类的就别关了。 参考链接 Wikipedia 同步多线程 知乎 说一说超线程/同步多线程(HT/SMT)技术那些事儿

April 9, 2025

curl 命令行参数注解

使用方法: curl [选项...] <url> 常用参数 基本操作 -X, --request <method>: 指定请求方法(如 GET、POST、PUT、DELETE 等)。 -d, --data <data>: 发送 HTTP POST 数据。 -G, --get: 将 POST 数据放入 URL 并使用 GET 方法。 -I, --head: 仅显示文档信息(HTTP 头部)。 -L, --location: 自动跟随重定向。 -o, --output <file>: 将输出写入文件。 -u, --user <user:password>: 指定用户名和密码。 -H, --header <header>: 添加自定义 HTTP 头部。 -v, --verbose: 显示详细的操作过程。 -s, --silent: 静默模式,不显示任何进度信息。 -w, --write-out <format>: 操作完成后输出指定格式的信息。 -O, --remote-name: 将输出写入与远程文件同名的文件。 文件传输 -T, --upload-file <file>: 上传文件到目标服务器。 -C, --continue-at <offset>: 从指定偏移量开始续传。 -F, --form <name=content>: 发送 multipart MIME 数据。 --limit-rate <speed>: 限制传输速率。 --max-time <seconds>: 设置最大传输时间。 --retry <num>: 在发生临时错误时重试请求。 --range <range>: 获取指定字节范围的内容。 网络选项 -4, --ipv4: 强制解析为 IPv4 地址。 -6, --ipv6: 强制解析为 IPv6 地址。 --dns-servers <addresses>: 指定 DNS 服务器。 --interface <name>: 使用指定的网络接口进行请求。 --socks5 <host[:port]>: 使用 SOCKS5 代理。 调试和日志 --trace <file>: 将调试信息写入文件。 --trace-time: 在调试输出中添加时间戳。 --stderr <file>: 将错误输出定向到文件。 -D, --dump-header <filename>: 将响应头保存到文件。 输出格式和显示 --progress-bar: 显示传输进度条。 --remote-name: 将输出写入文件,并使用服务器返回的文件名。 --remote-time: 设置本地文件的时间戳为远程文件的时间。 --styled-output: 启用彩色输出。 全部选项 --abstract-unix-socket <path> 通过抽象 Unix 域套接字连接 ...

April 8, 2025

Rio气泡鸡尾酒清爽阳光玫瑰葡萄伏特加风味 评测

价格 ¥ 4.9/瓶 购买渠道 线下 个人评分 7/10

April 8, 2025