mosdns
mosdns copied to clipboard
[Bug] docker 使用macvlan网络时,无法解析overS得ip,不知道为什么。
在提交之前,请确认
- [X] 我已经尝试搜索过 Issue ,但没有找到相关问题。
- [X] 我正在使用最新的 mosdns 版本(或者最新的 commit),问题依旧存在。
- [X] 我仔细看过 wiki 后仍然无法自行解决该问题。
- [X] 我非常确定这是 mosdns 核心的问题。(如果是通过第三方衍生软件使用 mosdns 核心,不确定问题源头时,请先向衍生软件开发者提交问题。)
mosdns 版本
docker lastest
操作系统
debian
Bug 描述和复现步骤
docker run 若使用host网络,,可以解析国内waiIP都没问题。 但使用macvlan网络是, 只可以解析国内ip,国外ip都无法解析。
macvlan有独立ip, host使用宿主机的ip
用dig 命令测试的
使用的配置文件
# 配置文件的部分内容参考了下面这个网站
# https://apad.pro/easymosdns
#
log:
file: "./mosdns.log"
level: error
data_providers:
- tag: geosite
file: ./geosite.dat
auto_reload: true
- tag: geoip
file: ./geoip.dat
auto_reload: true
- tag: cn
file: ./cn.dat
auto_reload: true
- tag: ecscn
file: ./ecs_cn_domain.txt
auto_reload: true
- tag: ecstw
file: ./ecs_tw_domain.txt
auto_reload: true
- tag: hosts
file: ./hosts.txt
auto_reload: true
plugins:
# 缓存的插件
- tag: cache
type: cache
args:
size: 10240
lazy_cache_ttl: 86400
cache_everything: true
# Hosts的插件
- tag: hosts
type: hosts
args:
hosts:
- "provider:hosts"
# 调整ECS的插件
# [auto|global|cn|tw]
- tag: ecs_auto
type: ecs
args:
auto: true
mask4: 24
force_overwrite: false
- tag: ecs_global
type: ecs
args:
auto: true
mask4: 22
force_overwrite: false
- tag: ecs_cn
type: ecs
args:
auto: false
ipv4: "1.2.4.0"
ipv6: "2001:dc7:1000::1"
mask4: 24
force_overwrite: true
- tag: ecs_tw
type: ecs
args:
auto: false
ipv4: "168.95.1.0"
ipv6: "2001:b000:168::1"
mask4: 22
force_overwrite: true
# 调整TTL的插件
- tag: ttl_short
type: ttl
args:
minimal_ttl: 60
maximum_ttl: 3600
- tag: ttl_long
type: ttl
args:
minimal_ttl: 300
maximum_ttl: 3600
# 屏蔽TYPE65类型请求的插件
- tag: qtype65
type: query_matcher
args:
qtype: [65]
- tag: black_hole
type: blackhole
args:
rcode: 0
ipv4: "127.0.0.1"
ipv6: "::1"
# 转发至 AliDNS 的插件
- tag: forward_ali
type: fast_forward
args:
upstream:
- addr: "https://dns.alidns.com/dns-query"
dial_addr: "223.5.5.5"
trusted: true
enable_pipeline: true
- addr: "tls://dns.alidns.com"
dial_addr: "223.5.5.5"
trusted: true
enable_pipeline: true
# 转发至 DnspodDNS 的插件
- tag: forward_dnspod
type: fast_forward
args:
upstream:
- addr: "https://1.12.12.12/dns-query"
trusted: true
- addr: "https://120.53.53.53/dns-query"
trusted: true
# 转发至本地服务器的插件
- tag: forward_local
type: sequence
args:
exec:
- parallel:
- - "forward_ali" # 执行序列 #1。
- - "forward_dnspod" # 执行序列 #2。
# 转发至 GoogleDNS 的插件
- tag: forward_google
type: fast_forward
args:
upstream:
- addr: "https://dns.google/dns-query"
dial_addr: "2001:4860:4860::8844"
trusted: true
enable_pipeline: true
enable_http3: true
- addr: "tls://dns.google"
dial_addr: "8.8.8.8"
trusted: true
enable_pipeline: true
enable_http3: true
# 转发至 CloudflareDNS 的插件
- tag: forward_cloudflare
type: fast_forward
args:
upstream:
- addr: "https://cloudflare-dns.com/dns-query"
dial_addr: "2606:4700::6810:f9f9"
trusted: true
enable_pipeline: true
enable_http3: true
- addr: "tls://1dot1dot1dot1.cloudflare-dns.com"
dial_addr: "1.1.1.1"
trusted: true
enable_pipeline: true
enable_http3: true
# 转发至远程服务器的插件
- tag: forward_remote
type: sequence
args:
exec:
- parallel: # 并行
- - "forward_google" # 执行序列 #1。
- - "forward_cloudflare" # 执行序列 #2。
# 匹配本地域名的插件
- tag: query_is_local_domain
type: query_matcher
args:
domain:
- "provider:geosite:cn"
- "provider:geosite:apple-cn"
- "provider:geosite:steam@cn"
# 匹配污染域名的插件
- tag: query_is_non_local_domain
type: query_matcher
args:
domain:
- "provider:geosite:geolocation-!cn"
- tag: response_has_local_ip
type: response_matcher
args:
ip:
# 使用默认geoip.dat文件
# - "ext:./geoip.dat:cn"
# 使用高性能cn.dat文件, 需要下载对应的文件
- "provider:cn:cn"
# - tag: query_is_ad_domain
# type: query_matcher
# args:
# domain:
# - "ext:./geosite.dat:category-ads-all"
# 匹配强制本地解析域名的插件
- tag: query_is_cn_domain
type: query_matcher
args:
domain:
- "provider:ecscn"
# 匹配强制非本地解析域名的插件
- tag: query_is_tw_domain
type: query_matcher
args:
domain:
- "provider:ecstw"
# 匹配RCODE2的插件
- tag: response_server_failed
type: response_matcher
args:
rcode: [2]
# 主要的运行逻辑插件
# sequence 插件中调用的插件 tag 必须在 sequence 前定义
# 否则 sequence 找不到对应插件
- tag: main_sequence
type: sequence
args:
exec:
# 域名映射IP
- hosts
# 缓存
- cache
# 屏蔽TYPE65类型请求
- if: qtype65
exec:
- black_hole
- _return
# 强制用本地服务器解析
- if: query_is_cn_domain
exec:
- ecs_auto
- forward_local
- _return
# 强制用非本地服务器解析
- if: query_is_tw_domain
exec:
- ecs_tw
- forward_remote
- ttl_long
- _return
# 屏蔽广告域名
# - if: query_is_ad_domain
# exec:
# - _new_nxdomain_response
# - _return
# 已知的本地域名或CDN域名用本地服务器解析
- if: query_is_local_domain
exec:
- ecs_auto
- forward_local
- _return
# 已知的污染域名用远程服务器解析
- if: query_is_non_local_domain
exec:
- _prefer_ipv4
- ecs_cn
- forward_remote
- _return
# 剩下的未知域名用IP分流,分流原理请参考fallback的工作流程
# primary 从本地服务器获取应答,丢弃非本地IP或污染IP的结果
- primary:
- ecs_auto
- forward_local
- ttl_short
- if: "(! response_has_local_ip) && [_response_valid_answer]"
exec:
- _drop_response
# secondary 从远程服务器获取应答,无法解析的域名从本地服务器获取应答
secondary:
- _prefer_ipv4
- ecs_global
- forward_remote
- ttl_long
- if: "response_server_failed"
exec:
- forward_local
- ttl_long
# 这里建议设置成 local 服务器正常延时的 2~5 倍
# 这个延时保证了 local 延时偶尔变高时,其结果不会被 remote 抢答
# 如果 local 超过这个延时还没响应,可以假设 local 出现了问题
# 这时用就采用 remote 的应答。单位: 毫秒
fast_fallback: 150
servers:
- exec: main_sequence
timeout: 5
listeners:
- protocol: udp
addr: ":53"
- protocol: tcp
addr: ":53"
api:
http: ":8080"
mosdns 的 log 记录
docker run -d --name mosdns --restart unless-stopped --network=adgnetwork --ip 192.168.18.10 -v /etc/mosdns:/etc/mosdns irinesistiana/mosdns