diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc
index ba289c1b42baf47c9eb99d418776de6c9f9bf7a5..c40de90931db32ee5eec81a7ce0fd7cabd5ffec0 100644
--- a/src/etc/inc/system.inc
+++ b/src/etc/inc/system.inc
@@ -672,7 +672,7 @@ function system_dhcpleases_configure() {
 	}
 }
 
-function system_get_dhcpleases() {
+function system_get_dhcpleases($dnsavailable=null) {
 	global $config, $g;
 
 	$leases = array();
@@ -730,6 +730,7 @@ function system_get_dhcpleases() {
 	$failover = false;
 	$dedup_lease = false;
 	$dedup_failover = false;
+
 	foreach ($leases_content as $line) {
 		/* Skip comments */
 		if (preg_match('/^\s*(|#.*)$/', $line)) {
@@ -739,9 +740,14 @@ function system_get_dhcpleases() {
 		if (preg_match('/}$/', $line)) {
 			if ($lease) {
 				if (empty($item['hostname'])) {
-					$hostname = gethostbyaddr($item['ip']);
-					if (!empty($hostname)) {
-						$item['hostname'] = $hostname;
+					if (is_null($dnsavailable)) {
+						$dnsavailable = check_dnsavailable();
+					}
+					if ($dnsavailable) {
+						$hostname = gethostbyaddr($item['ip']);
+						if (!empty($hostname)) {
+							$item['hostname'] = $hostname;
+						}
 					}
 				}
 				$leases['lease'][] = $item;
@@ -2704,4 +2710,33 @@ function system_get_arp_table($resolve_hostnames = false) {
 	return $arp_table;
 }
 
+function _getHostName($mac, $ip) {
+	global $dhcpmac, $dhcpip;
+
+	if ($dhcpmac[$mac]) {
+		return $dhcpmac[$mac];
+	} else if ($dhcpip[$ip]) {
+		return $dhcpip[$ip];
+	} else {
+		exec("host -W 1 " . escapeshellarg($ip), $output);
+		if (preg_match('/.*pointer ([A-Za-z_0-9.-]+)\..*/', $output[0], $matches)) {
+			if ($matches[1] <> $ip) {
+				return $matches[1];
+			}
+		}
+	}
+	return "";
+}
+
+function check_dnsavailable() {
+	$dns = trim(_getHostName("", "8.8.8.8"));
+	if ($dns == "") {
+		$dns = trim(_getHostName("", "8.8.4.4"));
+		if ($dns == "") {
+			return false;
+		}
+	}
+	return true;
+}
+
 ?>
diff --git a/src/usr/local/bin/dhcpd_gather_stats.php b/src/usr/local/bin/dhcpd_gather_stats.php
index 40865130a8037ceaad2891b7c7c814ab10d6e8cc..a5cb0e90c9cf6a61095799b62acb21b928e3e3f3 100644
--- a/src/usr/local/bin/dhcpd_gather_stats.php
+++ b/src/usr/local/bin/dhcpd_gather_stats.php
@@ -36,7 +36,7 @@ $result['range'] = "NaN";
 if (is_array($config['dhcpd'][$argv[1]])) {
 
 	$dhcpif = $argv[1] ;
-	$leases = system_get_dhcpleases();
+	$leases = system_get_dhcpleases(false);
 
 	$ifcfgip = get_interface_ip($dhcpif);
 	$ifcfgsn = get_interface_subnet($dhcpif);
diff --git a/src/usr/local/pfSense/include/www/diag_arp.inc b/src/usr/local/pfSense/include/www/diag_arp.inc
index 568657f2ffd409bb4733406ff6ad7fa9a8536017..6aeee09ecbbf0729507ef381e8c7e8b90226df3b 100644
--- a/src/usr/local/pfSense/include/www/diag_arp.inc
+++ b/src/usr/local/pfSense/include/www/diag_arp.inc
@@ -31,28 +31,10 @@ require_once("config.gui.inc");
 $dhcpmac = array();
 $dhcpip = array();
 
-function _getHostName($mac, $ip) {
-	global $dhcpmac, $dhcpip;
-
-	if ($dhcpmac[$mac]) {
-		return $dhcpmac[$mac];
-	} else if ($dhcpip[$ip]) {
-		return $dhcpip[$ip];
-	} else {
-		exec("host -W 1 " . escapeshellarg($ip), $output);
-		if (preg_match('/.*pointer ([A-Za-z_0-9.-]+)\..*/', $output[0], $matches)) {
-			if ($matches[1] <> $ip) {
-				return $matches[1];
-			}
-		}
-	}
-	return "";
-}
-
 function prepare_ARP_table($json = false) {
 	global $dhcpmac, $dhcpip;
 
-	$leases = system_get_dhcpleases();
+	$leases = system_get_dhcpleases(false);
 
 	// Put this in an easy to use form
 	$dhcpmac = array();
@@ -88,20 +70,19 @@ function prepare_ARP_table($json = false) {
 	// Resolve hostnames and replace Z_ with "".  The intention
 	// is to sort the list by hostnames, alpha and then the non
 	// resolvable addresses will appear last in the list.
-	$dnsavailable=1;
-	$dns = trim(_getHostName("", "8.8.8.8"));
-	if ($dns == "") {
-		$dns = trim(_getHostName("", "8.8.4.4"));
-		if ($dns == "") {
-			$dnsavailable = 0;
-		}
-	}
 
 	foreach ($arp_table as &$entry) {
 		// Add dnsresolve
-		if ($dnsavailable && !empty($entry['mac-address'])) {
-			$dns = trim(_getHostName($entry['mac-address'],
-			    $entry['ip-address']));
+		if (!empty($entry['mac-address'])) {
+			if (is_null($dnsavailable)) {
+				$dnsavailable = check_dnsavailable();
+			}
+			if ($dnsavailable) {
+				$dns = trim(_getHostName($entry['mac-address'],
+					$entry['ip-address']));
+			} else {
+				$dns="";
+			}
 		} else {
 			$dns="";
 		}
@@ -165,4 +146,4 @@ function prepare_ARP_table($json = false) {
 
 }
 
-?>
\ No newline at end of file
+?>
