/etc/hosts on Linux

2009-10-20 11:56:50 Operation System Views(430)

简言之:主机名 to IP地址,功能类似DNS,但与DNS不同的是hosts文件是本地系统管理员可控的。

The /etc/hosts file on linux is a computer file used by an operating system to map hostnames to IP addresses.

Unlike DNS, the hosts file is under the control of the local computer's administrator.

文件格式:

IP地址             主机名                   别名

127.0.0.1        localhost       www.localhost.com

用途1:

#虚拟域名

127.0.0.1    localhost      smartkit.org

在浏览器中输入http://smartkit.org将自动跳转到本地Web服务器根目录(如Apache)

用途2:

Web服务器配置为基于域名(主机名)的多个虚拟主机时,客户机如何访问:如Linux服务器IP为192.168.0.9,其下挂example.com和example.org两个站点,则可直接修改Windows客户机的C:\WINDOWS\system32\drivers\etc\hosts文件,将这两个域名直接映射到Web服务器IP地址 。

用途3:

#最近发现google相册Picasa不能访问(多半被域名劫持),在/etc/hosts文件中添加以下行以绕过GWF:

74.125.91.99 www.picasa.com
74.125.91.103 picasa.google.com
203.208.33.100 lh1.ggpht.com
203.208.33.100 lh2.ggpht.com
203.208.33.100 lh3.ggpht.com
203.208.33.100 lh4.ggpht.com
203.208.33.100 lh5.ggpht.com
203.208.33.100 lh6.ggpht.com
203.208.33.100 lh7.ggpht.com
203.208.33.100 lh8.ggpht.com

OK!!!

Tags:   hosts  proxy

Comments

Leave a Comment

Name
Content
Verification Type the characters you see in the picture below