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