메뉴 닫기

hosts 파일

리눅스나 윈도우에는 hosts 라는 파일이 있습니다

# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

리눅스의 경우 위와같은 내용이 기본값으로 들어가있으며

# Copyright (c) 1993-2009 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

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

윈도우의 경우 C:\Windows\System32\drivers\etc 경로에있는 hosts파일이  위와같은 내용으로 들어가있습니다.

현재는 bind 등을 이용하여 dns 서버를 구축하여 사용하지만 

hosts 파일은 dns 가 존재하지 않던 옛날에 도메인과 ip 주소를 짝지어 직접 등록하여 도메인에 대한 ip 주소를 찾아가도록 설정하는 파일입니다

 

현재는 도메인과 ip 주소를 따로 등록하지 않아도 dns서버에 요청을 해서 해당 도메인에 접속이 가능합니다

하지만 hosts 파일에 도메인과 해당 도메인에 대한 ip주소를 입력해놓을 경우 따로 dns 서버에 요청을 하지 않고 해당 도메인에 바로 접속이 가능합니다

hosts 파일의 수정을 통해서 일종의 트릭으로 원하는 ip와 도메인을 등록하여 사용할 수 있습니다.

현재 저희 스마일서브에서 사용하는 부분으로는 A 라는 서버에서 B라는 서버로  ‘논스톱 사이트’ 이전 등의 작업을 진행할 시 B 서버에 사이트 이전작업에 대한 테스트용으로

hosts 파일에 해당 도메인 의 ip 주소를 A서버가 아닌 B 서버로 등록하여 사이트 테스트를 진행하는 방식으로 이용중입니다.

    [polldaddy rating=”7739789″]

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x