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