エイリアスに関する質問がありますlocalhost
。これはうまくいきません。デフォルトでは、どのプログラムもlocalhost
この問題を解決できません127.0.0.1
。エイリアスは次の場所にあります/etc/hosts
。
[root@gabriel-notebook gpoesia]# cat /etc/hosts
#
# /etc/hosts: static lookup table for host names
#
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost gabriel-notebook
::1 localhost ip6-localhost ip6-loopback
# End of file
また、以下myhostname
で有効にします/etc/nsswitch.conf
。
[root@gabriel-notebook gpoesia]# cat /etc/nsswitch.conf
# Begin /etc/nsswitch.conf
passwd: compat mymachines systemd
group: compat mymachines systemd
shadow: compat
publickey: files
hosts: files mymachines resolve [!UNAVAIL=return] dns myhostname
networks: files
protocols: files
services: files
ethers: files
rpc: files
netgroup: files
# End /etc/nsswitch.conf
getent hosts
そしてlocalhostも/etc/hostname
設定されています。
[root@gabriel-notebook gpoesia]# getent hosts
127.0.0.1 localhost.localdomain localhost gabriel-notebook
127.0.0.1 localhost ip6-localhost ip6-loopback
[root@gabriel-notebook gpoesia]# getent hosts gabriel-notebook
127.0.0.1 localhost.localdomain localhost gabriel-notebook
[root@gabriel-notebook gpoesia]# cat /etc/hostname
gabriel-notebook
[root@gabriel-notebook gpoesia]# hostname
gabriel-notebook
しかし、ping localhost
動作しません。
[root@gabriel-notebook gpoesia]# ping localhost
ping: localhost: Name or service not known
最大の困難は、いつこのようなことが起こり始めたのかわからないということです。以前は働いていた思い出がありますが、故障した原因が何なのかわかりません。インターネット検索は役に立ちませんでした。私には理解できない理由(たとえば、破損したファイル、構文エラー/etc/hostname
など)と同じ問題を抱えている他の人が見つかりました。
どんなアイデアがありますか?
ありがとうございます!
ベストアンサー1
原因が見つかりました。/etc/hosts
ファイル権限が正しくありません。
に変わりました644
。