Changeset 923

Show
Ignore:
Timestamp:
11/16/06 22:10:54 (2 years ago)
Author:
ahu
Message:

implement 'dont-query', and enable it by default, which means we no longer query rfc1918 space, nor 127.0.0.1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pdns/pdns/docs/pdns.sgml

    r921 r923  
    67906790              <para> 
    67916791                A Verisign special. 
     6792              </para> 
     6793            </listitem> 
     6794          </varlistentry> 
     6795          <varlistentry> 
     6796            <term>dont-query</term> 
     6797            <listitem> 
     6798              <para> 
     6799                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,  
     6800                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 
     6801                private space IP addresses. This setting can be used to expand or reduce the limitations. 
    67926802              </para> 
    67936803            </listitem> 
  • trunk/pdns/pdns/iputils.hh

    r916 r923  
    120120  } 
    121121 
    122   bool isMappedIPv4()   
     122  bool isMappedIPv4()  const 
    123123  { 
    124124    if(sin4.sin_family!=AF_INET6) 
     
    138138  } 
    139139   
    140   ComboAddress mapToIPv4()  
     140  ComboAddress mapToIPv4() const 
    141141  { 
    142142    if(!isMappedIPv4()) 
     
    267267public: 
    268268  //! If this IP address is matched by any of the classes within 
    269   bool match(ComboAddress *ip) 
     269  bool match(const ComboAddress *ip) 
    270270  { 
    271271    for(container_t::const_iterator i=d_masks.begin();i!=d_masks.end();++i) 
  • trunk/pdns/pdns/lwres.cc

    r904 r923  
    5252  delete[] d_buf; 
    5353} 
    54  
    5554 
    5655//! returns -2 for OS limits error, -1 for permanent error that has to do with remote, 0 for timeout, 1 for success 
  • trunk/pdns/pdns/pdns_recursor.cc

    r917 r923  
    7777bool g_quiet; 
    7878NetmaskGroup* g_allowFrom; 
     79NetmaskGroup* g_dontQuery; 
    7980string s_programname="pdns_recursor"; 
    8081typedef vector<int> g_tcpListenSockets_t; 
     
    14901491    L<<Logger::Error<<"WARNING: Allowing queries from all IP addresses - this can be a security risk!"<<endl; 
    14911492   
     1493  if(!::arg()["dont-query"].empty()) { 
     1494    g_dontQuery=new NetmaskGroup; 
     1495    vector<string> ips; 
     1496    stringtok(ips, ::arg()["dont-query"], ", "); 
     1497    L<<Logger::Warning<<"Will not send queries to: "; 
     1498    for(vector<string>::const_iterator i = ips.begin(); i!= ips.end(); ++i) { 
     1499      g_dontQuery->addMask(*i); 
     1500      if(i!=ips.begin()) 
     1501        L<<Logger::Warning<<", "; 
     1502      L<<Logger::Warning<<*i; 
     1503    } 
     1504    L<<Logger::Warning<<endl; 
     1505  } 
     1506 
    14921507  g_quiet=::arg().mustDo("quiet"); 
    14931508  if(::arg().mustDo("trace")) { 
     
    16981713    ::arg().set("version-string", "string reported on version.pdns or version.bind")="PowerDNS Recursor "VERSION" $Id$"; 
    16991714    ::arg().set("allow-from", "If set, only allow these comma separated netmasks to recurse")="127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10"; 
     1715    ::arg().set("dont-query", "If set, do not query these netmasks for DNS data")="127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10"; 
    17001716    ::arg().set("max-tcp-per-client", "If set, maximum number of TCP sessions per client (IP address)")="0"; 
    17011717    ::arg().set("fork", "If set, fork the daemon for possible double performance")="no"; 
  • trunk/pdns/pdns/syncres.cc

    r919 r923  
    661661        for(remoteIP = remoteIPs.begin(); remoteIP != remoteIPs.end(); ++remoteIP) { 
    662662          LOG<<prefix<<qname<<": Trying IP "<< remoteIP->toString() <<", asking '"<<qname<<"|"<<qtype.getName()<<"'"<<endl; 
     663          extern NetmaskGroup* g_dontQuery; 
    663664           
    664665          if(s_throttle.shouldThrottle(d_now.tv_sec, make_tuple(*remoteIP, qname, qtype.getCode()))) { 
    665666            LOG<<prefix<<qname<<": query throttled "<<endl; 
    666667            s_throttledqueries++; d_throttledqueries++; 
     668            continue; 
     669          }  
     670          else if(g_dontQuery && g_dontQuery->match(&*remoteIP)) { 
     671            LOG<<prefix<<qname<<": not sending query to " << remoteIP->toString() << ", blocked by 'dont-query' setting" << endl; 
    667672            continue; 
    668673          }