Skip to content

ARP Table: hostname uses reverse DNS lookup as fallback#6016

Merged
AdSchellevis merged 6 commits intoopnsense:masterfrom
soif:arp_table_hostname
Sep 13, 2022
Merged

ARP Table: hostname uses reverse DNS lookup as fallback#6016
AdSchellevis merged 6 commits intoopnsense:masterfrom
soif:arp_table_hostname

Conversation

@soif
Copy link
Contributor

@soif soif commented Sep 12, 2022

Arp table only relies on dhcp-leases entries to get the hostname. So when using an external DHCP server, or for IP addresses that are not assigned by DHCP, the displayed hostnames are always blank.

Features added:

  • if hostame is not found in the dhcp-leases, the hostname is fetched from a DNS PTR query, (using the system's DNS server).
  • use_dns variable can allow/disallow this behaviour (useful is someone would like to move this to a system preference)

HTH

@AdSchellevis
Copy link
Member

A similar construction as used for the routes might be acceptable, putting the burden to resolve (with timeouts for everyone) isn't, so if you're up for it, please change the PR to include the option to the endpoint, either as uri part or as parameter (latter might make more sense at the moment).

For some inspiration, the following code blocks are being used in the route dialog.

ajaxGet("/api/diagnostics/interface/getRoutes/", {resolve:resolve}, function (data, status) {

$backend = new Backend();
if (empty($this->request->get('resolve'))) {
$response = $backend->configdRun('interface routes list -n json');
} else {
$response = $backend->configdRun('interface routes list json');
}

sp = subprocess.run(['/usr/bin/netstat', '-rW' + resolv], capture_output=True, text=True)

ps: removing the -n from arp would resolve in the same pass.

@soif
Copy link
Contributor Author

soif commented Sep 12, 2022

Hi thanks for the fast review!

You're perfectly right. I wrongly assumed that the ARP table should typically be only filled with LAN IP addresses where DNS timeout is usually not an issue for in-addr.arpa zones. But for cases where OPNsense is used mainly with publically routables ip addresses, that obviously would create timeout issues.

Thanks for the inspiration examples (helps a LOT): I'm gonna fix the PR to make DNS resolving optionnal, like in routes.

@soif
Copy link
Contributor Author

soif commented Sep 12, 2022

Here it is.

Notice that:

  • i used the -r as additional parameter, that triggers the Reverse DNS.
    Without -r, the command behaves exactly as in the latest release.

  • I've added a natural sort of IP addresses (separate commit, to be easily reverted), as requested in IPs in ARP table not sorted numerically #4185.
    This is visible when using the command line:
    configctl "interface list arp -r"
    When using the GUI, and because Javascript sorts the results, it might still be usefull, when for example sorting by Interface or Interface name.

HTH

@AdSchellevis AdSchellevis self-assigned this Sep 13, 2022
@AdSchellevis AdSchellevis merged commit d2ee799 into opnsense:master Sep 13, 2022
@AdSchellevis
Copy link
Member

@soif thanks, I've made some small cleanups in 1548ae0 before merging. The natural sort has been left out for now as it will likely lead to new tickets since it doesn't fix the complete issue.

@soif
Copy link
Contributor Author

soif commented Sep 13, 2022

@AdSchellevis Thank you for the fast merge & cleanup. 👍

Happy to contribute! 😎

@soif soif deleted the arp_table_hostname branch September 16, 2022 09:05
fichtner pushed a commit that referenced this pull request Oct 7, 2022
…olution for ARP table hostnames

PR: #6016

(cherry picked from commit de07e8d)
(cherry picked from commit d5d8374)
(cherry picked from commit 5f4cd33)
(cherry picked from commit cdc4189)
(cherry picked from commit 1548ae0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants