- 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 - dnsPromises.getServers() Method
The dnsPromises.getServers() method returns an array of IP address strings, formatted across RFC 5952. These IP strings are currently configured for DNS configurations. The string will include a port only if a custom port is used.
Syntax
dnsPromises.getServers( )
Example 1
Create a file with the name "getServers.js" and copy the following code snippet. After creating the file, use the command "node getServers.js" to run this code as shown in the example below −
// dnsPromises.getServers() Demo Example // Importing promises from dns module const { Resolver } = require('dns').promises; // Initializing resolver constructor const dnsPromises = new Resolver(); // Creating async function (async function() { // Getting addresses const addresses = await dnsPromises.getServers(); // Printing addresses console.log(addresses); })();
Output
C:\home
ode>> node getServers.js [ '127.0.0.53' ]
Example 2
// dnsPromises.getServers() Demo Example // Importing promises from dns module const { Resolver } = require('dns').promises; // Initializing resolver constructor const dnsPromises = new Resolver(); // Creating async function (async function() { // Getting addresses const addresses = await dnsPromises.getServers(); // Printing each address one by one addresses.forEach(element => { console.log(element); }); })();
Output
C:\home
ode>> node getServers.js '4.4.4.4', '2001:4860:4860::8888', '4.4.4.4:1053', '[2001:4860:4860::8888]:1053',
Advertisements