From ee556e820f02c77716e74be727da319bd429fba4 Mon Sep 17 00:00:00 2001 From: Sebastien GISLAIN Date: Fri, 17 Nov 2023 15:44:22 +0100 Subject: [PATCH] dhcp.cgi: Add column with resolved hostname by IP address MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In web interface, on page DHCP Server, in table Current fixed leases, add column with resolved hostname by IP address Reviewed-by: Peter Müller --- html/cgi-bin/dhcp.cgi | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/html/cgi-bin/dhcp.cgi b/html/cgi-bin/dhcp.cgi index f45703f0b2..b87da69072 100755 --- a/html/cgi-bin/dhcp.cgi +++ b/html/cgi-bin/dhcp.cgi @@ -21,6 +21,7 @@ use strict; use experimental 'smartmatch'; +use IO::Socket; # enable only the following on debugging purpose #use warnings; @@ -1007,8 +1008,9 @@ END print < - $Lang::tr{'mac address'} - $Lang::tr{'ip address'} + $Lang::tr{'mac address'} + $Lang::tr{'ip address'} + $Lang::tr{'hostname'} $Lang::tr{'remark'} next-server filename @@ -1106,9 +1108,14 @@ foreach my $line (@current2) { $TAG4 = "class='red'" if ($dhcpsettings{'KEY2'} ne $key); } + # resolved name (if exists) + my $iaddr = inet_aton($temp[1]); + my $rname = gethostbyaddr($iaddr, AF_INET); + if (!$rname || $rname eq "") { $rname = $Lang::tr{'ptr lookup failed'}; } print <$TAG2$temp[0]$TAG3 $TAG0$temp[1]$TAG1 +$rname  $temp[6]  $temp[3]  $temp[4]  -- 2.39.5