Index: CHANGELOG
===================================================================
--- CHANGELOG	(revision 3a67dfd7ce558dc401b99744a85bfb78e1890125)
+++ CHANGELOG	(revision 025fb1bf1f1030f163d42868672055cda17597a4)
@@ -18,4 +18,6 @@
 		Should remove the need for the -c option and also work with
 		bugfixed DNS servers worldwide.
+	- Added -D option on server to enable debugging. Debug level 1 now prints
+		info about each RX/TX datagram.
 
 2007-11-30: 0.4.1 "Tea Online"
Index: man/iodine.8
===================================================================
--- man/iodine.8	(revision 0d3494ae7887f2e171f0d4958ffddad1c308e569)
+++ man/iodine.8	(revision 025fb1bf1f1030f163d42868672055cda17597a4)
@@ -26,5 +26,5 @@
 .B iodined [-h]
 
-.B iodined [-c] [-s] [-f] [-u
+.B iodined [-c] [-s] [-f] [-D] [-u
 .I user
 .B ] [-P
@@ -80,10 +80,12 @@
 .TP
 .B -c
-Disable checks on client IP and port on all incoming requests.
-This might help if server is behind a NAT firewall.
+Disable checks on client IP on all incoming requests.
 .TP
 .B -s
 Don't try to configure IP address or MTU. This should only be used if
 you have already configured the device that will be used.
+.TP
+.B -D
+Increase debug level. Level 1 prints info about each RX/TX packet.
 .TP
 .B -m mtu
Index: src/iodined.c
===================================================================
--- src/iodined.c	(revision 539ebb27d973c0295519bd1247644405fb6794d0)
+++ src/iodined.c	(revision 025fb1bf1f1030f163d42868672055cda17597a4)
@@ -58,4 +58,6 @@
 static in_addr_t my_ip;
 
+static int debug;
+
 #if !defined(BSD) && !defined(__GLIBC__)
 static char *__progname;
@@ -328,4 +330,10 @@
 	if ((read = read_dns(dns_fd, &q)) <= 0)
 		return 0;
+
+	if (debug >= 1) {
+		struct sockaddr_in *tempin;
+		tempin = (struct sockaddr_in *) &(q.from);
+		printf("RX: client %s, type %d, name %s\n", inet_ntoa(tempin->sin_addr), q.type, q.name);
+	}
 	
 	switch (q.type) {
@@ -428,4 +436,11 @@
 	len = dns_encode(buf, sizeof(buf), q, QR_ANSWER, data, datalen);
 	
+	if (debug >= 1) {
+		struct sockaddr_in *tempin;
+		tempin = (struct sockaddr_in *) &(q->from);
+		printf("TX: client %s, type %d, name %s, %d bytes data\n", 
+			inet_ntoa(tempin->sin_addr), q->type, q->name, datalen);
+	}
+
 	sendto(fd, buf, len, 0, (struct sockaddr*)&q->from, q->fromlen);
 }
@@ -500,4 +515,5 @@
 	check_ip = 1;
 	skipipconfig = 0;
+	debug = 0;
 
 	b32 = get_base32_encoder();
@@ -514,5 +530,5 @@
 	srand(time(NULL));
 	
-	while ((choice = getopt(argc, argv, "vcsfhu:t:d:m:l:p:P:")) != -1) {
+	while ((choice = getopt(argc, argv, "vcsfhDu:t:d:m:l:p:P:")) != -1) {
 		switch(choice) {
 		case 'v':
@@ -530,4 +546,7 @@
 		case 'h':
 			help();
+			break;
+		case 'D':
+			debug++;
 			break;
 		case 'u':
@@ -604,4 +623,10 @@
 		printf("ALERT! Other dns servers expect you to run on port 53.\n");
 		printf("You must manually forward port 53 to port %d for things to work.\n", port);
+	}
+
+	if (debug) {
+		printf("Debug level %d enabled, will stay in foreground.\n", debug);
+		printf("Add more -D switches to set higher debug level.\n");
+		foreground = 1;
 	}
 
