localhost vs 127.0.0.1 vs 0.0.0.0 vs 本機(jī)ip

localhost

localhost是 127.0.0.1的域名訪問,規(guī)則在/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

實際測試為 如果程序發(fā)布在127.0.0.1 局域網(wǎng)內(nèi)是訪問不到的。除非你綁定到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).

本機(jī)ip

是針對外網(wǎng)而言的。

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/

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容