xref: /freebsd/share/man/man4/inet.4 (revision edf8578117e8844e02c0121147f45e4609b30680)
1.\" Copyright (c) 1983, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     From: @(#)inet.4	8.1 (Berkeley) 6/5/93
29.\"
30.Dd September 8, 2022
31.Dt INET 4
32.Os
33.Sh NAME
34.Nm inet
35.Nd Internet protocol family
36.Sh SYNOPSIS
37.In sys/types.h
38.In netinet/in.h
39.Sh DESCRIPTION
40The Internet protocol family is a collection of protocols
41layered atop the
42.Em Internet Protocol
43.Pq Tn IP
44transport layer, and utilizing the Internet address format.
45The Internet family provides protocol support for the
46.Dv SOCK_STREAM , SOCK_DGRAM ,
47and
48.Dv SOCK_RAW
49socket types; the
50.Dv SOCK_RAW
51interface provides access to the
52.Tn IP
53protocol.
54.Sh ADDRESSING
55Internet addresses are four byte quantities, stored in
56network standard format (on little endian machines, such as the
57.Tn alpha ,
58.Tn amd64
59and
60.Tn i386
61these are word and byte reversed).
62The include file
63.In netinet/in.h
64defines this address
65as a discriminated union.
66.Pp
67Sockets bound to the Internet protocol family utilize
68the following addressing structure,
69.Bd -literal -offset indent
70struct sockaddr_in {
71	uint8_t		sin_len;
72	sa_family_t	sin_family;
73	in_port_t	sin_port;
74	struct in_addr	sin_addr;
75	char		sin_zero[8];
76};
77.Ed
78.Pp
79Sockets may be created with the local address
80.Dv INADDR_ANY
81to affect
82.Dq wildcard
83matching on incoming messages.
84The address in a
85.Xr connect 2
86or
87.Xr sendto 2
88call may be given as
89.Dv INADDR_ANY
90to mean
91.Dq this host .
92The distinguished address
93.Dv INADDR_BROADCAST
94is allowed as a shorthand for the broadcast address on the primary
95network if the first network configured supports broadcast.
96.Sh PROTOCOLS
97The Internet protocol family is comprised of
98the
99.Tn IP
100network protocol, Internet Control
101Message Protocol
102.Pq Tn ICMP ,
103Internet Group Management Protocol
104.Pq Tn IGMP ,
105Transmission Control
106Protocol
107.Pq Tn TCP ,
108and User Datagram Protocol
109.Pq Tn UDP .
110.Tn TCP
111is used to support the
112.Dv SOCK_STREAM
113abstraction while
114.Tn UDP
115is used to support the
116.Dv SOCK_DGRAM
117abstraction.
118A raw interface to
119.Tn IP
120is available
121by creating an Internet socket of type
122.Dv SOCK_RAW .
123The
124.Tn ICMP
125message protocol is accessible from a raw socket.
126.Pp
127The
128.Nm
129address on an interface consist of the address itself, the
130netmask, either broadcast address in case of a broadcast
131interface or peers address in case of point-to-point interface.
132The following
133.Xr ioctl 2
134commands are provided for a datagram socket in the Internet domain:
135.Pp
136.Bl -tag -width ".Dv SIOCGIFBRDADDR" -offset indent -compact
137.It Dv SIOCAIFADDR
138Add address to an interface.
139The command requires
140.Ft struct in_aliasreq
141as argument.
142.It Dv SIOCDIFADDR
143Delete address from an interface.
144The command requires
145.Ft struct ifreq
146as argument.
147.It Dv SIOCGIFADDR
148.It Dv SIOCGIFBRDADDR
149.It Dv SIOCGIFDSTADDR
150.It Dv SIOCGIFNETMASK
151Return address information from interface.
152The returned value is in
153.Ft struct ifreq .
154This way of address information retrieval is obsoleted, a
155preferred way is to use
156.Xr getifaddrs 3
157API.
158.El
159.Ss MIB (sysctl) Variables
160In addition to the variables supported by the transport protocols in
161.Va net.inet
162(for which the respective manual pages may be consulted),
163there are a number of general variables implemented in the
164.Va net.inet.ip
165branch of the
166.Xr sysctl 3
167MIB, which can be also read or modified with
168.Xr sysctl 8 .
169The following general variables are defined:
170.Bl -tag -width ".Va accept_sourceroute"
171.It Va accept_sourceroute
172Boolean: enable/disable accepting of source-routed IP packets (default false).
173.It Va allow_net0
174Boolean: allow experimental use of addresses in 0.0.0.0/8 as endpoints,
175and allow forwarding of packets with these addresses.
176.It Va allow_net240
177Boolean: allow experimental use of addresses in 240.0.0.0/4 as endpoints,
178and allow forwarding of packets with these addresses.
179.It Va curfrags
180Integer: Current number of IPv4 fragments across all reassembly queues
181in all VNETs (read-only).
182.It Va forwarding
183Boolean: enable/disable forwarding of IP packets.
184Defaults to off.
185.It Va fragpackets
186Integer: Current number of IPv4 fragment reassembly queue entries
187for the VNET (read-only).
188.It Va fragttl
189Integer: time to live for IPv4 packet fragments in the per-VNET reassemby queue.
190.It Va loopback_prefixlen
191Integer: prefix length of the address space reserved for loopback purposes.
192The default is 8, meaning that 127.0.0.0/8 is reserved for loopback,
193and cannot be sent, received, or forwarded on a non-loopback interface.
194Use of other values is experimental.
195.It Va maxfragbucketsize
196Integer: maximum number of reassembly queues per bucket.
197Fragmented packets are hashed to buckets.
198Each bucket has a list of reassembly queues.
199The system must compare the incoming packets to the existing reassembly queues
200in the bucket to find a matching reassembly queue.
201To preserve system resources, the system limits the number of reassembly
202queues allowed in each bucket.
203This limit is recalculated when the number of mbuf clusters is changed or
204when the value of
205.Va maxfragpackets
206changes.
207This is a per-VNET limit.
208.It Va maxfragpackets
209Integer: maximum number of fragmented packets the host will accept and
210simultaneously hold in the reassembly queue for a particular VNET.
2110 means that the host will not accept any fragmented packets for that VNET.
212\-1 means that the host will not apply this limit for that VNET.
213This limit is recalculated when the number of mbuf clusters is changed.
214This is a per-VNET limit.
215.It Va maxfrags
216Integer: maximum number of fragments the host will accept and simultaneously
217hold across all reassembly queues in all VNETs.
218If set to 0, reassembly is disabled.
219If set to -1, this limit is not applied.
220This limit is recalculated when the number of mbuf clusters is changed.
221This is a global limit.
222.It Va maxfragsperpacket
223Integer: maximum number of fragments the host will accept and hold
224in the reassembly queue for a packet.
2250 means that the host will not accept any fragmented packets for the VNET.
226This is a per-VNET limit.
227.It Va mcast
228Variables under the
229.Va net.inet.ip.mcast
230node are documented in
231.Xr ip 4 .
232.It Va no_same_prefix
233Boolean: Refuse to create same prefixes on different interfaces.
234This is a per-VNET value.
235.It Va portrange
236Variables under the
237.Va net.inet.ip.portrange
238node control port ranges used by transport protocols; see
239.Xr ip 4
240for details.
241.It Va process_options
242Integer: control IP options processing.
243By setting this variable to 0, all IP options in the incoming packets
244will be ignored, and the packets will be passed unmodified.
245By setting to 1, IP options in the incoming packets will be processed
246accordingly.
247By setting to 2, an
248.Tn ICMP
249.Dq "prohibited by filter"
250message will be sent back in response to incoming packets with IP options.
251Default is 1.
252This
253.Xr sysctl 8
254variable affects packets destined for a local host as well as packets
255forwarded to some other host.
256.It Va random_id
257Boolean: control IP IDs generation behavior.
258Setting this
259.Xr sysctl 8
260to 1 causes the ID field in
261.Em non-atomic
262IP datagrams (or all IP datagrams, if
263.Va rfc6864
264is disabled) to be randomized instead of incremented by 1 with each packet
265generated.
266This closes a minor information leak which allows remote observers to
267determine the rate of packet generation on the machine by watching the
268counter.
269At the same time, on high-speed links, it can decrease the ID reuse
270cycle greatly.
271Default is 0 (sequential IP IDs).
272IPv6 flow IDs and fragment IDs are always random.
273.It Va random_id_collisions
274Integer: count of IP ID collisions (read-only, per-VNET).
275.It Va random_id_period
276Integer: size of the IP ID array, which is the number of previous packets
277for which the IDs are recorded.
278The number must be between 512 and 32768 inclusive.
279This is a per-VNET value.
280.It Va random_id_total
281Integer: count of IP IDs created (read-only, per-VNET).
282.It Va reass_hashsize
283Number of hash slots in the IPv4 reassembly queue (loader tunable).
284.It Va redirect
285Boolean: enable/disable sending of ICMP redirects in response to
286.Tn IP
287packets for which a better, and for the sender directly reachable, route
288and next hop is known.
289Defaults to on.
290.It Va rfc1122_strong_es
291Boolean: in non-forwarding mode
292.Pq forwarding is disabled
293partially implement the Strong End System model per RFC1122.
294If a packet with destination address that is local arrives on a different
295interface than the interface the address belongs to, the packet would be
296silently dropped.
297Enabling this option may break certain setups, e.g. having an alias address(es)
298on loopback that are expected to be reachable by outside traffic.
299Enabling some other network features, e.g.
300.Xr carp 4
301or destination address rewriting
302.Xr pfil 4
303filters may override and bypass this check.
304Disabled by default.
305.It Va rfc6864
306Boolean: control IP IDs generation behaviour.
307True value enables RFC6864 support, which specifies that IP ID field of
308.Em atomic
309datagrams can be set to any value.
310The
311.Fx implementation sets it to zero.
312Enabled by default.
313.It Va source_address_validation
314Boolean: perform source address validation for packets destined for the local
315host.
316Consider this as following Section 3.2 of RFC3704/BCP84, where we treat local
317host as our own infrastructure.
318Forwarded packets are unaffected by this
319and it should not be considered an anti-spoof feature for a router.
320Enabled by default.
321.It Va sourceroute
322Boolean: enable/disable forwarding of source-routed IP packets (default false).
323.It Va ttl
324Integer: default time-to-live
325.Pq Dq TTL
326to use for outgoing
327.Tn IP
328packets.
329.El
330.Sh SEE ALSO
331.Xr ioctl 2 ,
332.Xr socket 2 ,
333.Xr getifaddrs 3 ,
334.Xr sysctl 3 ,
335.Xr icmp 4 ,
336.Xr intro 4 ,
337.Xr ip 4 ,
338.Xr ipfirewall 4 ,
339.Xr route 4 ,
340.Xr tcp 4 ,
341.Xr udp 4 ,
342.Xr sysctl 8 ,
343.Xr pfil 9
344.Rs
345.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
346.%B PS1
347.%N 7
348.Re
349.Rs
350.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
351.%B PS1
352.%N 8
353.Re
354.Sh HISTORY
355The
356.Nm
357protocol interface appeared in
358.Bx 4.2 .
359The
360.Dq protocol cloning
361code appeared in
362.Fx 2.1 .
363.Sh CAVEATS
364The Internet protocol support is subject to change as
365the Internet protocols develop.
366Users should not depend
367on details of the current implementation, but rather
368the services exported.
369