xref: /freebsd/share/man/man4/inet.4 (revision e7d939bda22b07be6b68ba38835c9167212fd56e)
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.\"
31c1f9914bSGleb Smirnoff.Dd January 26, 2012
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 ,
59*e7d939bdSMarcel Moolenaar.Tn amd64
604d721ca3SWarner Loshand
61*e7d939bdSMarcel 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
152c1f9914bSGleb SmirnoffReturn address information from interface. The returned value
153c1f9914bSGleb Smirnoffis 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
161a2cc1fa2SGarrett WollmanA number of variables are implemented in the net.inet branch of the
162a2cc1fa2SGarrett Wollman.Xr sysctl 3
16351b62b5aSYoshinobu InoueMIB.
16451b62b5aSYoshinobu InoueIn addition to the variables supported by the transport protocols
16551b62b5aSYoshinobu Inoue(for which the respective manual pages may be consulted),
16651b62b5aSYoshinobu Inouethe following general variables are defined:
1670f5d195dSDag-Erling Smørgrav.Bl -tag -width IPCTL_FASTFORWARDING
168a2cc1fa2SGarrett Wollman.It Dv IPCTL_FORWARDING
169a2cc1fa2SGarrett Wollman.Pq ip.forwarding
1700f5d195dSDag-Erling SmørgravBoolean: enable/disable forwarding of IP packets.
1710f5d195dSDag-Erling SmørgravDefaults to off.
1720f5d195dSDag-Erling Smørgrav.It Dv IPCTL_FASTFORWARDING
1730f5d195dSDag-Erling Smørgrav.Pq ip.fastforwarding
174bf59255fSAndre OppermannBoolean: enable/disable the use of
175bf59255fSAndre Oppermann.Tn fast IP forwarding
176bf59255fSAndre Oppermanncode.
1770f5d195dSDag-Erling SmørgravDefaults to off.
178bf59255fSAndre OppermannWhen
179bf59255fSAndre Oppermann.Tn fast IP forwarding
180bf59255fSAndre Oppermannis enabled, IP packets are forwarded directly to the appropriate network
181bf59255fSAndre Oppermanninterface with direct processing to completion, which greatly improves
182bf59255fSAndre Oppermannthe throughput.
183bf59255fSAndre OppermannAll packets for local IP addresses, non-unicast, or with IP options are
184bf59255fSAndre Oppermannhandled by the normal IP input processing path.
185bf59255fSAndre OppermannAll features of the normal (slow) IP forwarding path are supported
186bf59255fSAndre Oppermannincluding firewall (through
187bf59255fSAndre Oppermann.Xr pfil 9
188bf59255fSAndre Oppermannhooks) checking, except
1893ac17febSRuslan Ermilov.Xr ipsec 4
190bf59255fSAndre Oppermanntunnel brokering.
191bf59255fSAndre OppermannThe
192bf59255fSAndre Oppermann.Tn IP fastforwarding
193bf59255fSAndre Oppermannpath does not generate ICMP redirect or source quench messages.
194a2cc1fa2SGarrett Wollman.It Dv IPCTL_SENDREDIRECTS
195a2cc1fa2SGarrett Wollman.Pq ip.redirect
196a2cc1fa2SGarrett WollmanBoolean: enable/disable sending of ICMP redirects in response to
197a2cc1fa2SGarrett Wollman.Tn IP
198bf59255fSAndre Oppermannpackets for which a better, and for the sender directly reachable, route
199bf59255fSAndre Oppermannand next hop is known.
2006d249eeeSSheldon HearnDefaults to on.
201a2cc1fa2SGarrett Wollman.It Dv IPCTL_DEFTTL
202a2cc1fa2SGarrett Wollman.Pq ip.ttl
203a2cc1fa2SGarrett WollmanInteger: default time-to-live
204a2cc1fa2SGarrett Wollman.Pq Dq TTL
205a2cc1fa2SGarrett Wollmanto use for outgoing
206a2cc1fa2SGarrett Wollman.Tn IP
207a2cc1fa2SGarrett Wollmanpackets.
2083d140861SRuslan Ermilov.It Dv IPCTL_ACCEPTSOURCEROUTE
2093d140861SRuslan Ermilov.Pq ip.accept_sourceroute
2103d140861SRuslan ErmilovBoolean: enable/disable accepting of source-routed IP packets (default false).
2110e5ca0d8SGarrett Wollman.It Dv IPCTL_SOURCEROUTE
2120e5ca0d8SGarrett Wollman.Pq ip.sourceroute
2130e5ca0d8SGarrett WollmanBoolean: enable/disable forwarding of source-routed IP packets (default false).
214a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTEXPIRE
215a2cc1fa2SGarrett Wollman.Pq ip.rtexpire
216a2cc1fa2SGarrett WollmanInteger: lifetime in seconds of protocol-cloned
217a2cc1fa2SGarrett Wollman.Tn IP
218b5e7e999SRuslan Ermilovroutes after the last reference drops (default one hour).
219b5e7e999SRuslan ErmilovThis value varies dynamically as described above.
220a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTMINEXPIRE
221a2cc1fa2SGarrett Wollman.Pq ip.rtminexpire
222b5e7e999SRuslan ErmilovInteger: minimum value of ip.rtexpire (default ten seconds).
223b5e7e999SRuslan ErmilovThis value has no effect on user modifications, but restricts the dynamic
224a2cc1fa2SGarrett Wollmanadaptation described above.
225a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTMAXCACHE
226a2cc1fa2SGarrett Wollman.Pq ip.rtmaxcache
227a2cc1fa2SGarrett WollmanInteger: trigger level of cached, unreferenced, protocol-cloned routes
228a2cc1fa2SGarrett Wollmanwhich initiates dynamic adaptation (default 128).
229a65cfc98SMaxim Konovalov.It Va ip.process_options
230a65cfc98SMaxim KonovalovInteger: control IP options processing.
231a65cfc98SMaxim KonovalovBy setting this variable to 0, all IP options in the incoming packets
232a65cfc98SMaxim Konovalovwill be ignored, and the packets will be passed unmodified.
233a65cfc98SMaxim KonovalovBy setting to 1, IP options in the incoming packets will be processed
234a65cfc98SMaxim Konovalovaccordingly.
235a65cfc98SMaxim KonovalovBy setting to 2, an
236a65cfc98SMaxim Konovalov.Tn ICMP
237a65cfc98SMaxim Konovalov.Dq "prohibited by filter"
2380af22117SMike Pritchardmessage will be sent back in response to incoming packets with IP options.
239a65cfc98SMaxim KonovalovDefault is 1.
240a65cfc98SMaxim KonovalovThis
241a65cfc98SMaxim Konovalov.Xr sysctl 8
242a65cfc98SMaxim Konovalovvariable affects packets destined for a local host as well as packets
243a65cfc98SMaxim Konovalovforwarded to some other host.
2444892c9a4SMaxim Konovalov.It Va ip.random_id
2454892c9a4SMaxim KonovalovBoolean: control IP IDs generation behaviour.
2464892c9a4SMaxim KonovalovSetting this
2474892c9a4SMaxim Konovalov.Xr sysctl 8
2484892c9a4SMaxim Konovalovto non-zero causes the ID field in IP packets to be randomized instead of
2494892c9a4SMaxim Konovalovincremented by 1 with each packet generated.
2504892c9a4SMaxim KonovalovThis closes a minor information leak which allows remote observers to
2514892c9a4SMaxim Konovalovdetermine the rate of packet generation on the machine by watching the
2524892c9a4SMaxim Konovalovcounter.
253b2df3ab1SMaxim KonovalovIn the same time, on high-speed links, it can decrease the ID reuse
254b2df3ab1SMaxim Konovalovcycle greatly.
2554892c9a4SMaxim KonovalovDefault is 0 (sequential IP IDs).
2564892c9a4SMaxim KonovalovIPv6 flow IDs and fragment IDs are always random.
25705b5066eSMaxim Konovalov.It Va ip.maxfragpackets
25805b5066eSMaxim KonovalovInteger: maximum number of fragmented packets the host will accept and hold
25905b5066eSMaxim Konovalovin the reassembling queue simultaneously.
26005b5066eSMaxim Konovalov0 means that the host will not accept any fragmented packets.
26105b5066eSMaxim Konovalov\-1 means that the host will accept as many fragmented packets as it receives.
26205b5066eSMaxim Konovalov.It Va ip.maxfragsperpacket
26305b5066eSMaxim KonovalovInteger: maximum number of fragments the host will accept and hold
26405b5066eSMaxim Konovalovin the reassembling queue for a packet.
26505b5066eSMaxim Konovalov0 means that the host will not accept any fragmented packets.
266a2cc1fa2SGarrett Wollman.El
267afe61c15SRodney W. Grimes.Sh SEE ALSO
268afe61c15SRodney W. Grimes.Xr ioctl 2 ,
269afe61c15SRodney W. Grimes.Xr socket 2 ,
270c1f9914bSGleb Smirnoff.Xr getifaddrs 3 ,
271a2cc1fa2SGarrett Wollman.Xr sysctl 3 ,
2720b992c1dSWolfram Schneider.Xr icmp 4 ,
273afe61c15SRodney W. Grimes.Xr intro 4 ,
2740b992c1dSWolfram Schneider.Xr ip 4 ,
2750f5d195dSDag-Erling Smørgrav.Xr ipfirewall 4 ,
276bf59255fSAndre Oppermann.Xr route 4 ,
277afe61c15SRodney W. Grimes.Xr tcp 4 ,
278bf59255fSAndre Oppermann.Xr udp 4 ,
279bf59255fSAndre Oppermann.Xr pfil 9
280afe61c15SRodney W. Grimes.Rs
281afe61c15SRodney W. Grimes.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
282afe61c15SRodney W. Grimes.%B PS1
283afe61c15SRodney W. Grimes.%N 7
284afe61c15SRodney W. Grimes.Re
285afe61c15SRodney W. Grimes.Rs
286afe61c15SRodney W. Grimes.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
287afe61c15SRodney W. Grimes.%B PS1
288afe61c15SRodney W. Grimes.%N 8
289afe61c15SRodney W. Grimes.Re
290afe61c15SRodney W. Grimes.Sh HISTORY
291afe61c15SRodney W. GrimesThe
292afe61c15SRodney W. Grimes.Nm
293afe61c15SRodney W. Grimesprotocol interface appeared in
294afe61c15SRodney W. Grimes.Bx 4.2 .
295a2cc1fa2SGarrett WollmanThe
296a2cc1fa2SGarrett Wollman.Dq protocol cloning
297a2cc1fa2SGarrett Wollmancode appeared in
29846f84fcbSMike Pritchard.Fx 2.1 .
2990afc94c1SUlrich Spörlein.Sh CAVEATS
3000afc94c1SUlrich SpörleinThe Internet protocol support is subject to change as
3010afc94c1SUlrich Spörleinthe Internet protocols develop.
3020afc94c1SUlrich SpörleinUsers should not depend
3030afc94c1SUlrich Spörleinon details of the current implementation, but rather
3040afc94c1SUlrich Spörleinthe services exported.
305