mosdns缓存dns服务器配置记录

https://irine-sistiana.gitbook.io/mosdns-wiki参考配置

使用内置执行器cache

复制代码
[root@localhost ~]# cat /etc/mosdns/config.yaml 
log:
  level: debug
  file: /tmp/mosdns.log
plugins:
  - tag: main
    type: sequence
    args:
      - exec: cache 10000     #查找 cache。
      - matches:             # 如果
          - has_resp         # 有应答了(上一步 cache 找到应答)
        exec: accept         # 结束。

      # 上一步没有找到缓存,就会到这一步,转发至阿里云获取应答。
      - exec: forward https://dns.alidns.com/dns-query?
      # sequence 结束(被 reject,accept,或者运行到末尾)后就会返回调用者。在这个配置文件中
      # 调用者是下面的服务器。服务器就会返回应答至客户端。


  # 启动 udp 和 tcp 服务器。
  - type: udp_server
    args:
      entry: main # 收到的请求会执行上面的逻辑
      listen: 0.0.0.0:53
  - type: tcp_server
    args:
      entry: main
      listen: 0.0.0.0:53

使用自定义lazy_cache插件

复制代码
[root@localhost 100trust]# cat /etc/mosdns/config.yaml 
log:
  level: debug
  file: /tmp/mosdns.log
plugins:
  - tag: lazy_cache
    type: cache
    args:
      size: 10240
      lazy_cache_ttl: 86400
      dump_file: /tmp/mosdns.dump

  - tag: main
    type: sequence
    args:
      - exec: $lazy_cache
      - matches: has_resp
        exec: accept

      # 上一步没有找到缓存,就会到这一步,转发至360获取应答。
      - exec: forward https://doh.360.cn/dns-query
      # sequence 结束(被 reject,accept,或者运行到末尾)后就会返回调用者。在这个配置文件中
      # 调用者是下面的服务器。服务器就会返回应答至客户端。


  # 启动 udp 和 tcp 服务器。
  - type: udp_server
    args:
      entry: main # 收到的请求会执行上面的逻辑
      listen: 0.0.0.0:53
  - type: tcp_server
    args:
      entry: main
      listen: 0.0.0.0:53

[root@localhost 100trust]# cat /etc/mosdns/config.yaml 
log:
  level: debug
  file: /tmp/mosdns.log
plugins:
  - tag: lazy_cache
    type: cache
    args:
      size: 10240
      lazy_cache_ttl: 86400
      dump_file: /tmp/mosdns.dump


  - tag: "remote_forward"
    type: forward
    args:
      concurrent: 2
      upstreams: 
        - addr: "https://doh.360.cn/dns-query"
          idle_timeout: 86400
        - addr: "https://dns.alidns.com/dns-query?"
          idle_timeout: 86400
  - tag: main
    type: sequence
    args:
      - exec: $lazy_cache
      - matches: has_resp
        exec: accept

      # 上一步没有找到缓存,就会到这一步,转发至remote_forward获取应答。
      - exec: $remote_forward
      # sequence 结束(被 reject,accept,或者运行到末尾)后就会返回调用者。在这个配置文件中
      # 调用者是下面的服务器。服务器就会返回应答至客户端。


  # 启动 udp 和 tcp 服务器。
  - type: udp_server
    args:
      entry: main # 收到的请求会执行上面的逻辑
      listen: 0.0.0.0:53
  - type: tcp_server
    args:
      entry: main
      listen: 0.0.0.0:53
[root@localhost 100trust]# 
相关推荐
Dovis(誓平步青云)4 分钟前
《Gdb 调试实战指南:不同风格于VS下的一种调试模式》
linux·运维·服务器
小-黯9 分钟前
Ubuntu离线安装软件包
linux·运维·ubuntu
tt55555555555533 分钟前
Linux驱动开发核心概念详解 - 从入门到精通
linux·运维·驱动开发
神秘人X70736 分钟前
Docker 镜像结构详解
运维·docker·容器
Elastic 中国社区官方博客7 小时前
Elasticsearch MCP 服务器:与你的 Index 聊天
大数据·服务器·人工智能·elasticsearch·搜索引擎·ai·全文检索
cpsvps_net7 小时前
VPS服务器锁等待超时处理,如何有效解决数据库性能瓶颈
服务器·数据库·oracle
南枝异客8 小时前
CentOS 7 网络连接问题
linux·运维·centos
阿方索12 小时前
Linux 正则表达式
linux·运维
硅谷工具人12 小时前
vue3边学边做系列(3)-路由缓存接口封装
前端·缓存·前端框架·vue
TTGGGFF12 小时前
云端服务器使用指南:利用Python操作mysql数据库
服务器·数据库·python