--- a/src/forward.c	2011-10-07 15:09:30.000000000 +0100
+++ b/src/forward.c	2013-01-09 17:42:50.337002077 +0000
@@ -555,7 +555,7 @@
    
   server = forward->sentto;
   
-  if ((RCODE(header) == SERVFAIL || RCODE(header) == REFUSED) &&
+  if ((RCODE(header) == SERVFAIL || RCODE(header) == REFUSED || RCODE(header) == NOTIMP) &&
       !option_bool(OPT_ORDER) &&
       forward->forwardall == 0)
     /* for broken servers, attempt to send to another one. */
@@ -582,7 +582,7 @@
   
   if ((forward->sentto->flags & SERV_TYPE) == 0)
     {
-      if (RCODE(header) == SERVFAIL || RCODE(header) == REFUSED)
+      if (RCODE(header) == SERVFAIL || RCODE(header) == REFUSED || RCODE(header) == NOTIMP)
 	server = NULL;
       else
 	{
@@ -606,7 +606,7 @@
      had replies from all to avoid filling the forwarding table when
      everything is broken */
   if (forward->forwardall == 0 || --forward->forwardall == 1 || 
-      (RCODE(header) != REFUSED && RCODE(header) != SERVFAIL))
+      (RCODE(header) != REFUSED && RCODE(header) != SERVFAIL && RCODE(header) != NOTIMP))
     {
       int check_rebind = !(forward->flags & FREC_NOREBIND);
 

