MacOS 使用SwitchHosts修改 hosts 不生效的原因及解决方法
SwitchHosts
Switch hosts quickly!
项目地址:https://gitcode.com/gh_mirrors/sw/SwitchHosts
·
MacOS 使用SwitchHosts修改 hosts 不生效的原因及解决方法

使用switch host修改mac hosts后,cat 发现hosts已经修改成功。

但是ping的时候发现,域名解析的ip还是老的。
翻了很多资料,在windows下并没有这种情况。
最后在stackoverflow上发现如下咨询:
This is because macOS Catalina has another thing going; it will only make changes in the hosts file effective if you change them as the root user !!
我的系统是

也就是说,mac下默认不是root用户的修改,可能不会立刻起效。
这也就解释了,为什么hosts修改成功了,但是本地dns还是读取的老的IP。

可以看到hosts文件的修改权限是本地用户。
所以解决方法也就有两种了。
1.执行sudo killall mDNSResponder,手动刷新本地dns缓存。
2.使用sudo vim hosts命令修改hosts文件。
Switch hosts quickly!
最近提交(Master分支:4 个月前 )
68fa4c5b
Bump react-router and react-router-dom 10 天前
a3356b32
Bumps [react-router](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router) to 7.12.0 and updates ancestor dependency [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom). These dependencies need to be updated together.
Updates `react-router` from 7.5.2 to 7.12.0
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router@7.12.0/packages/react-router)
Updates `react-router-dom` from 7.5.2 to 7.12.0
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router-dom@7.12.0/packages/react-router-dom)
---
updated-dependencies:
- dependency-name: react-router
dependency-version: 7.12.0
dependency-type: indirect
- dependency-name: react-router-dom
dependency-version: 7.12.0
dependency-type: direct:development
...
Signed-off-by: dependabot[bot] <support@github.com> 10 天前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)