
我正在設定一個 Postfix 郵件伺服器,主機名稱“letters”,來處理網域“example.net”的郵件。我嘗試使用 nis 將字母的網域設定為 example.net,但主機名稱 -f ('letters.stuff.comcast.net') 和網域名稱 ('example.net') 的輸出不一致,我該怎麼辦設定網域以便hostname -f 指令報告「example.net」?這對於正確的 Postfix 功能到底有多重要?
主機字母運行 Ubuntu,並透過 openwrt 路由器透過電纜數據機連接到 Comcast 的互聯網。網域 example.net 的名稱伺服器位於遠端 Debian 電腦上,該電腦尚未配置為建立字母的主機或別名。
我認為主機名稱輸出中的域名反映了盒子的 dhcp 用戶端從 comcast 伺服器獲取的域名,並反映了盒子是該網路上的客戶端的想法。解決方案是在 example.net 的名稱伺服器上建立「字母」主機嗎?這是否還需要將該名稱伺服器新增至信件的 resolv.conf 檔案中列出的名稱伺服器中?
答案1
確保您/etc/hosts
(或 NIS)條目正確。
我本來想嘗試解釋一下,但線上幫助頁更好地講述了這個故事:
THE FQDN
You can't change the FQDN (as returned by hostname --fqdn) or the DNS
domain name (as returned by dnsdomainname) with this command. The FQDN
of the system is the name that the resolver(3) returns for the host
name.
[..]
Therefore it depends on the configuration (usually in /etc/host.conf)
how you can change it. Usually (if the hosts file is parsed before DNS
or NIS) you can change it in /etc/hosts.
答案2
我昨天在處理其他人啟動的伺服器刷新時遇到了這個問題...主機名稱 -f 輸出從未有正確的結束網域(缺少 .org)。
# hostname foobar.example.org
# hostname -f
foobar.example
#
# cat /etc/hosts
10.20.11.244 foobar.example foobar
解決方案:
主機名稱 -f 的網域部分似乎來自該主機的 /etc/hosts 條目。在我修復 /etc/hosts 中的主機名稱後,hostname -f 傳回正確的網域:
# hostname foobar
# hostname
foobar
# hostname -f
foobar.example.org
YMMV。
答案3
如果您的 IP 不是靜態的,則該方法/etc/hosts
將不適用於您(或僅暫時有效,直到您獲得新的 IP)。我不確定這是否有效,但可以嘗試以下方法:
- 將 dhcp 用戶端設定為不向 dhcp 伺服器要求網域名稱。或者只是告訴它根本不要碰 resolv.conf,如果您有自訂名稱伺服器,您可能已經這樣做了。
- 將您的網域設定為 example.net
/etc/resolv.conf
- 確保您的名稱伺服器可以解析
letters.example.net
,我想您將需要使用某種動態 dns 服務,因為此解決方案適用於非靜態 IP。
這可能意味著我對你問題的回答很簡單:「是」。
答案4
這是「網域」的常見誤解問題。這是我的 Mac OS X 系統上的手冊頁頂部,但您的系統也類似:
DOMAINNAME(1) BSD General Commands Manual DOMAINNAME(1)
NAME
domainname -- set or print the name of the current NIS domain
該指令不用於DNS配置!