- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Node.js - dns.reverse() Method
The dns.reverse() method is somewhat opposite of the method dns.lookup().This method performs a reverse DNS query that resolves an IPv4 or IPv6 to an array of host names.
Syntax
dns.reverse(ip, callback)
Parameters
ip – This takes an input for ip as a string, for which the DNS needs to be found.
callback – It will catch errors, if any.
Example 1
Create a file with the name "reverse.js" and copy the following code snippet. After creating the file, use the command "node reverse.js" to run this code as shown in the example below −
// dns.reverse() method Demo Example // Importing the dns module const dns = require('dns'); // It will return the dns name dns.reverse('127.0.0.53', (err, addresses) => console.log('addresses: %j', addresses));
Output
C:\home
ode>> node reverse.js addresses: ["localhost"]
Example 2
// dns.reverse() method Demo Example // Importing the dns module const dns = require('dns'); // It will return the dns name dns.reverse('127.0.0.1', (err, addresses) => console.log('addresses: %j', addresses)); // It will return the dns name dns.reverse('95.217.74.146', (err, addresses) => console.log('addresses: %j', addresses));
Output
C:\home
ode>> node reverse.js addresses: [] addresses: ["static.146.74.217.95.clients.your-server.de"]
Advertisements