关于mac 配置hosts无效的解决方案

323 阅读1分钟

1、首先命令行查看hosts文件

sudo vim /etc/hosts

如果里面没有你配置的内容话,则表示hosts文件无效了

2、恢复系统默认的hosts文件

步骤如下:

1、打开一个终端命令窗口

2、输入下面的命令并按回车键,按照提示输入管理员密码,输入过程中光标不会移动,输入完成后回车确认即可

sudo -s

3、输入如下命令并回车

cat <<EOF > /etc/hosts
**##**
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
EOF

4、回车后继续执行

sudo chown root:wheel /etc/hosts; sudo chmod 644 /etc/hosts

3、使用工具来配置Hosts

不推荐直接在hosts 文件中进行修改,我就是这样改出问题来的

  • 1、安装switchhosts
  • 2、新建一个hosts
  • 3、切换开关来配置不同的hosts配置项