From eb5bae862eaa38daa0d49e84ef935406bcaeb721 Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Thu, 16 Nov 2006 21:10:54 +0000 Subject: [PATCH] implement 'dont-query', and enable it by default, which means we no longer query rfc1918 space, nor 127.0.0.1 git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@923 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/docs/pdns.sgml | 10 ++++++++++ pdns/iputils.hh | 6 +++--- pdns/lwres.cc | 1 - pdns/pdns_recursor.cc | 16 ++++++++++++++++ pdns/syncres.cc | 5 +++++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/pdns/docs/pdns.sgml b/pdns/docs/pdns.sgml index 3a574b1fd..def48d8ec 100644 --- a/pdns/docs/pdns.sgml +++ b/pdns/docs/pdns.sgml @@ -6792,6 +6792,16 @@ local0.err /var/log/pdns.err + + dont-query + + + The DNS is a public database, but sometimes contains delegations to private IP addresses, like for example 127.0.0.1. This can have odd effects, + depending on your network, and may even be a security risk. Therefore, since version 3.1.5, the PowerDNS recursor by default does not query + private space IP addresses. This setting can be used to expand or reduce the limitations. + + + export-etc-hosts diff --git a/pdns/iputils.hh b/pdns/iputils.hh index d5f18d0da..a562a2f90 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -119,7 +119,7 @@ union ComboAddress { } } - bool isMappedIPv4() + bool isMappedIPv4() const { if(sin4.sin_family!=AF_INET6) return false; @@ -137,7 +137,7 @@ union ComboAddress { return true; } - ComboAddress mapToIPv4() + ComboAddress mapToIPv4() const { if(!isMappedIPv4()) throw AhuException("ComboAddress can't map non-mapped IPv6 address back to IPv4"); @@ -266,7 +266,7 @@ class NetmaskGroup { public: //! If this IP address is matched by any of the classes within - bool match(ComboAddress *ip) + bool match(const ComboAddress *ip) { for(container_t::const_iterator i=d_masks.begin();i!=d_masks.end();++i) if(i->match(ip) || (ip->isMappedIPv4() && i->match(ip->mapToIPv4()) )) diff --git a/pdns/lwres.cc b/pdns/lwres.cc index 79637969b..cd0028139 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -52,7 +52,6 @@ LWRes::~LWRes() delete[] d_buf; } - //! returns -2 for OS limits error, -1 for permanent error that has to do with remote, 0 for timeout, 1 for success /** Never throws! */ int LWRes::asyncresolve(const ComboAddress& ip, const string& domain, int type, bool doTCP, struct timeval* now) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 35a17f159..bc71226f5 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -76,6 +76,7 @@ MemRecursorCache RC; RecursorStats g_stats; bool g_quiet; NetmaskGroup* g_allowFrom; +NetmaskGroup* g_dontQuery; string s_programname="pdns_recursor"; typedef vector g_tcpListenSockets_t; g_tcpListenSockets_t g_tcpListenSockets; @@ -1489,6 +1490,20 @@ int serviceMain(int argc, char*argv[]) else if(::arg()["local-address"]!="127.0.0.1" && ::arg().asNum("local-port")==53) L< ips; + stringtok(ips, ::arg()["dont-query"], ", "); + L<::const_iterator i = ips.begin(); i!= ips.end(); ++i) { + g_dontQuery->addMask(*i); + if(i!=ips.begin()) + L< nameservers, string auth, } for(remoteIP = remoteIPs.begin(); remoteIP != remoteIPs.end(); ++remoteIP) { LOG<toString() <<", asking '"<match(&*remoteIP)) { + LOG<toString() << ", blocked by 'dont-query' setting" << endl; + continue; } else { s_outqueries++; d_outqueries++; -- 2.49.0