天天看點

Ubuntu更改主機名

 Ubuntu更改主機名跟RedHat不一樣,有兩處需要修改,小記一下,以免以後忘掉

首先編輯 /etc/hosts檔案,這個跟RedHat一樣,不過略有不同

root@node1:~# cat /etc/hosts 

#127.0.0.1      localhost 

127.0.1.1       node1.ttpod.com 

192.168.0.2     node1.ttpod.com 

192.168.0.128   node2.ttpod.com 

# The following lines are desirable for IPv6 capable hosts 

::1     ip6-localhost ip6-loopback 

fe00::0 ip6-localnet 

ff00::0 ip6-mcastprefix 

ff02::1 ip6-allnodes 

ff02::2 ip6-allrouters 

RedHat可以在主機名後跟一個短的名稱,Ubuntu不可以。

第二處要改的地方是/etc/hostname

root@node1:~# cat /etc/hostname 

node1.ttpod.com 

裡面的内容很簡單,就一個主機名。

本文轉自 gm100861 51CTO部落格,原文連結:http://blog.51cto.com/gm100861/903852

繼續閱讀