http://www.w3big.com/ko/nodejs/nodejs-dns-module.html
DNS 모듈 Node.js를
DNS 모듈 Node.js를 DNS 모듈 Node.js를 Node.js를 도구 모듈 DNS 모듈Node.js를 도메인 이름을 확인하는 데 사용됩니다.다음과 같이 DNS 모듈 구문의 도입은 다음과 같습니다 var dns = require("dns") 방법 아니오. 방법 및 설명 (1) dns.lookup (호스트 이름 [옵션], 콜백) 해결 된 도메인 이름 (예 : 'w3big.com')는 첫 번째 레코드 A (IPV4) 또는 AAAA (IPV6)을 찾을
www.w3big.com
dns.lookup: 지정된 주소의 ip주소를 찾아낸다
dns.resolive: 지정된 유형에따라 레코드 유형의 배열을 반환
dns.reverse : 지정된 ip주소의 도메인명을 찾아냄
const dns = require('dns');
//address:주소 family : ip 버전 (ipv4 or ipv6)
dns.lookup('test.com', (err, address, family) => {
console.log(`address: ${address}, ${family}`);
});
//지정된 유형에 따라 레코드 유형의 배열을 반환한다
dns.resolve4('archive.org', (err, addresses) => {
if (err) throw err;
const res = JSON.stringify(addresses);
console.log(res);
addresses.forEach((a) => {
// 지정된 IP주소의 도메인 명을 찾아낸다
dns.reverse(a, (err, hostnames) => {
if (err) throw err;
console.log(`reverse for ${a}; ${JSON.stringify(hostnames)}`);
});
});
});
'Node.js > node 기초' 카테고리의 다른 글
express 글로벌 변수및 404, 500 에러 핸들링 (0) | 2020.05.15 |
---|---|
express 정적 파일 생성하기 (0) | 2020.05.15 |
미들웨어(middleware) (0) | 2020.05.15 |
http 내장모듈을 활용한 서버 구축하기 (0) | 2020.05.05 |
node EventEmitter (0) | 2020.05.04 |