Background:
Hi all,
I'm currently taking a deep dive into DNS and learning using NodeJS and I'm having trouble understanding why I cannot perform a reverse lookup on a local IP address using the dns.reverse() function.
Details:
Code:
const dns = require('node:dns');
// Reverse DNS lookup
dns.reverse('192.168.0.20', (err, addr) =>{
if (err){
console.log(err);
}
console.log(addr);
})
// DNS lookup
dns.lookup('mypc-hostname', (err, addr) =>{
if (err){
console.log(err);
}
console.log(addr);
})
Results:
192.168.0.20
Error: getHostByAddr ENOTFOUND 192.168.0.20
at QueryReqWrap.onresolve [as oncomplete] (node:dns:279:19) {
errno: undefined,
code: 'ENOTFOUND',
syscall: 'getHostByAddr',
hostname: '192.168.0.20'
}
undefined
As you can see, the results indicate that the IP address of the hostname can be resolved, however the reverse DNS lookup for the IP address does not return the desired hostname. I'm confused as since resolving the hostname into an IP address completes with seemingly no issues.
Any ideas? Please feel free to call out flaws in my logic :) Thanks!