Skip to contentSkip to conversation

ip.7: Add Special and Reserved IP Addresses section

PATCH RESEND Superseded Seth David Schoen 2 participants 2 messages Apr 13, 2023

Subsystems (3)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v4 1/1 ip.7: Add Special and Reserved IP Addresses section

Break out the discussion of special and reserved IPv4 addresses into a subsection, and briefly describe three cases in which Linux no longer treats addresses specially, where other systems do or did.

The divergences in Linux's behavior mentioned in this patch were introduced at

unicast 240/4 (since 2.6.25):
commit 1e637c74b0f84eaca02b914c0b8c6f67276e9697
Author: Jan Engelhardt <[email protected]>
Date: Mon Jan 21 03:18:08 2008 -0800

unicast 0/8 (since 5.3):
commit 96125bf9985a75db00496dd2bc9249b777d2b19b
Author: Dave Taht <[email protected]>
Date: Sat Jun 22 10:07:34 2019 -0700

unicast subnet lowest address (since 5.14):
commit 58fee5fc83658aaacf60246aeab738946a9ba516
Merge: 77091933e453 6101ca0384e3
Author: David S. Miller <[email protected]>
Date: Mon May 17 13:47:58 2021 -0700

---
 man7/ip.7 | 38 +++++++++++++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)
man7/ip.7 +35 -3
index f69af1b32..94de21979 100644
@@ -237,6 +237,7 @@ In particular, this means that you need to call
 on the number that is assigned to a port.
 All address/port manipulation
 functions in the standard library work in network byte order.
+.SS Special and reserved addresses
 .PP
 There are several special addresses:
 .B INADDR_LOOPBACK
@@ -244,12 +245,43 @@ There are several special addresses:
 always refers to the local host via the loopback device;
 .B INADDR_ANY
 (0.0.0.0)
-means any address for binding;
+means any address for socket binding;
 .B INADDR_BROADCAST
 (255.255.255.255)
-means any host and has the same effect on bind as
+has the same effect on socket binding as
 .B INADDR_ANY
-for historical reasons.
+for historical reasons. A packet addressed to
+.B INADDR_BROADCAST
+through a socket which has
+.B SO_BROADCAST
+set will be broadcast to all hosts on the local network segment, as
+long as the link is broadcast-capable.
+.PP
+On any locally-attached IP subnet with a link type that supports
+broadcasts, the highest-numbered address (e.g., the .255 address on a
+subnet with netmask 255.255.255.0) is designated as a broadcast address.
+This "broadcast address" cannot usefully be assigned to an interface, and
+can only be addressed with a socket on which the
+.B SO_BROADCAST
+option has been set.
+Internet standards have historically also reserved the lowest-numbered
+address (e.g., the .0 address on a subnet with netmask 255.255.255.0)
+for broadcast, though they call it "obsolete" for this purpose.  Since
+Linux 5.14, it is treated as an ordinary unicast address.
+.PP
+Internet standards have also traditionally reserved various addresses
+for particular uses, though Linux no longer treats some of these
+specially. Addresses in the ranges 0.0.0.1 through 0.255.255.255 and
+240.0.0.0 through 255.255.255.254 (0/8 and 240/4) are reserved globally.
+Since Linux 5.3 and Linux 2.6.245, respectively, the 0/8 and 240/4
+addresses are treated as ordinary unicast addresses. Systems that follow
+the traditional behaviors may not interoperate with these historically
+reserved addresses.
+.PP
+All addresses from 127.0.0.1 through 127.255.255.254
+are treated as loopback addresses akin to the standardized
+local loopback address 127.0.0.1, while addresses in 224.0.0.0 through
+239.255.255.255 (224/4) are dedicated to multicast use.
 .SS Socket options
 IP supports some protocol-specific socket options that can be set with
 .BR setsockopt (2)
Signature · 1 line
2.25.1
#1 lore raw

Hi Seth,

Quoted 45 lines · Seth David Schoen

Break out the discussion of special and reserved IPv4 addresses into a subsection, and briefly describe three cases in which Linux no longer treats addresses specially, where other systems do or did.

The divergences in Linux's behavior mentioned in this patch were introduced at

unicast 240/4 (since 2.6.25):
commit 1e637c74b0f84eaca02b914c0b8c6f67276e9697
Author: Jan Engelhardt <[email protected]>
Date: Mon Jan 21 03:18:08 2008 -0800

unicast 0/8 (since 5.3):
commit 96125bf9985a75db00496dd2bc9249b777d2b19b
Author: Dave Taht <[email protected]>
Date: Sat Jun 22 10:07:34 2019 -0700

unicast subnet lowest address (since 5.14):
commit 58fee5fc83658aaacf60246aeab738946a9ba516
Merge: 77091933e453 6101ca0384e3
Author: David S. Miller <[email protected]>
Date: Mon May 17 13:47:58 2021 -0700

---
 man7/ip.7 | 38 +++++++++++++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)
man7/ip.7 +1 -0
index f69af1b32..94de21979 100644
@@ -237,6 +237,7 @@ In particular, this means that you need to call
 on the number that is assigned to a port.
 All address/port manipulation
 functions in the standard library work in network byte order.
