我读了很多关于这个问题的帖子,但都没什么用。我不明白我做错了什么。一切正常,但我收到此错误/警告消息:sudo: unable to resolve host serverlaptop: Name or service not known
server@serverlaptop:~$ hostname
serverlaptop
server@serverlaptop:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 server_laptop
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
server@serverlaptop:~$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 8.8.8.8
options edns0 trust-ad
server@serverlaptop:~$ ifconfig
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.100.5 netmask 255.255.255.0 broadcast 192.168.100.255
inet6 fe80::26b6:fdff:fe17:d9bf prefixlen 64 scopeid 0x20<link>
inet6 2a01:36d:600:6fe5:26b6:fdff:fe17:d9bf prefixlen 64 scopeid 0x0<global>
ether 24:b6:fd:17:d9:bf txqueuelen 1000 (Ethernet)
RX packets 11111647 bytes 12011580399 (12.0 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3443145 bytes 465936458 (465.9 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我甚至运行了这个命令,hostnamectl set-hostname server_laptop
可能是我没有卸载一些docker的东西?因为我安装了docker和pihole,然后我卸载了它们。
答案1
好吧,我会对着枕头尖叫,直到我死去。所以我找到了问题所在。当我通过 ssh 工作时,主机名是,server_laptop
但当我在裸机上工作时,主机名是serverlaptop
。
非常抱歉,我真是个笨蛋,浪费了你们的时间和精力。我真的很抱歉。再次感谢你们的帮助,对不起,我是个笨蛋。