路由上跑dnsmasq通过将客户端ip添加为edns ip转发到其它dns服务器时可以根据客户端ip做相应操作,dnmasq只有在设置add-subnet为固定ip段时才缓存,add-subnet=32时动态添加客户端ip为edns ip时不缓存,做了下修改可以缓存。
--- dnsmasq-2.86/src/edns0.c 2021-09-09 04:21:22.000000000 +0800
+++ dnsmasq-2.86-bak/src/edns0.c 2022-01-23 18:54:04.801336879 +0800
@@ -375,6 +375,7 @@
if (cacheablep)
*cacheablep = cacheable;
+ *cacheablep = 1;
return len + 4;
}
diff -urN dnsmasq-2.86/src/forward.c dnsmasq-2.86-bak/src/forward.c
--- dnsmasq-2.86/src/forward.c 2021-09-09 04:21:22.000000000 +0800
+++ dnsmasq-2.86-bak/src/forward.c 2022-01-23 18:58:25.020648204 +0800
@@ -596,7 +596,7 @@
/* Get extended RCODE. */
rcode |= sizep[2] << 4;
- if (check_subnet && !check_source(header, plen, pheader, query_source))
+ if ( 0 && check_subnet && !check_source(header, plen, pheader, query_source))
{
my_syslog(LOG_WARNING, _("discarding DNS reply: subnet option mismatch"));
return 0;