[Others] 修改/etc/hosts文件不生效
Tofloor
poster avatar
hyw520110
deepin
2022-03-18 19:16
Author

cat /etc/hosts

127.0.0.1 localhost
127.0.1.1 sky-PC

199.232.28.133 raw.githubusercontent.com
199.232.68.133 gist.githubusercontent.com
199.232.28.133 cloud.githubusercontent.com
199.232.28.133 camo.githubusercontent.com
199.232.28.133 avatars0.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
199.232.68.133 avatars3.githubusercontent.com
199.232.68.133 avatars4.githubusercontent.com
199.232.68.133 avatars5.githubusercontent.com
199.232.68.133 avatars6.githubusercontent.com
199.232.68.133 avatars7.githubusercontent.com
199.232.68.133 avatars8.githubusercontent.com

10.1.100.100 redis-server

执行命令:

ping redis-server

ping: redis-server: 未知的名称或服务

确认过文件格式为unix;

确认空格回车符没问题,

操作系统重启过均无效

Reply Favorite View the author
All Replies
deepin-superuser
deepin
2022-03-18 19:22
#1

注销或重启一下试试?

Reply View the author
liwl
deepin
2022-03-18 20:08
#2

这个不用怀疑,肯定是那里写错了

Reply View the author
hyw520110
deepin
2022-03-18 20:51
#3
deepin-superuser

注销或重启一下试试?

试过无效

Reply View the author
hyw520110
deepin
2022-03-18 21:14
#4

通过utools的hosts插件写入hosts有问题,之前可以的,手动写入也没有问题

Reply View the author
fymumu
deepin
2022-03-18 21:53
#5

难道不是写成类似我这样的,192.168.33.110 master master.centos.com,,,,你这个中间少了个名字

Reply View the author
mjw1127
deepin
2022-03-18 22:52
#6

图片.png

没有出现楼主图中的报错

Reply View the author
云的眼泪
deepin
2022-03-18 23:19
#7

不能超过8个字符?

Reply View the author
waiting
deepin
2022-03-19 00:08
#8
  1. 使用 dig 命令排查域名解析
  2. 删除 hosts 中除了 localhost 的其它记录,然后仅添加 10.1.100.100 redis-server
Reply View the author
deepinuser17
deepin
2022-03-19 08:23
#9

查看一下/etc/hosts文件里是否有隐藏的非字体符号。

在vim打开文件以后, 输入:set list 回车。

编辑Linux文本文件时,千万不能用WPS之类文字处理器。 要用vim, nano, 深度编辑器。

另外查看一下该文件的权限。

ls -lh /etc/hosts*

Reply View the author
joo
deepin
2022-03-19 19:34
#10

你先 ping 10.1.100.100,估计你网络访问不了这个ip,跟hosts没关系

Reply View the author
joo
deepin
2022-03-19 19:45
#11

你直接将

cat /etc/hosts

显示的内容以图片贴出来,你肯定有些内容格式不对,你的hosts文件已修改过,比如默认的hosts文件会有ipv6的localhost,但从你的内容没见到

Reply View the author
hyw520110
deepin
2022-03-20 02:21
#12
hyw520110

通过utools的hosts插件写入hosts有问题,之前可以的,手动写入也没有问题

问题已查到是utools的hosts插件写入问题(之前没问题的)手动写入一行是没问题的,查看文件格式为unix,查看回车换行符都正常

image.png

Reply View the author