1. 程式人生 > >《Linux學習並不難》Linux網絡配置文件(3):/etc/hosts文件

《Linux學習並不難》Linux網絡配置文件(3):/etc/hosts文件

Linux /etc/hosts

26.3 《Linux學習並不難》Linux網絡配置文件(3):/etc/hosts文件


當計算機啟動時,在可以查詢DNS以前,計算機需要查詢一些主機名到IP地址的匹配。這些匹配信息存放在/etc/hosts文件中。在沒有域名服務器的情況下,系統上的所有網絡程序都通過查詢該文件來解析對應於某個主機名的IP地址。
下面是/etc/hosts文件內容的示例。

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 
192.168.0.2      rhel.test.com     rhel  
//最左邊一列是計算機IP地址,中間一列是主機名,最右面的列都是該主機的別名



本文節選自Linux學習並不難》教材,這是一本最實用的、理論實踐並重的Linux入門教材。如需閱覽整本書的內容請訪問Linux運維者www.linuxywz.com)網站



《Linux學習並不難》Linux網絡配置文件(3):/etc/hosts文件