From 2f679523bc90c7f896dd6750c754e591759fe242 Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Sun, 14 Dec 2014 15:19:55 +0100 Subject: [PATCH] Limit who can send us AXFR notify queries Fixes #1937 and #1120 (cherry picked from commit d207ad630ba2c98c922c8ca31b35d973b2e6b756) --- pdns/common_startup.cc | 1 + pdns/communicator.cc | 8 ++++++++ pdns/docs/pdns.xml | 13 ++++++++++++- pdns/packethandler.cc | 7 +++++++ pdns/packethandler.hh | 1 + pdns/pdns.conf-dist | 5 +++++ 6 files changed, 34 insertions(+), 1 deletion(-) diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 1df40bec70..30976a6b7e 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -98,6 +98,7 @@ void declareArguments() ::arg().set("allow-axfr-ips","Allow zonetransfers only to these subnets")="127.0.0.0/8,::1"; ::arg().set("only-notify", "Only send AXFR NOTIFY to these IP addresses or netmasks")="0.0.0.0/0,::/0"; ::arg().set("also-notify", "When notifying a domain, also notify these nameservers")=""; + ::arg().set("allow-notify-from","Allow AXFR NOTIFY from these IP ranges. If empty, drop all incoming notifies.")="0.0.0.0/0,::/0"; ::arg().set("slave-cycle-interval","Schedule slave freshness checks once every .. seconds")="60"; ::arg().set("tcp-control-address","If set, PowerDNS can be controlled over TCP on this address")=""; diff --git a/pdns/communicator.cc b/pdns/communicator.cc index 41e7e56ca7..e5160e1215 100644 --- a/pdns/communicator.cc +++ b/pdns/communicator.cc @@ -56,6 +56,14 @@ void CommunicatorClass::retrievalLoopThread(void) void CommunicatorClass::go() { + try { + PacketHandler::s_allowNotifyFrom.toMasks(::arg()["allow-notify-from"] ); + } + catch(PDNSException &e) { + L< Behaviour post 2.9.10: If set, only these IP addresses or netmasks will be able to perform AXFR. - + + + + allow-notify-from=... + + + By specifying allow-notify-from, receiving AXFR NOTIFY can be restricted to netmasks specified. The default is to allow + AXFR NOTIFY from anywhere. Example: allow-notify-from=192.168.0.0/24, 10.0.0.0/8, 192.0.2.4. + The default is 0.0.0.0,::/0. Setting this to an empty string will drop all incoming notifies. Available since 3.4.3. + + + allow-recursion=... diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 01e409b567..1ab5118a02 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -50,6 +50,7 @@ #endif AtomicCounter PacketHandler::s_count; +NetmaskGroup PacketHandler::s_allowNotifyFrom; extern string s_programname; enum root_referral { @@ -756,6 +757,12 @@ int PacketHandler::processNotify(DNSPacket *p) L<qdomain<<" from "<getRemote()<<" but slave support is disabled in the configuration"<d_remote )) { + L<qdomain<<" from "<getRemote()<<" but remote is not in allow-notify-from"<