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