리눅스 hosts 파일

(/etc/hosts에서 넘어옴)

1 개요[ | ]

리눅스 호스트 파일
리눅스 /etc/hosts
  • 리눅스에서 DNS보다 먼저 호스트명을 IP로 풀어주는 파일

2 예시: CentOS[ | ]

hosts 파일의 기본값(default)은 CentOS 5, 6, 7의 경우 다음과 같았다.

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

3 예시: Ubuntu[ | ]

우분투16, 우분투18
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

4 예시: Mac OS X 10.7.3[ | ]

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

5 테스트[ | ]

예를 들어 hosts 파일 내용을 아래와 같이 같은 이름 test1을 2개 설정한 경우, test1을 호출하면 위에 있는 8.8.8.8로 접속을 시도한다.

[root@zetawiki ~]# cat /etc/hosts
8.8.8.8 test1
8.8.4.4 test1
[root@zetawiki ~]# ping test1
PING test1 (8.8.8.8) 56(84) bytes of data.

6 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}