xref: /freebsd/share/man/man4/inet.4 (revision 60052a11db8e729e8df92611c05135f009c01081)
1afe61c15SRodney W. Grimes.\" Copyright (c) 1983, 1991, 1993
2afe61c15SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
3afe61c15SRodney W. Grimes.\"
4afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
5afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions
6afe61c15SRodney W. Grimes.\" are met:
7afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
8afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
9afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
10afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
11afe61c15SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12dda5b397SEitan Adler.\" 3. Neither the name of the University nor the names of its contributors
13afe61c15SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
14afe61c15SRodney W. Grimes.\"    without specific prior written permission.
15afe61c15SRodney W. Grimes.\"
16afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19afe61c15SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26afe61c15SRodney W. Grimes.\" SUCH DAMAGE.
27afe61c15SRodney W. Grimes.\"
28a2cc1fa2SGarrett Wollman.\"     From: @(#)inet.4	8.1 (Berkeley) 6/5/93
297f3dea24SPeter Wemm.\" $FreeBSD$
30afe61c15SRodney W. Grimes.\"
31*60052a11SMike Karels.Dd July 14, 2022
32afe61c15SRodney W. Grimes.Dt INET 4
333d45e180SRuslan Ermilov.Os
34afe61c15SRodney W. Grimes.Sh NAME
35afe61c15SRodney W. Grimes.Nm inet
36afe61c15SRodney W. Grimes.Nd Internet protocol family
37afe61c15SRodney W. Grimes.Sh SYNOPSIS
3832eef9aeSRuslan Ermilov.In sys/types.h
3932eef9aeSRuslan Ermilov.In netinet/in.h
40afe61c15SRodney W. Grimes.Sh DESCRIPTION
41afe61c15SRodney W. GrimesThe Internet protocol family is a collection of protocols
42afe61c15SRodney W. Grimeslayered atop the
43afe61c15SRodney W. Grimes.Em Internet Protocol
44afe61c15SRodney W. Grimes.Pq Tn IP
45afe61c15SRodney W. Grimestransport layer, and utilizing the Internet address format.
46afe61c15SRodney W. GrimesThe Internet family provides protocol support for the
47afe61c15SRodney W. Grimes.Dv SOCK_STREAM , SOCK_DGRAM ,
48afe61c15SRodney W. Grimesand
49afe61c15SRodney W. Grimes.Dv SOCK_RAW
50afe61c15SRodney W. Grimessocket types; the
51afe61c15SRodney W. Grimes.Dv SOCK_RAW
52afe61c15SRodney W. Grimesinterface provides access to the
53afe61c15SRodney W. Grimes.Tn IP
54afe61c15SRodney W. Grimesprotocol.
55afe61c15SRodney W. Grimes.Sh ADDRESSING
56afe61c15SRodney W. GrimesInternet addresses are four byte quantities, stored in
574d721ca3SWarner Loshnetwork standard format (on little endian machines, such as the
584d721ca3SWarner Losh.Tn alpha ,
59e7d939bdSMarcel Moolenaar.Tn amd64
604d721ca3SWarner Loshand
61e7d939bdSMarcel Moolenaar.Tn i386
624d721ca3SWarner Loshthese are word and byte reversed).
63b5e7e999SRuslan ErmilovThe include file
64fe08efe6SRuslan Ermilov.In netinet/in.h
65afe61c15SRodney W. Grimesdefines this address
66afe61c15SRodney W. Grimesas a discriminated union.
67afe61c15SRodney W. Grimes.Pp
68afe61c15SRodney W. GrimesSockets bound to the Internet protocol family utilize
69afe61c15SRodney W. Grimesthe following addressing structure,
70afe61c15SRodney W. Grimes.Bd -literal -offset indent
71afe61c15SRodney W. Grimesstruct sockaddr_in {
7275eb8a43SRuslan Ermilov	uint8_t		sin_len;
7375eb8a43SRuslan Ermilov	sa_family_t	sin_family;
7475eb8a43SRuslan Ermilov	in_port_t	sin_port;
75afe61c15SRodney W. Grimes	struct in_addr	sin_addr;
76afe61c15SRodney W. Grimes	char		sin_zero[8];
77afe61c15SRodney W. Grimes};
78afe61c15SRodney W. Grimes.Ed
79afe61c15SRodney W. Grimes.Pp
80afe61c15SRodney W. GrimesSockets may be created with the local address
81afe61c15SRodney W. Grimes.Dv INADDR_ANY
82db3357b8SSheldon Hearnto affect
83afe61c15SRodney W. Grimes.Dq wildcard
84afe61c15SRodney W. Grimesmatching on incoming messages.
85afe61c15SRodney W. GrimesThe address in a
86afe61c15SRodney W. Grimes.Xr connect 2
87afe61c15SRodney W. Grimesor
88afe61c15SRodney W. Grimes.Xr sendto 2
89afe61c15SRodney W. Grimescall may be given as
90afe61c15SRodney W. Grimes.Dv INADDR_ANY
91afe61c15SRodney W. Grimesto mean
92afe61c15SRodney W. Grimes.Dq this host .
93afe61c15SRodney W. GrimesThe distinguished address
94afe61c15SRodney W. Grimes.Dv INADDR_BROADCAST
95afe61c15SRodney W. Grimesis allowed as a shorthand for the broadcast address on the primary
96afe61c15SRodney W. Grimesnetwork if the first network configured supports broadcast.
97afe61c15SRodney W. Grimes.Sh PROTOCOLS
98afe61c15SRodney W. GrimesThe Internet protocol family is comprised of
99afe61c15SRodney W. Grimesthe
100afe61c15SRodney W. Grimes.Tn IP
101a2cc1fa2SGarrett Wollmannetwork protocol, Internet Control
102afe61c15SRodney W. GrimesMessage Protocol
103afe61c15SRodney W. Grimes.Pq Tn ICMP ,
104a2cc1fa2SGarrett WollmanInternet Group Management Protocol
105a2cc1fa2SGarrett Wollman.Pq Tn IGMP ,
106afe61c15SRodney W. GrimesTransmission Control
107afe61c15SRodney W. GrimesProtocol
108afe61c15SRodney W. Grimes.Pq Tn TCP ,
109afe61c15SRodney W. Grimesand User Datagram Protocol
110afe61c15SRodney W. Grimes.Pq Tn UDP .
111afe61c15SRodney W. Grimes.Tn TCP
112afe61c15SRodney W. Grimesis used to support the
113afe61c15SRodney W. Grimes.Dv SOCK_STREAM
114afe61c15SRodney W. Grimesabstraction while
115afe61c15SRodney W. Grimes.Tn UDP
116afe61c15SRodney W. Grimesis used to support the
117afe61c15SRodney W. Grimes.Dv SOCK_DGRAM
118b5e7e999SRuslan Ermilovabstraction.
119b5e7e999SRuslan ErmilovA raw interface to
120afe61c15SRodney W. Grimes.Tn IP
121afe61c15SRodney W. Grimesis available
122afe61c15SRodney W. Grimesby creating an Internet socket of type
123afe61c15SRodney W. Grimes.Dv SOCK_RAW .
124afe61c15SRodney W. GrimesThe
125afe61c15SRodney W. Grimes.Tn ICMP
126afe61c15SRodney W. Grimesmessage protocol is accessible from a raw socket.
127afe61c15SRodney W. Grimes.Pp
128c1f9914bSGleb SmirnoffThe
129c1f9914bSGleb Smirnoff.Nm
130c1f9914bSGleb Smirnoffaddress on an interface consist of the address itself, the
131c1f9914bSGleb Smirnoffnetmask, either broadcast address in case of a broadcast
132c1f9914bSGleb Smirnoffinterface or peers address in case of point-to-point interface.
133c1f9914bSGleb SmirnoffThe following
134afe61c15SRodney W. Grimes.Xr ioctl 2
135c1f9914bSGleb Smirnoffcommands are provided for a datagram socket in the Internet domain:
136c1f9914bSGleb Smirnoff.Pp
137c1f9914bSGleb Smirnoff.Bl -tag -width ".Dv SIOCGIFBRDADDR" -offset indent -compact
138c1f9914bSGleb Smirnoff.It Dv SIOCAIFADDR
139c1f9914bSGleb SmirnoffAdd address to an interface.
140c1f9914bSGleb SmirnoffThe command requires
141c1f9914bSGleb Smirnoff.Ft struct in_aliasreq
142c1f9914bSGleb Smirnoffas argument.
143c1f9914bSGleb Smirnoff.It Dv SIOCDIFADDR
144c1f9914bSGleb SmirnoffDelete address from an interface.
145c1f9914bSGleb SmirnoffThe command requires
146c1f9914bSGleb Smirnoff.Ft struct ifreq
147c1f9914bSGleb Smirnoffas argument.
148c1f9914bSGleb Smirnoff.It Dv SIOCGIFADDR
149c1f9914bSGleb Smirnoff.It Dv SIOCGIFBRDADDR
150c1f9914bSGleb Smirnoff.It Dv SIOCGIFDSTADDR
151afe61c15SRodney W. Grimes.It Dv SIOCGIFNETMASK
15225972509SEdward Tomasz NapieralaReturn address information from interface.
15325972509SEdward Tomasz NapieralaThe returned value is in
154c1f9914bSGleb Smirnoff.Ft struct ifreq .
155c1f9914bSGleb SmirnoffThis way of address information retrieval is obsoleted, a
156c1f9914bSGleb Smirnoffpreferred way is to use
157c1f9914bSGleb Smirnoff.Xr getifaddrs 3
158c1f9914bSGleb SmirnoffAPI.
159afe61c15SRodney W. Grimes.El
16051b62b5aSYoshinobu Inoue.Ss MIB Variables
161b691e485SMike KarelsIn addition to the variables supported by the transport protocols in
162b691e485SMike Karels.Va net.inet
163b691e485SMike Karels(for which the respective manual pages may be consulted),
164b691e485SMike Karelsthere are a number of general variables implemented in the
165b691e485SMike Karels.Va net.inet.ip
166b691e485SMike Karelsbranch of the
167a2cc1fa2SGarrett Wollman.Xr sysctl 3
16851b62b5aSYoshinobu InoueMIB.
169*60052a11SMike KarelsThe following general variables are defined:
170b691e485SMike Karels.Bl -tag -width ".Va accept_sourceroute"
171b691e485SMike Karels.It Va forwarding
1720f5d195dSDag-Erling SmørgravBoolean: enable/disable forwarding of IP packets.
1730f5d195dSDag-Erling SmørgravDefaults to off.
174b691e485SMike Karels.It Va redirect
175a2cc1fa2SGarrett WollmanBoolean: enable/disable sending of ICMP redirects in response to
176a2cc1fa2SGarrett Wollman.Tn IP
177bf59255fSAndre Oppermannpackets for which a better, and for the sender directly reachable, route
178bf59255fSAndre Oppermannand next hop is known.
1796d249eeeSSheldon HearnDefaults to on.
180b691e485SMike Karels.It Va ttl
181a2cc1fa2SGarrett WollmanInteger: default time-to-live
182a2cc1fa2SGarrett Wollman.Pq Dq TTL
183a2cc1fa2SGarrett Wollmanto use for outgoing
184a2cc1fa2SGarrett Wollman.Tn IP
185a2cc1fa2SGarrett Wollmanpackets.
186b691e485SMike Karels.It Va accept_sourceroute
1873d140861SRuslan ErmilovBoolean: enable/disable accepting of source-routed IP packets (default false).
188b691e485SMike Karels.It Va sourceroute
1890e5ca0d8SGarrett WollmanBoolean: enable/disable forwarding of source-routed IP packets (default false).
190b691e485SMike Karels.It Va process_options
191a65cfc98SMaxim KonovalovInteger: control IP options processing.
192a65cfc98SMaxim KonovalovBy setting this variable to 0, all IP options in the incoming packets
193a65cfc98SMaxim Konovalovwill be ignored, and the packets will be passed unmodified.
194a65cfc98SMaxim KonovalovBy setting to 1, IP options in the incoming packets will be processed
195a65cfc98SMaxim Konovalovaccordingly.
196a65cfc98SMaxim KonovalovBy setting to 2, an
197a65cfc98SMaxim Konovalov.Tn ICMP
198a65cfc98SMaxim Konovalov.Dq "prohibited by filter"
1990af22117SMike Pritchardmessage will be sent back in response to incoming packets with IP options.
200a65cfc98SMaxim KonovalovDefault is 1.
201a65cfc98SMaxim KonovalovThis
202a65cfc98SMaxim Konovalov.Xr sysctl 8
203a65cfc98SMaxim Konovalovvariable affects packets destined for a local host as well as packets
204a65cfc98SMaxim Konovalovforwarded to some other host.
205b691e485SMike Karels.It Va rfc1122_strong_es
20694df3271SGleb SmirnoffBoolean: in non-forwarding mode
207b691e485SMike Karels.Pq forwarding is disabled
20894df3271SGleb Smirnoffpartially implement the Strong End System model per RFC1122.
20994df3271SGleb SmirnoffIf a packet with destination address that is local arrives on a different
21094df3271SGleb Smirnoffinterface than the interface the address belongs to, the packet would be
21194df3271SGleb Smirnoffsilently dropped.
21294df3271SGleb SmirnoffEnabling this option may break certain setups, e.g. having an alias address(es)
21394df3271SGleb Smirnoffon loopback that are expected to be reachable by outside traffic.
21494df3271SGleb SmirnoffEnabling some other network features, e.g.
21594df3271SGleb Smirnoff.Xr carp 4
21694df3271SGleb Smirnoffor destination address rewriting
21794df3271SGleb Smirnoff.Xr pfil 4
21894df3271SGleb Smirnofffilters may override and bypass this check.
21994df3271SGleb SmirnoffDisabled by default.
220b691e485SMike Karels.It Va source_address_validation
2212ce85919SGleb SmirnoffBoolean: perform source address validation for packets destined for the local
2222ce85919SGleb Smirnoffhost.
2232ce85919SGleb SmirnoffConsider this as following Section 3.2 of RFC3704/BCP84, where we treat local
2242ce85919SGleb Smirnoffhost as our own infrastructure.
2252ce85919SGleb SmirnoffThis has no effect on packets to be forwarded, so don't consider it as
2262ce85919SGleb Smirnoffanti-spoof feature for a router.
2272ce85919SGleb SmirnoffEnabled by default.
228b691e485SMike Karels.It Va rfc6864
2296d947416SGleb SmirnoffBoolean: control IP IDs generation behaviour.
2306d947416SGleb SmirnoffTrue value enables RFC6864 support, which specifies that IP ID field of
2316d947416SGleb Smirnoff.Em atomic
2326d947416SGleb Smirnoffdatagrams can be set to any value.
2336d947416SGleb SmirnoffThe
2346d947416SGleb Smirnoff.Fx implementation sets it to zero.
2356d947416SGleb SmirnoffEnabled by default.
236b691e485SMike Karels.It Va random_id
2374892c9a4SMaxim KonovalovBoolean: control IP IDs generation behaviour.
2384892c9a4SMaxim KonovalovSetting this
2394892c9a4SMaxim Konovalov.Xr sysctl 8
2406d947416SGleb Smirnoffto 1 causes the ID field in
2416d947416SGleb Smirnoff.Em non-atomic
2426d947416SGleb SmirnoffIP datagrams (or all IP datagrams, if
243b691e485SMike Karels.Va rfc6864
2446d947416SGleb Smirnoffis disabled) to be randomized instead of incremented by 1 with each packet
2456d947416SGleb Smirnoffgenerated.
24610e69389SHans Petter SelaskyThis closes a minor information leak which allows remote observers to
24710e69389SHans Petter Selaskydetermine the rate of packet generation on the machine by watching the
24810e69389SHans Petter Selaskycounter.
2497ab169a3SHans Petter SelaskyAt the same time, on high-speed links, it can decrease the ID reuse
250b2df3ab1SMaxim Konovalovcycle greatly.
2514892c9a4SMaxim KonovalovDefault is 0 (sequential IP IDs).
2524892c9a4SMaxim KonovalovIPv6 flow IDs and fragment IDs are always random.
253b691e485SMike Karels.It Va maxfrags
2548c52a6dbSJonathan T. LooneyInteger: maximum number of fragments the host will accept and simultaneously
2558c52a6dbSJonathan T. Looneyhold across all reassembly queues in all VNETs.
2568c52a6dbSJonathan T. LooneyIf set to 0, reassembly is disabled.
2578c52a6dbSJonathan T. LooneyIf set to -1, this limit is not applied.
2588c52a6dbSJonathan T. LooneyThis limit is recalculated when the number of mbuf clusters is changed.
2598c52a6dbSJonathan T. LooneyThis is a global limit.
260b691e485SMike Karels.It Va maxfragpackets
2618c52a6dbSJonathan T. LooneyInteger: maximum number of fragmented packets the host will accept and
2628c52a6dbSJonathan T. Looneysimultaneously hold in the reassembly queue for a particular VNET.
2638c52a6dbSJonathan T. Looney0 means that the host will not accept any fragmented packets for that VNET.
2648c52a6dbSJonathan T. Looney\-1 means that the host will not apply this limit for that VNET.
2658c52a6dbSJonathan T. LooneyThis limit is recalculated when the number of mbuf clusters is changed.
2668c52a6dbSJonathan T. LooneyThis is a per-VNET limit.
267b691e485SMike Karels.It Va maxfragbucketsize
2688c52a6dbSJonathan T. LooneyInteger: maximum number of reassembly queues per bucket.
2698c52a6dbSJonathan T. LooneyFragmented packets are hashed to buckets.
2708c52a6dbSJonathan T. LooneyEach bucket has a list of reassembly queues.
2718c52a6dbSJonathan T. LooneyThe system must compare the incoming packets to the existing reassembly queues
2728c52a6dbSJonathan T. Looneyin the bucket to find a matching reassembly queue.
2738c52a6dbSJonathan T. LooneyTo preserve system resources, the system limits the number of reassembly
2748c52a6dbSJonathan T. Looneyqueues allowed in each bucket.
2758c52a6dbSJonathan T. LooneyThis limit is recalculated when the number of mbuf clusters is changed or
2768c52a6dbSJonathan T. Looneywhen the value of
277b691e485SMike Karels.Va maxfragpackets
2788c52a6dbSJonathan T. Looneychanges.
2798c52a6dbSJonathan T. LooneyThis is a per-VNET limit.
280b691e485SMike Karels.It Va maxfragsperpacket
28105b5066eSMaxim KonovalovInteger: maximum number of fragments the host will accept and hold
2828c52a6dbSJonathan T. Looneyin the reassembly queue for a packet.
2838c52a6dbSJonathan T. Looney0 means that the host will not accept any fragmented packets for the VNET.
2848c52a6dbSJonathan T. LooneyThis is a per-VNET limit.
285b691e485SMike Karels.It Va allow_net0
286efe58855SMike KarelsBoolean: allow experimental use of addresses in 0.0.0.0/8 as endpoints,
287efe58855SMike Karelsand allow forwarding of packets with these addresses.
288b691e485SMike Karels.It Va allow_net240
289efe58855SMike KarelsBoolean: allow experimental use of addresses in 240.0.0.0/4 as endpoints,
290efe58855SMike Karelsand allow forwarding of packets with these addresses.
291b691e485SMike Karels.It Va loopback_prefixlen
292efe58855SMike KarelsInteger: prefix length of the address space reserved for loopback purposes.
293efe58855SMike KarelsThe default is 8, meaning that 127.0.0.0/8 is reserved for loopback,
294efe58855SMike Karelsand cannot be sent, received, or forwarded on a non-loopback interface.
295efe58855SMike KarelsUse of other values is experimental.
296a2cc1fa2SGarrett Wollman.El
297afe61c15SRodney W. Grimes.Sh SEE ALSO
298afe61c15SRodney W. Grimes.Xr ioctl 2 ,
299afe61c15SRodney W. Grimes.Xr socket 2 ,
300c1f9914bSGleb Smirnoff.Xr getifaddrs 3 ,
301a2cc1fa2SGarrett Wollman.Xr sysctl 3 ,
3020b992c1dSWolfram Schneider.Xr icmp 4 ,
303afe61c15SRodney W. Grimes.Xr intro 4 ,
3040b992c1dSWolfram Schneider.Xr ip 4 ,
3050f5d195dSDag-Erling Smørgrav.Xr ipfirewall 4 ,
306bf59255fSAndre Oppermann.Xr route 4 ,
307afe61c15SRodney W. Grimes.Xr tcp 4 ,
308bf59255fSAndre Oppermann.Xr udp 4 ,
309bf59255fSAndre Oppermann.Xr pfil 9
310afe61c15SRodney W. Grimes.Rs
311afe61c15SRodney W. Grimes.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
312afe61c15SRodney W. Grimes.%B PS1
313afe61c15SRodney W. Grimes.%N 7
314afe61c15SRodney W. Grimes.Re
315afe61c15SRodney W. Grimes.Rs
316afe61c15SRodney W. Grimes.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
317afe61c15SRodney W. Grimes.%B PS1
318afe61c15SRodney W. Grimes.%N 8
319afe61c15SRodney W. Grimes.Re
320afe61c15SRodney W. Grimes.Sh HISTORY
321afe61c15SRodney W. GrimesThe
322afe61c15SRodney W. Grimes.Nm
323afe61c15SRodney W. Grimesprotocol interface appeared in
324afe61c15SRodney W. Grimes.Bx 4.2 .
325a2cc1fa2SGarrett WollmanThe
326a2cc1fa2SGarrett Wollman.Dq protocol cloning
327a2cc1fa2SGarrett Wollmancode appeared in
32846f84fcbSMike Pritchard.Fx 2.1 .
3290afc94c1SUlrich Spörlein.Sh CAVEATS
3300afc94c1SUlrich SpörleinThe Internet protocol support is subject to change as
3310afc94c1SUlrich Spörleinthe Internet protocols develop.
3320afc94c1SUlrich SpörleinUsers should not depend
3330afc94c1SUlrich Spörleinon details of the current implementation, but rather
3340afc94c1SUlrich Spörleinthe services exported.
335