Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 8fdb18e1b43cce69fbf3e0ce3a63e333e77c79db)
+++ uspace/Makefile	(revision 4e71618092ebe577592604ad7b834fcf812406ff)
@@ -39,4 +39,5 @@
 	app/bnchmark \
 	app/devctl \
+	app/dnscfg \
 	app/dnsres \
 	app/edit \
Index: uspace/app/dnscfg/Makefile
===================================================================
--- uspace/app/dnscfg/Makefile	(revision 4e71618092ebe577592604ad7b834fcf812406ff)
+++ uspace/app/dnscfg/Makefile	(revision 4e71618092ebe577592604ad7b834fcf812406ff)
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2013 Jiri Svoboda
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../..
+BINARY = dnscfg
+
+SOURCES = \
+	dnscfg.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/app/dnscfg/dnscfg.c
===================================================================
--- uspace/app/dnscfg/dnscfg.c	(revision 4e71618092ebe577592604ad7b834fcf812406ff)
+++ uspace/app/dnscfg/dnscfg.c	(revision 4e71618092ebe577592604ad7b834fcf812406ff)
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2013 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup dnscfg
+ * @{
+ */
+/** @file DNS configuration utility.
+ *
+ * Controls the DNS resolution server (@c dnsrsrv).
+ */
+
+#include <errno.h>
+#include <inet/addr.h>
+#include <inet/dnsr.h>
+#include <ipc/services.h>
+#include <loc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <str_error.h>
+#include <sys/types.h>
+
+#define NAME "dnscfg"
+
+static void print_syntax(void)
+{
+	printf("syntax:\n");
+	printf("\t" NAME " set-ns <server-addr>\n");
+	printf("\t" NAME " unset-ns\n");
+}
+
+static int dnscfg_set_ns(int argc, char *argv[])
+{
+	char *srv_addr;
+	inet_addr_t addr;
+	int rc;
+
+	if (argc < 1) {
+		printf(NAME ": Missing arguments.\n");
+		print_syntax();
+		return EINVAL;
+	}
+
+	if (argc > 1) {
+		printf(NAME ": Too many arguments.\n");
+		print_syntax();
+		return EINVAL;
+	}
+
+	srv_addr = argv[0];
+
+	rc = inet_addr_parse(srv_addr, &addr);
+	if (rc != EOK) {
+		printf(NAME ": Invalid address format '%s'.\n", srv_addr);
+		return EINVAL;
+	}
+
+	rc = dnsr_set_srvaddr(&addr);
+	if (rc != EOK) {
+		printf(NAME ": Failed setting server address '%s' (%s)\n",
+		    srv_addr, str_error(rc));
+		return EIO;
+	}
+
+	return EOK;
+}
+
+static int dnscfg_unset_ns(int argc, char *argv[])
+{
+	inet_addr_t addr;
+	int rc;
+
+	if (argc > 0) {
+		printf(NAME ": Too many arguments.\n");
+		print_syntax();
+		return EINVAL;
+	}
+
+	addr.ipv4 = 0;
+	rc = dnsr_set_srvaddr(&addr);
+	if (rc != EOK) {
+		printf(NAME ": Failed unsetting server address (%s)\n",
+		    str_error(rc));
+		return EIO;
+	}
+
+	return EOK;
+}
+
+static int dnscfg_print(void)
+{
+	inet_addr_t addr;
+	char *addr_str;
+	int rc;
+
+	rc = dnsr_get_srvaddr(&addr);
+	if (rc != EOK) {
+		printf(NAME ": Failed getting DNS server address.\n");
+		return rc;
+	}
+
+	rc = inet_addr_format(&addr, &addr_str);
+	if (rc != EOK) {
+		printf(NAME ": Out of memory.\n");
+		return rc;
+	}
+
+	printf("Server: %s\n", addr_str);
+	free(addr_str);
+	return EOK;
+}
+
+int main(int argc, char *argv[])
+{
+	int rc;
+
+	if (argc < 2) {
+		rc = dnscfg_print();
+		if (rc != EOK)
+			return 1;
+		return 0;
+	}
+
+	if (str_cmp(argv[1], "set-ns") == 0) {
+		rc = dnscfg_set_ns(argc - 2, argv + 2);
+		if (rc != EOK)
+			return 1;
+	} else if (str_cmp(argv[1], "unset-ns") == 0) {
+		rc = dnscfg_unset_ns(argc - 2, argv + 2);
+		if (rc != EOK)
+			return 1;
+	} else {
+		printf(NAME ": Unknown command '%s'.\n", argv[1]);
+		print_syntax();
+		return 1;
+	}
+
+
+	return 0;
+}
+
+/** @}
+ */
Index: uspace/srv/net/dnsrsrv/dnsrsrv.c
===================================================================
--- uspace/srv/net/dnsrsrv/dnsrsrv.c	(revision 8fdb18e1b43cce69fbf3e0ce3a63e333e77c79db)
+++ uspace/srv/net/dnsrsrv/dnsrsrv.c	(revision 4e71618092ebe577592604ad7b834fcf812406ff)
@@ -114,17 +114,6 @@
     ipc_call_t *call)
 {
-//	inet_addr_t remote;
-//	uint8_t tos;
-//	inet_addr_t local;
-//	int rc;
-
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_get_srvaddr_srv()");
-
-/*	remote.ipv4 = IPC_GET_ARG1(*call);
-	tos = IPC_GET_ARG2(*call);
-	local.ipv4 = 0;
-
-	rc = inet_get_srcaddr(&remote, tos, &local);*/
-	async_answer_1(callid, EOK, 0x01020304);
+	async_answer_1(callid, EOK, dns_server_addr.ipv4);
 }
 
