Why don't we have a usable IP address in 127.0.0.0?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Peaceful Mind
--
Chapters
00:00 Why Don'T We Have A Usable Ip Address In 127.0.0.0?
00:34 Answer 1 Score 34
01:50 Accepted Answer Score 4
02:42 Answer 3 Score 2
03:45 Answer 4 Score 1
04:12 Thank you
--
Full question
https://superuser.com/questions/1725375/...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#networking #ip #tcp #tcpip
#avk47
ANSWER 1
Score 34
In IPv4, the first address of a subnet is reserved for...unclear reasons, really, but most likely because very long ago it used to be the "broadcast" address. (Later, the last address became the standard broadcast address.)
So nowadays it might be possible to use the first address, technically, but most existing network stacks still treat it as "reserved" (kind of like how the entire ex-"Class E" 240.0.0.0/4 space became accidentally unusable).
Note that it's specifically the first address of a subnet, and not always the 0
address. Those only match up in the case of a /24 subnet. But for example, a /16 subnet will have .0.0
reserved, but not .1.0
or .47.0
– those are in the middle of the /16 so they're perfectly valid host addresses.
(And on the other hand, a smaller /27 subnet could start not only at .0
but also at .32
or .192
– those would again be reserved in a /27, even if they're not reserved in a /24.)
Also note that this only applies to broadcast subnets (e.g. ethernet). Such addresses can still be used in point-to-point links or routed individually as /32's.
ACCEPTED ANSWER
Score 4
But why is 0 not used in any IP addresses in their 4th part and they always start from 1 in IP addresses calculations?
With respect to the title of your question, at least under Linux, 127.0.0.0
is a perfectly useful address (that like any other 127.*
address maps to the loopback interface).
For example, I can start a webserver on 127.0.0.0:8080
:
docker run -d --rm --hostname node1 --name node1 -p 127.0.0.0:8080:8080 alpine \
sh -c "apk add --update darkhttpd; mkdir /srv; hostname > /srv/index.html; darkhttpd /srv --port 8080"
And then start another one bound to 127.0.0.1:8080
:
docker run -d --rm --hostname node2 --name node2 -p 127.0.0.1:8080:8080 alpine \
sh -c "apk add --update darkhttpd; mkdir /srv; hostname > /srv/index.html; darkhttpd /srv --port 8080"
And now now I can access those servers on their respective addresses:
$ curl 127.0.0.0:8080
node1
$ curl 127.0.0.1:8080
node2
ANSWER 3
Score 2
Many decades ago the 127.0.0.0/8 address was designated as a internal loopback address. Only suitable for local traffic with the local PC.
Since the decision was made years ago, every router manufacturer every has designated this address as non-routable. Many old routers it maybe hard coded and not removable. Some would require new firmware, and the manufacturer has designated them end of line so they won't ever get new firmware. This would require many hundreds if not thousand of routers to be replaced. Some do exist that you could reprogram.
Therefore every single router on the internet will discard any traffic destine for the 127.0.0.0/8 address. The traffic will never make it through the internet due to this.
Literally tens of thousand of routers would have to be reprogrammed to allow this address to be routed. A single non-compliant router between you and your destination and the packet will never reach you.
Even if the change was made now, it would take years before packets would make it through reliably.
ANSWER 4
Score 1
In IPv4, whatever IP ends in .0 means it's a (default) network address when you use the prefix /24. You cannot use this address and assign it to a computer. The 'allowed' IPs to assign is from .1 to .254. You also can't use .255 because it is used as the 'broadcast' address for the network.