localhost
:一种特殊的域名,默认通过本地 hosts
文件解析到本地 IP 127.0.0.1
127.0.0.1
:一种本地保留的私有 IP,本质是绑定在虚拟网卡(loopback)的环回地址
环回地址:环回地址是主机用于向自身发送通信的一个特殊地址
localhost
和 127.0.0.1
的区别:
Localhost | 127.0.0.1 |
---|---|
In localhost, we need a lookup table. | There is no need of a lookup table. |
The conversion of localhost into IP address requires a look up table. | The address 127.0.0.1 can be converted into an IP address directly with the help of intelligent software. In this, there is no need to do look up table at all. |
The localhost is easy to remember. | It is hard to remember the IP address 127.0.0.1. |
It is user-friendly in the sense that all you need to type is "http://localhost" in the address bar of your browser. | One needs to type "http://127.0.0.1" in the address bar of the browser, which is comparatively a little difficult to remember. |
The localhost is slower as compared to 127.0.0.1. | The IP address 127.0.0.1 is faster |
localhost和127.0.0.1的区别是localhost 不经过网卡?错误,二者都会走网卡
127.0.0.1 和 127.1 的关系:127.1 会自动补全成 127.0.0.1
参考:
Difference between localhost and 127.0.0.1?
localhost和127.0.0.1的区别