顯示頁面舊版反向連結Fold/unfold all回到頁頂 本頁是唯讀的,您可以看到原始碼,但不能更動它。您如果覺得它不應被鎖上,請詢問管理員。 ====== 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> tech/linux_hostname.txt 上一次變更: 2019/10/24 01:27由 jonathan_tsai