Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
998 views
in Technique[技术] by (71.8m points)

localhost - 127.x.y.z but not 127.0.0.0?

I was looking around on this question, when I found this comment.

My home is 127.1.2.3, ha! In fact everything that starts with "127." resolves to the local host. – TToni Jan 27 '11 at 23:30

I tried this by going to http://127.1.2.3 and http://127.174.199.127 and other random URLs that all lead to http://localhost

Except for one of them: http://127.0.0.0

After waiting some time I get

This site can’t be reached

127.0.0.0 took too long to respond.

Error Code: ERR_CONNECTION_TIMED_OUT

What is special about http://127.0.0.0 that it can't be reached?


Another thing: something similar occurs with http://127.255.255.255

This site can’t be reached

The webpage at http://127.255.255.255/ might be temporarily down or it may have moved permanently to a new web address.

Error Code: ERR_ADDRESS_INVALID

Note: this happens immediately, meaning no waiting for about 10-15 seconds

question from:https://stackoverflow.com/questions/65925026/127-x-y-z-but-not-127-0-0-0

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As with a lot of things IP related, 127.0.0.0 is the "network" address, so no host should claim it.

The subnet is defined as 127.0.0.0/8 or 127.0.0.0 with a netmask of 255.0.0.0 which means the network address is 127.0.0.0 and the broadcast address is 127.255.255.255, both of which are reserved.

For any given subnet, the first address is considered the network, the last the broadcast. The remainder is the host addresses.

For smaller subnets, like /24 (255.255.255.0) the range is proportionately smaller, and for some like a /29 smaller still. Any smaller is just silly as you end up with nothing more than a network and broadcast address, it's not a usable subnet.

Note: /32 isn't a subnet, it's only used as a way of saying "host address" for things like firewall rules.

Many IP stacks respond to any valid 127.0.0.0/8 address, not just 127.0.0.1, but they will not respond to the network address.

In other words, the valid IP range is 127.0.0.1 through 127.255.255.254 for host addresses.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...