@@ -132,12 +121,8 @@
     ipc_call_t *call)
 {
-//	inet_addr_t naddr;
-//	int rc;
-
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "dnsr_set_srvaddr_srv()");
 
-//	naddr.ipv4 = IPC_GET_ARG1(*call);
+	dns_server_addr.ipv4 = IPC_GET_ARG1(*call);
 
-	/*rc = inet_get_srcaddr(&remote, tos, &local);*/
 	async_answer_0(callid, EOK);
 }
@@ -151,6 +136,4 @@
 	/* Accept the connection */
 	async_answer_0(iid, EOK);
-
-//	inet_client_init(&client);
 
 	while (true) {
@@ -179,6 +162,4 @@
 		}
 	}
-
-//	inet_client_fini(&client);
 }
 
Index: uspace/srv/net/dnsrsrv/transport.c
===================================================================
--- uspace/srv/net/dnsrsrv/transport.c	(revision 8fdb18e1b43cce69fbf3e0ce3a63e333e77c79db)
+++ uspace/srv/net/dnsrsrv/transport.c	(revision 4e71618092ebe577592604ad7b834fcf812406ff)
@@ -49,4 +49,5 @@
 
 #define RECV_BUF_SIZE 4096
+#define DNS_SERVER_PORT 53
 
 /** Request timeout (microseconds) */
@@ -68,4 +69,5 @@
 static fid_t recv_fid;
 static int transport_fd = -1;
+inet_addr_t dns_server_addr;
 
 /** Outstanding requests */
@@ -187,6 +189,6 @@
 
 	addr.sin_family = AF_INET;
-	addr.sin_port = htons(53);
-	addr.sin_addr.s_addr = htonl((10 << 24) | (0 << 16) | (0 << 8) | 138);
+	addr.sin_port = htons(DNS_SERVER_PORT);
+	addr.sin_addr.s_addr = host2uint32_t_be(dns_server_addr.ipv4);
 
 	rc = dns_message_encode(req, &req_data, &req_size);
Index: uspace/srv/net/dnsrsrv/transport.h
===================================================================
--- uspace/srv/net/dnsrsrv/transport.h	(revision 8fdb18e1b43cce69fbf3e0ce3a63e333e77c79db)
+++ uspace/srv/net/dnsrsrv/transport.h	(revision 4e71618092ebe577592604ad7b834fcf812406ff)
@@ -37,4 +37,5 @@
 #define TRANSPORT_H
 
+#include <inet/addr.h>
 #include "dns_type.h"
 
@@ -43,4 +44,7 @@
 extern int dns_request(dns_message_t *, dns_message_t **);
 
+extern inet_addr_t dns_server_addr;
+
+
 #endif
 
