路径与格式
路径与格式
# Linux/macOS: /etc/hosts
# Windows: C:\Windows\System32\drivers\etc\hosts
# 格式: IP 域名 [别名...]
203.0.113.10 app.example.com app
127.0.0.1 blocked.example.com验证命中
验证命中
getent hosts app.example.com
dig +short app.example.com # 不读 hosts:拿到的仍是 DNS 结果hosts 改错会让「只有本机解析异常」,且 dig 正常容易误判为应用问题;排查看 getent 与 hosts 文件。