差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:linux_hostname [2008/06/26 09:38] jonathantech:linux_hostname [2019/10/24 09:27] (目前版本) jonathan_tsai
行 1: 行 1:
 +====== Linux (Redhat / Fedora / CentOS) 更改 hostname 的方式 ======
  
 +發現更改主機的 hostname 的方式都改不太完整. 以下是試出來比較完整的方式:
 +
 +=== Step 00: ===
 +  * 假設原本 hostname 為 tryboxap2, 現在想要更改為 tryboxap03
 +  * 使用 root 才可以更改 hostname
 +<code>
 +su - root
 +</code>
 +
 +=== Step 01: ===
 +  * 將 /etc/hosts 內出現的 tryboxap2 都改成 tryboxap03
 +<code |h vi /etc/hosts>
 +127.0.0.1 tryboxap03 localhost.localdomain localhost
 +</code>
 +
 +=== Step 02: ===
 +  * 將 /etc/sysconfig/network 內的 HOSTNAME 改成 tryboxap03
 +
 +<code |h vi /etc/sysconfig/network>
 +NETWORKING=yes
 +HOSTNAME=tryboxap03
 +GATEWAY=61.67.71.126
 +</code>
 +
 +=== Step 03: ===
 +  * 再使用 hostname 命令指定一次
 +<code>
 +hostname tryboxap03
 +</code>
 +
 +
 +===== =====
 +  * 這時就已經設定完成. 可以使用 hostname 命令去確認一次
 +<code>
 +[root@tryboxap2 etc]# hostname
 +tryboxap03
 +[root@tryboxap2 etc]#
 +</code>
 +
 +只要重新登入, 命令提示字串就會改成 [root@tryboxap03 etc]#
 +
 +<note>
 +  * **如果有系統有設定自動寄出信件, 必須要重新啟動 sendmail 否則會出現 relay deny 的狀況**
 +  * 如果要當郵件主機, hostname 就要符合 FQDN Exp. tryboxap03.ichiayi.com 所以 /etc/hosts 內要改成<code |h vi /etc/hosts>
 +127.0.0.1 tryboxap03.ichiayi.com tryboxap03 localhost.localdomain localhost
 +</code>
 +  * CentOS7 如果以上三步驟還無法改成功, 就需要在 /etc/hostname 這檔案內加入 hostname Exp. tryboxap03 或 tryboxap03.ichiayi.com <code |h vi /etc/hostname>
 +tryboxap03.ichiayi.com
 +</code>
 +</note>
 +
 +{{tag>linux hostname sendmail mail 密技}}
 +
 +<html><a href="https://www.everplast.com.tw/">Everplast –
 +Your Reliable Extruder Machine Partner
 +We Design We Care</a></html>
 +
 +<html><a href="http://www.diamonds2cash.com/diamond-buyer/">diamond buyers</a></html>