1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| const dns = require('dns');
dns.lookup('example.org', (err, address, family) => { console.log('address: %j family: IPv%s', address, family); });
dns.resolve4('juneleo.cn', (err, addresses) => { if (err) throw err;
console.log(`addresses: ${JSON.stringify(addresses)}`);
addresses.forEach((a) => { dns.reverse(a, (err, hostnames) => { if (err) { throw err; } console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`); }); }); });
const dnsArrays = dns.getServers(); dnsArrays.forEach((it) => { console.log(it) });
|