如何在不同的操作系统上安装HOSTS文件?

请提供如何在各种操作系统的客户端和服务器版本上设置的示例。

在Linux / Unix上的主机文件:

/etc/hosts ip.nu.mb.er name1 name2 

在Windows上托pipe文件:

 %WINDOWS%\System32\Drivers\etc\hosts (eg C:\Windows\System32\Drivers\etc\hosts) ip.nu.mb.er name1 name2 

假设你问如何find文件(它很可能已经存在):

  • 在类Unix操作系统(包括Mac OS X和Linux)中,通常会在/etc/hostsfindhosts文件。 请注意,Mac OS X默认情况下不显示您的etc目录。 你可以用不同的方式显示它,例如在Finder中selectGo→Go to Folder … ,然后input/etc
  • 在基于NT的操作系统(包括Windows XP和Windows Vista)中, etc目录稍微隐藏在%WINDIR%\system32\drivers\ ,例如C:\WINDOWS\system32\drivers\etc\hosts