• Windows Host 文件


    什么是Host文件?

    ===================

    简单的答案就是: host文件就像一个地址本. 当你在你的浏览器中键入一个网址的时候, host文件会被查询到, 看你是否已经为那个站点设置了IP地址. 如果你设置了, 那么你的计算机会用这个IP去打开站点. 如果没有, 那么计算机回去查询你的internet service provider(ISP)的计算机去查找IP地址. 多数的时候, 在host文件中不会有那些IP. 所以多数时候, 计算机会去查询ISP来获得IP地址.

    长一点的答案是: Windows和其他操作系统使用host文件来将主机名与IP地址对应起来.

    查找与主机名对应的IP需要一系列的步骤:

    先查询你本机的host文件. host文件会告诉你的计算机主机名对应的IP地址, 这样你的计算机就会停止查询, 直接打开站点. 但是如果它没找到, 它就会去询问DNS服务器(domain name server), 索要信息.

     

    Host文件的位置

    ===================

    Windows 95/98/Me

                  c:\windows\hosts

    Windows NT/2000/XP Pro

                  c:\winnt\system32\drivers\etc\hosts

    Windows XP Home / Windows 7/ Windows Server 2008

                  c:\windows\system32\drivers\etc\hosts

     

    注意:

    Host是文件的名字而不是文件夹的名字. 这个文件没有扩展名(比如说.exe, .txt, .doc等等)

    如果你没有host文件, 你可以自己创建一个, 把它放到上面例举的文件夹中.

     

    注意:

    如果你发现你已经有了host文件, 我推荐你把它备份一个, 拷贝到另外的一个硬盘分区上, 这样你就可以恢复了.

    Host文件举例

    # 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

    127.0.0.1        alternative80

    http://accs-net.com/hosts/what_is_hosts.html

    http://accs-net.com/hosts/how_to_use_hosts.html

    http://en.wikipedia.org/wiki/Hosts_file

  • 相关阅读:
    英语apyrite红碧玺apyrite单词
    英语SouthRedAgate南红玛瑙
    英语kutnahorite金田黄kutnahorite单词
    英语chalchite蓝绿松石chalchite单词
    单词demantoite翠榴石demantoite英语
    英语fieldyellowstone田黄石fieldyellowstone单词
    Http通讯Util
    redis分布式锁工具类
    永不重复的id生成器
    二维码生成工具类
  • 原文地址:https://www.cnblogs.com/awpatp/p/1667442.html
Copyright © 2020-2023  润新知