【LEDE】树莓派上玩LEDE终极指南-85-配置酸酸乳的心得

### 涉及到的方面
- 使用pdnsd解析域名
- 通过kdig调试pdnsd
- 使用dnsmasq+ipset实现域名分流


# 正文
## 使用pdnsd解析域名
1. 首先安装pdnsd
`opkg install pdnsd`
2. 配置/etc/pdnsd.conf
```
global {
#run_ipv4=off;  # 仿IPv6 模式运行,因为指定的 Google DNS
server_port=5353;  # 监听端口
perm_cache=1024;
cache_dir="/etc/pdnsd";
run_as="root";
server_ip = 127.0.0.1;  # Use eth0 here if you want to allow other
# machines on your network to query pdnsd.
status_ctl = on;
# but may make pdnsd less efficient, unfortunately.
query_method=tcp_only;  # 查询方式,优兿TCP
min_ttl=15m;       # Retain cached entries at least 15 minutes.
max_ttl=1w;        # One week.
timeout=10;        # Global timeout option (10 seconds).
neg_domain_pol=on;
udpbufsize=1024;   # Upper limit on the size of UDP messages.
}
server {
label= "mydns";
#ip="8.8.4.4";  # 指定 Google DNS
ip="205.252.144.228", "202.12.27.33", "114.114.114.114";
proxy_only=off;
timeout=10;
uptest=ping;
purge_cache=off;
preset=off;
}
source {
owner=localhost;
file="/etc/hosts";
}
rr {
name=localhost;
reverse=on;
a=127.0.0.1;
owner=localhost;
soa=localhost,root.localhost,42,86400,900,86400,86400;
}
```
3. 启动pdnsd
`/etc/init.d/pdnsd start`


4. 坑
A. pdnsd不会自动在cache目录建立cache文件,也不会在动新建cache目录,所以需要手动mkdir和touch一下。
B. pdnsd可以配置多个DNS上层服务器,也支持TCP模式解析DNS,并且这些DNS服务器安装一定的规则进行自动切换,所以如果某一个服务器down掉,而pdnsd正好在使用该服务器解析用户的DNS请求时,则会失败,所以配置上层服务器的时候要尽量确保上层DNS服务器的稳定性。


## 通过kdig调试pdnsd
通过`kdig www.google.com -p 5353`调试pdnsd
- 为啥不用nslookup? 因为OpenWrt自带的nslookup来自busybox,不支持设置DNS服务器端口,所以无法调试5353


## 使用dnsmasq+ipset实现域名分流
> 原理较为复杂,暂时不在这里解释:relaxed:


坑:
1. 安装完luci-app-shadowsocksR-GFW之后,并不能立即翻墙,需要在dnsmasq.conf中添加`conf-dir=./dnsmasq.ssr/`,重启dnsmasq,才能使用ipset匹配gfwlist中的域名。

猜你喜欢

转载自blog.csdn.net/wang805447391/article/details/80928929