티스토리 뷰

Java

[Java] nslookup

Jane Kwon 2021. 12. 24. 11:09
반응형

 

자바로 nslookup을 구현할 수 있다.

public void nslookup(String domain) {
	InetAddress[] inetaddr = null;

	try {
		inetaddr = InetAddress.getAllByName(domain);
	} catch(Exception e) {
		e.printStackTrace();
	}

	for (InetAddress inetAddress : inetaddr) {
    	System.out.println("-----------------------------");
		System.out.println(inetAddress.getHostName());
		System.out.println(inetAddress.getHostAddress());
		System.out.println(inetAddress.toString());
        System.out.println("-----------------------------");
	}
}

 

 

 

nslookup("google.com"); 을 실행한 결과

-----------------------------
google.com
172.217.26.238
google.com/172.217.26.238
-----------------------------
-----------------------------
google.com
2404:6800:4004:80b:0:0:0:200e
google.com/2404:6800:4004:80b:0:0:0:200e
-----------------------------

(참고 : https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=myeongdms55&logNo=220927725991, https://www.withover.com/2008/04/%EC%9E%90%EB%B0%94%EB%A1%9C-%EA%B5%AC%ED%98%84%ED%95%9C-nslookup.html)

 

 

 

 

 

반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/12   »
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 27 28
29 30 31
글 보관함