+.SS Special and reserved addresses
 .PP
 There are several special addresses:
 .B INADDR_LOOPBACK
@@ -244,12 +245,43 @@ There are several special addresses:
 always refers to the local host via the loopback device;
 .B INADDR_ANY

man7/ip.7 There are several special addresses: · line 253

Quoted 10 lines
man7/ip.7 +3 -3
 (0.0.0.0)
-means any address for binding;
+means any address for socket binding;
 .B INADDR_BROADCAST
 (255.255.255.255)
-means any host and has the same effect on bind as
+has the same effect on socket binding as
 .B INADDR_ANY
-for historical reasons.
+for historical reasons. A packet addressed to

Please use semantic newlines. See man-pages(7):

Use semantic newlines
In the source of a manual page, new sentences should be started on new lines, long sentences should be split into lines at clause breaks (commas, semicolons, colons, and so on), and long clauses should be split at phrase boundaries. This convention, sometimes known as "semantic newlines", makes it easier to see the effect of patches, which often operate at the level of in‐ dividual sentences, clauses, or phrases.

Quoted 21 lines
man7/ip.7 +21 -0
+.B INADDR_BROADCAST
+through a socket which has
+.B SO_BROADCAST
+set will be broadcast to all hosts on the local network segment, as
+long as the link is broadcast-capable.
+.PP
+On any locally-attached IP subnet with a link type that supports
+broadcasts, the highest-numbered address (e.g., the .255 address on a
+subnet with netmask 255.255.255.0) is designated as a broadcast address.
+This "broadcast address" cannot usefully be assigned to an interface, and
+can only be addressed with a socket on which the
+.B SO_BROADCAST
+option has been set.
+Internet standards have historically also reserved the lowest-numbered
+address (e.g., the .0 address on a subnet with netmask 255.255.255.0)
+for broadcast, though they call it "obsolete" for this purpose.  Since
+Linux 5.14, it is treated as an ordinary unicast address.
+.PP
+Internet standards have also traditionally reserved various addresses
+for particular uses, though Linux no longer treats some of these
+specially. Addresses in the ranges 0.0.0.1 through 0.255.255.255 and

man7/ip.7 There are several special addresses: · line 284

Quoted 10 lines
man7/ip.7 +10 -0
+240.0.0.0 through 255.255.255.254 (0/8 and 240/4) are reserved globally.
+Since Linux 5.3 and Linux 2.6.245, respectively, the 0/8 and 240/4
+addresses are treated as ordinary unicast addresses. Systems that follow
+the traditional behaviors may not interoperate with these historically
+reserved addresses.
+.PP
+All addresses from 127.0.0.1 through 127.255.255.254
+are treated as loopback addresses akin to the standardized
+local loopback address 127.0.0.1, while addresses in 224.0.0.0 through
+239.255.255.255 (224/4) are dedicated to multicast use.

Maybe it would be interesting to use tagged paragraphs (.TP), so that it's reasy to see at a first glance the reserved values? Something like:

Special and reserved addresses
INADDR_LOOPBACK
127.0.0.1
INADDR_LOOPBACK (127.0.0.1) always refers to the local host via the loopback device;

INADDR_ANY
0.0.0.0
INADDR_ANY (0.0.0.0) means any address for socket binding;

INADDR_BROADCAST
255.255.255.255
INADDR_BROADCAST (255.255.255.255) has the same effect on socket binding as INADDR_ANY for historical reasons. A packet addressed to INADDR_BROADCAST through a socket which has SO_BROADCAST set will be broadcast to all hosts on the local network segment, as long as the link is broadcast‐capable.

Highest-numbered address
Lowest-numbered address
On any locally‐attached IP subnet with a link type that supports broadcasts, the highest‐numbered address (e.g., the .255 address on a subnet with netmask 255.255.255.0) is designated as a broadcast address. This "broadcast address" cannot usefully be assigned to an interface, and can only be addressed with a socket on which the SO_BROADCAST option has been set. Internet standards have historically also reserved the lowest‐numbered ad‐ dress (e.g., the .0 address on a subnet with netmask 255.255.255.0) for broadcast, though they call it "obso‐ lete" for this purpose. Since Linux 5.14, it is treated as an ordinary unicast address.

Internet standards have also traditionally reserved vari‐ ous addresses for particular uses, though Linux no longer treats some of these specially.

[0.0.0.1, 0.255.255.255]
[240.0.0.0, 255.255.255.254]
Addresses in these ranges (0/8 and 240/4) are reserved globally. Since Linux 5.3 and Linux 2.6.245, respectively, the 0/8 and 240/4 addresses are treated as ordinary unicast addresses. Systems that follow the traditional behaviors may not interoperate with these historically reserved addresses.

[127.0.0.1, 127.255.255.254]
Addresses in this range are treated as loopback addresses akin to the standardized local loopback address 127.0.0.1.

[224.0.0.0, 239.255.255.255]
Addresses in this range (224/4) are dedicated to multicast use.

Cheers,
Alex

Quoted 3 lines
man7/ip.7 +0 -0
 .SS Socket options
 IP supports some protocol-specific socket options that can be set with
 .BR setsockopt (2)
Signature · 2 lines
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5