歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Ubuntu中如何更改主機名

Ubuntu中如何更改主機名

日期:2017/3/3 15:57:15   编辑:關於Linux

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

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

URL:http://www.bianceng.cn/OS/Linux/201410/46056.htm

Copyright © Linux教程網 All Rights Reserved