Skip to content

Commit 2f67952

Browse files
committed
Limit who can send us AXFR notify queries
Fixes #1937 and #1120 (cherry picked from commit d207ad6)
1 parent 59eb25c commit 2f67952

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed

pdns/common_startup.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ void declareArguments()
9898
::arg().set("allow-axfr-ips","Allow zonetransfers only to these subnets")="127.0.0.0/8,::1";
9999
::arg().set("only-notify", "Only send AXFR NOTIFY to these IP addresses or netmasks")="0.0.0.0/0,::/0";
100100
::arg().set("also-notify", "When notifying a domain, also notify these nameservers")="";
101+
::arg().set("allow-notify-from","Allow AXFR NOTIFY from these IP ranges. If empty, drop all incoming notifies.")="0.0.0.0/0,::/0";
101102
::arg().set("slave-cycle-interval","Schedule slave freshness checks once every .. seconds")="60";
102103

103104
::arg().set("tcp-control-address","If set, PowerDNS can be controlled over TCP on this address")="";

pdns/communicator.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ void CommunicatorClass::retrievalLoopThread(void)
5656

5757
void CommunicatorClass::go()
5858
{
59+
try {
60+
PacketHandler::s_allowNotifyFrom.toMasks(::arg()["allow-notify-from"] );
61+
}
62+
catch(PDNSException &e) {
63+
L<<Logger::Error<<"Unparseable IP in allow-notify-from. Error: "<<e.reason<<endl;
64+
exit(1);
65+
}
66+
5967
pthread_t tid;
6068
pthread_create(&tid,0,&launchhelper,this); // Starts CommunicatorClass::mainloop()
6169
for(int n=0; n < ::arg().asNum("retrieval-threads", 1); ++n)

pdns/docs/pdns.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17397,7 +17397,18 @@ To enable a Lua script for a particular slave zone, determine the domain_id for
1739717397
</para>
1739817398
<para>Behaviour post 2.9.10: If set, only these IP addresses or netmasks will be able to perform AXFR.
1739917399
</para>
17400-
</listitem></varlistentry>
17400+
</listitem>
17401+
</varlistentry>
17402+
<varlistentry>
17403+
<term>allow-notify-from=...</term>
17404+
<listitem>
17405+
<para>
17406+
By specifying <command>allow-notify-from</command>, receiving AXFR NOTIFY can be restricted to netmasks specified. The default is to allow
17407+
AXFR NOTIFY from anywhere. Example: <command>allow-notify-from=192.168.0.0/24, 10.0.0.0/8, 192.0.2.4</command>.
17408+
The default is 0.0.0.0,::/0. Setting this to an empty string will drop all incoming notifies. Available since 3.4.3.
17409+
</para>
17410+
</listitem>
17411+
</varlistentry>
1740117412
<varlistentry>
1740217413
<term>allow-recursion=...</term>
1740317414
<listitem>

pdns/packethandler.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#endif
5151

5252
AtomicCounter PacketHandler::s_count;
53+
NetmaskGroup PacketHandler::s_allowNotifyFrom;
5354
extern string s_programname;
5455

5556
enum root_referral {
@@ -756,6 +757,12 @@ int PacketHandler::processNotify(DNSPacket *p)
756757
L<<Logger::Error<<"Received NOTIFY for "<<p->qdomain<<" from "<<p->getRemote()<<" but slave support is disabled in the configuration"<<endl;
757758
return RCode::NotImp;
758759
}
760+
761+
if(!s_allowNotifyFrom.match((ComboAddress *) &p->d_remote )) {
762+
L<<Logger::Notice<<"Received NOTIFY for "<<p->qdomain<<" from "<<p->getRemote()<<" but remote is not in allow-notify-from"<<endl;
763+
return RCode::Refused;
764+
}
765+
759766
DNSBackend *db=0;
760767
DomainInfo di;
761768
di.serial = 0;

pdns/packethandler.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public:
6464
DNSBackend *getBackend();
6565

6666
int trySuperMasterSynchronous(DNSPacket *p);
67+
static NetmaskGroup s_allowNotifyFrom;
6768

6869
private:
6970
int trySuperMaster(DNSPacket *p);

pdns/pdns.conf-dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
#
1010
# allow-dnsupdate-from=127.0.0.0/8,::1
1111

12+
#################################
13+
# allow-notify-from Allow AXFR NOTIFY from these IP ranges. If empty, drop all incoming notifies.
14+
#
15+
# allow-notify-from=0.0.0.0/0,::/0
16+
1217
#################################
1318
# allow-recursion List of subnets that are allowed to recurse
1419
#

0 commit comments

Comments
 (0)