330505b
diff --git a/common/dns.c b/common/dns.c
330505b
index 0f8be80..37878bc 100644
330505b
--- a/common/dns.c
330505b
+++ b/common/dns.c
330505b
@@ -2132,6 +2132,41 @@ void ddns_interlude(isc_task_t  *taskp,
330505b
 }
330505b
 
330505b
 /*
330505b
+ * Moved here from omapip/isclib.c, function dhcp_context_create.
330505b
+ * Create dnsclient only before the first use.
330505b
+ */
330505b
+static isc_result_t
330505b
+dns_client_lazy() {
330505b
+	isc_result_t result;
330505b
+	if (dhcp_gbl_ctx.dnsclient == NULL){
330505b
+		result = dns_client_createx2(dhcp_gbl_ctx.mctx,
330505b
+					     dhcp_gbl_ctx.actx,
330505b
+					     dhcp_gbl_ctx.taskmgr,
330505b
+					     dhcp_gbl_ctx.socketmgr,
330505b
+					     dhcp_gbl_ctx.timermgr,
330505b
+					     0,
330505b
+					     &dhcp_gbl_ctx.dnsclient,
330505b
+					     dhcp_gbl_ctx.local4_ptr,
330505b
+					     dhcp_gbl_ctx.local6_ptr);
330505b
+		if (result != ISC_R_SUCCESS)
330505b
+			return result;
330505b
+		/*
330505b
+		 * If we can't set up the servers we may not be able to
330505b
+		 * do DDNS but we should continue to try and perform
330505b
+		 * our basic functions and let the user sort it out.
330505b
+		 */
330505b
+		result = dhcp_dns_client_setservers();
330505b
+		if (result != ISC_R_SUCCESS) {
330505b
+			log_error("Unable to set resolver from resolv.conf; "
330505b
+				  "startup continuing but DDNS support "
330505b
+				  "may be affected");
330505b
+		}
330505b
+	};
330505b
+	return ISC_R_SUCCESS;
330505b
+}
330505b
+
330505b
+
330505b
+/*
330505b
  * This routine does the generic work for sending a ddns message to
330505b
  * modify the forward record (A or AAAA) and calls one of a set of
330505b
  * routines to build the specific message.
330505b
@@ -2154,6 +2189,10 @@ ddns_modify_fwd(dhcp_ddns_cb_t *ddns_cb, const char *file, int line)
330505b
 	/* Get a pointer to the clientname to make things easier. */
330505b
 	clientname = (unsigned char *)ddns_cb->fwd_name.data;
330505b
 
330505b
+	result = dns_client_lazy();
330505b
+	if (result != ISC_R_SUCCESS)
330505b
+		return result;
330505b
+
330505b
 	/* Extract and validate the type of the address. */
330505b
 	if (ddns_cb->address.len == 4) {
330505b
 		ddns_cb->address_type = dns_rdatatype_a;
330505b
@@ -2359,6 +2398,10 @@ ddns_modify_ptr(dhcp_ddns_cb_t *ddns_cb, const char *file, int line)
330505b
 	unsigned char buf[256];
330505b
 	int buflen;
330505b
 
330505b
+	result = dns_client_lazy();
330505b
+	if (result != ISC_R_SUCCESS)
330505b
+		return result;
330505b
+
330505b
 	/*
330505b
 	 * Try to lookup the zone in the zone cache.  As with the forward
330505b
 	 * case it's okay if we don't have one, the DNS code will try to
330505b
diff --git a/includes/omapip/isclib.h b/includes/omapip/isclib.h
330505b
index caa388a..7f2719b 100644
330505b
--- a/includes/omapip/isclib.h
330505b
+++ b/includes/omapip/isclib.h
330505b
@@ -98,6 +98,8 @@ typedef struct dhcp_context {
330505b
 	isc_timermgr_t	*timermgr;
330505b
 #if defined (NSUPDATE)
330505b
   	dns_client_t    *dnsclient;
330505b
+	isc_sockaddr_t  *local4_ptr;
330505b
+	isc_sockaddr_t  *local6_ptr;
330505b
 #endif
330505b
 } dhcp_context_t;
330505b
 
330505b
diff --git a/omapip/isclib.c b/omapip/isclib.c
330505b
index 13f0d3e..36b399d 100644
330505b
--- a/omapip/isclib.c
330505b
+++ b/omapip/isclib.c
330505b
@@ -220,40 +220,22 @@ dhcp_context_create(int flags,
330505b
 	}
330505b
 
330505b
 #if defined (NSUPDATE)
330505b
+        /*
330505b
+        * Setting addresses only.
330505b
+        * All real work will be done later on if needed to avoid listening 
330505b
+        * on ddns port if client/server was compiled with ddns support 
330505b
+        * but not using it.
330505b
+        */
330505b
 	if ((flags & DHCP_CONTEXT_POST_DB) != 0) {
330505b
-		isc_sockaddr_t localaddr4, *localaddr4_ptr = NULL;
330505b
-		isc_sockaddr_t localaddr6, *localaddr6_ptr = NULL;
330505b
+		isc_sockaddr_t localaddr4;
330505b
+		isc_sockaddr_t localaddr6;
330505b
 		if (local4 != NULL) {
330505b
 			isc_sockaddr_fromin(&localaddr4, local4, 0);
330505b
-			localaddr4_ptr = &localaddr4;
330505b
+			dhcp_gbl_ctx.local4_ptr = &localaddr4;
330505b
 		}
330505b
 		if (local6 != NULL) {
330505b
 			isc_sockaddr_fromin6(&localaddr6, local6, 0);
330505b
-			localaddr6_ptr = &localaddr6;
330505b
-		}
330505b
-
330505b
-		result = dns_client_createx2(dhcp_gbl_ctx.mctx,
330505b
-					     dhcp_gbl_ctx.actx,
330505b
-					     dhcp_gbl_ctx.taskmgr,
330505b
-					     dhcp_gbl_ctx.socketmgr,
330505b
-					     dhcp_gbl_ctx.timermgr,
330505b
-					     0,
330505b
-					     &dhcp_gbl_ctx.dnsclient,
330505b
-					     localaddr4_ptr,
330505b
-					     localaddr6_ptr);
330505b
-		if (result != ISC_R_SUCCESS)
330505b
-			goto cleanup;
330505b
-
330505b
-		/*
330505b
-		 * If we can't set up the servers we may not be able to
330505b
-		 * do DDNS but we should continue to try and perform
330505b
-		 * our basic functions and let the user sort it out.
330505b
-		 */
330505b
-		result = dhcp_dns_client_setservers();
330505b
-		if (result != ISC_R_SUCCESS) {
330505b
-			log_error("Unable to set resolver from resolv.conf; "
330505b
-				  "startup continuing but DDNS support "
330505b
-				  "may be affected");
330505b
+			dhcp_gbl_ctx.local6_ptr = &localaddr6;
330505b
 		}
330505b
 	}
330505b
 #endif