티스토리 뷰
반응형
자바로 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)
반응형