localhost

特殊的DNS主機名

在計算機網路中,localhost(意為“本地主機”,指“這台計算機”)是給迴路網路介面(loopback)的一個標準主機名,相對應的IP地址為127.0.0.1(IPv4)和[::1](IPv6)。

問題解決


這個名稱也是一個保留域名(RFC 2606) ,為了避免同狹義定義主機名混淆而單獨列出。
在可用其他方式使用計算機主機名稱的地方,可以指定主機為localhost。例如,將web伺服器上安裝的web瀏覽器指向http://localhost,將會顯示運行這個瀏覽器的計算機上所服務的網站的主頁,但是只有當web伺服器配置至服務迴路介面時才能顯示。
一個特殊的DNS主機名,代表分配給引用這個名稱的計算機的IP地址。把這個名稱看作是提供快速但是不可靠服務的無連接協議。
localhost 指你所在的計算機本身。
在windows系統它成了127.0.0.1的別名,在Unix系統下,查看網卡配置會發現作為本地迴環的方式,一定程序上使用localhost比127.0.0.1要快一些。
重要重申localhost和IIS,IE,windows無關,他就是指你使用的計算機本身。
在Hosts文件中 localhost指向的IP是127.0.0.1這個關係是可以修改的。
windows修改localhost指向。

設置


windows中設置

兩種方法找到localhost設置:
1、運行 drivers 打開etc文件下hosts 就看到了127.0.0.1 localhost
2、打開C:\WINDOWS\system32\drivers\etc\hosts文件,此文件可以用記事本打開打開如下:
# Copyright (c) 1993-1999 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 (這裡不讓顯示) # source server
# 38.25.63.10 (這裡不讓顯示) # x client host
127.0.0.1localhost
最下面的:127.0.0.1localhost,這兩個參數你可以隨意改。格式是IP空格域名。

linux中設置

在Linux系統中,系統管理員在為用戶建立新帳號時賦給用戶一個用戶名和一個初始的口令。另外,Linux系統給計算機賦予一個主機名。主機名用於在網路上識別獨立的計算機(即使用戶的計算機沒有聯網,也應該有一個主機名)。TurboLinux系統給出的預設主機名為:localhost。
Linux系統成功啟動后,屏幕會提示:localhost login ,意思就是系統要求輸入用戶名,接著要求輸入口令。否則將無法登錄系統,也就無法使用。