Learn Simpli

Free Online Tutorial For Programmers, Contains a Solution For Question in Programming. Quizzes and Practice / Company / Test interview Questions.

DNS in nodeJS

Introduction
  1. Domain Name System (DNS)
  2. The DNS module enables name resolution. For example, use it to look up IP addresses of hostnames
  3. Uses the DNS protocol for lookups
  4. dns.lookup() uses the operating system facilities to perform name resolution
const dns = require('dns');
dns.lookup('domainname', (err, address, family) => {
    console.log('address: %j family: IPv%s', address, family);
});
// address: IP address family: IPv4