localhost vs 127.0.0.1 vs 0.0.0.0 vs 本机ip

localhost

localhost是 127.0.0.1的域名访问,规则在/etc/hosts

127.0.0.1

127...* are the loopback IP addresses for most modern operating systems
and these IP addresses can be used to refer to our own computer.

0.0.0.0 vs 127.0.0.1

实际测试为 如果程序发布在127.0.0.1 局域网内是访问不到的。除非你绑定到0.0.0.0。
0.0.0.0, in this context, means "all IP addresses on the local machine" (in fact probably, "all IPv4 addresses on the local machine"). So, if your webserver machine has two ip addresses, 192.168.1.1 and 10.1.2.1, and you allow a webserver daemon like apache to listen on 0.0.0.0, it will be reachable at both of those IPs. But only to what can contact those IPs and the web port(s).

本机ip

是针对外网而言的。

ps

https://serverfault.com/questions/78048/whats-the-difference-between-ip-address-0-0-0-0-and-127-0-0-1
https://www.howtogeek.com/225487/what-is-the-difference-between-127.0.0.1-and-0.0.0.0/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容