본문 바로가기

Languages/Java

JAVA - java.net.UnknownHostException

  • java.net.UnknownHostException

  • [원인]

웹 서버의 DNS 설정이 되어있지 않아서 발생되는 문제입니다.

이 문제는 localhost 환경에서는 발생되지 않지만, 직접 설치된 서버 혹은 외부서버에서 가동 시에 문제가 될 수 있습니다.

이 문제는 SNMP 통신 혹은 PING 등의 Network 관련 작업을 수행할 경우,

해당 웹 서버에서 외부로의 이동이 요구될 때 발생될 수 있는 문제입니다.

  • [해결방법]

각 웹 서버의 설정에 맞게 DNS 설정을 합니다.

[1] 서버가 IBM AIX 일 경우

telnet 으로 해당 서버에 접속 cd /etc/resolv.conf 파일을 vi 편집기로 수정하여

해당 ISP 의 네임서버와 IP 주소를 등록합니다.

(ex : 127.0.0.1 localhost )

[2] 서버가 TOMCAT 일 경우

telnet 으로 cd /etc/ 경로로 이동하여 vi 편집기로 hosts 파일을 수정합니다.

[1] 번과 마찬가지로 수정하면 됩니다.

ps. 운영체제는 리눅스 혹은 UNIX 기준입니다. Windows OS 일 경우 아래와 같이 변경하시면 됩니다.

경로 : windows/system32/driver/etc

위의 경로를 따라가면 hosts 라는 파일이 있습니다. 해당 파일을 메모장 혹은 기타 편집기를 이용하여

수정하시면 됩니다.

일반적인 hosts 파일의 내용은 아래와 같습니다만, 상이할 수 있습니다.

#========================================================================================

# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost
127.0.0.1 activate.adobe.com
127.0.0.1 3dns-3.adobe.com
127.0.0.1 adobe-dns-2.adobe.com
127.0.0.1 adobe-dns-3.adobe.com
127.0.0.1 ereg.wip3.adobe.com
127.0.0.1 activate-sea.adobe.com
127.0.0.1 wip3.adobe.com
127.0.0.1 wwis-dubc1-vip60.adobe.com
127.0.0.1 activate-sjc0.adobe.com
127.0.0.1 practivate.adobe.com
127.0.0.1 ereg.adobe.com
127.0.0.1 activate.wip3.adobe.com
127.0.0.1 3dns-2.adobe.com
127.0.0.1 adobe-dns.adobe.com

#========================================================================================

참고http://junyong.tistory.com/92

참고http://hosang.tistory.com/entry/javanetUnknownHostException

참고: http://www.google.co.kr/search?hl=ko&q=java.net.UnknownHostException&lr=