prosodyctl: check dns: List discovered addresses for diagnostic purposes
authorMatthew Wild <mwild1@gmail.com>
Wed, 02 Mar 2022 16:02:42 +0000
changeset 12323 8fc3c06f922d
parent 12322 239ce74aa6a4
child 12324 f0be98bab9dd
prosodyctl: check dns: List discovered addresses for diagnostic purposes It is very common to get the "unknown address" warning with this command, but people do not always understand it, or know how to debug it. Now we clearly show the addresses that prosodyctl discovered.
util/prosodyctl/check.lua
--- a/util/prosodyctl/check.lua	Wed Mar 02 15:45:24 2022 +0000
+++ b/util/prosodyctl/check.lua	Wed Mar 02 16:02:42 2022 +0000
@@ -560,6 +560,8 @@
 			return (n:gsub("%.$", ""));
 		end
 
+		local unknown_addresses = set.new();
+
 		for jid, host_options in enabled_hosts() do
 			local all_targets_ok, some_targets_ok = true, false;
 			local node, host = jid_split(jid);
@@ -742,6 +744,7 @@
 								print("    "..target_host.." A record points to internal address, external connections might fail");
 							else
 								print("    "..target_host.." A record points to unknown address "..record.a);
+								unknown_addresses:add(record.a);
 								all_targets_ok = false;
 							end
 						end
@@ -760,6 +763,7 @@
 								print("    "..target_host.." AAAA record points to internal address, external connections might fail");
 							else
 								print("    "..target_host.." AAAA record points to unknown address "..record.aaaa);
+								unknown_addresses:add(record.aaaa);
 								all_targets_ok = false;
 							end
 						end
@@ -805,6 +809,18 @@
 			print("");
 		end
 		if not problem_hosts:empty() then
+			if not unknown_addresses:empty() then
+				print("");
+				print("Some of your DNS records point to unknown IP addresses. This may be expected if your server");
+				print("is behind a NAT or proxy. The unrecognized addresses were:");
+				print("");
+				print("    Unrecognized: "..tostring(unknown_addresses));
+				print("");
+				print("The addresses we found on this system are:");
+				print("");
+				print("    Internal: "..tostring(internal_addresses));
+				print("    External: "..tostring(external_addresses));
+			end
 			print("");
 			print("For more information about DNS configuration please see https://prosody.im/doc/dns");
 			print("");