sudo:無法解析主機 server1.yourdomain.com:資源暫時無法使用

sudo:無法解析主機 server1.yourdomain.com:資源暫時無法使用

作業系統:Ubuntu 18.0.4

我用這個指令安裝 Squid:

sudo apt-get install squid

安裝後我對squid.conf做了一些小改動,只需將這個http_access拒絕所有更改為http_access允許所有

保存更改後我運行此命令

sudo service squid restart

但我收到此錯誤:

sudo: unable to resolve host server1.yourdomain.com: Resource temporarily unavailable

我檢查我的主機文件,我看到這樣的文字:

127.0.0.1   localhost
127.0.1.1   ubuntu

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

我檢查我的主機名稱文件,看到以下文字:

server1.yourdomain.com

我將此文字更改為 ubuntu

更改後我再次運行此命令:

sudo service squid restart

and this command

sudo service squid stop

但我再次收到此錯誤:

sudo: unable to resolve host server1.yourdomain.com: Resource temporarily unavailable

並測試這個指令:

sudo service squid reload
sudo: unable to resolve host server1.yourdomain.com: Resource temporarily unavailable
squid.service is not active, cannot reload.

我檢查 ping ip ,得到良好的 ping

如何解決這個問題?

答案1

您的電腦嘗試解析 server1.yourdomain.com 但失敗。

dns 解析的第一步是實例在檢查下一個 dns 伺服器之前先尋找自己的 /etc/hosts 檔案。

只需編輯伺服器的 /etc/hosts 檔案並將此行:更改127.0.0.1 localhost為:

127.0.0.1 localhost server1.yourdomain.com

然後重啟squid服務:

service squid restart

相關內容