xref: /freebsd/share/man/man4/inet.4 (revision dda5b39711dab90ae1c5624bdd6ff7453177df31)
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.
12*dda5b397SEitan 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 ,
594d721ca3SWarner Losh.Tn amd64 ,
604d721ca3SWarner Losh.Tn i386
614d721ca3SWarner Loshand
624d721ca3SWarner Losh.Tn ia64
634d721ca3SWarner Loshthese are word and byte reversed).
64b5e7e999SRuslan ErmilovThe include file
65fe08efe6SRuslan Ermilov.In netinet/in.h
66afe61c15SRodney W. Grimesdefines this address
67afe61c15SRodney W. Grimesas a discriminated union.
68afe61c15SRodney W. Grimes.Pp
69afe61c15SRodney W. GrimesSockets bound to the Internet protocol family utilize
70afe61c15SRodney W. Grimesthe following addressing structure,
71afe61c15SRodney W. Grimes.Bd -literal -offset indent
72afe61c15SRodney W. Grimesstruct sockaddr_in {
7375eb8a43SRuslan Ermilov	uint8_t		sin_len;
7475eb8a43SRuslan Ermilov	sa_family_t	sin_family;
7575eb8a43SRuslan Ermilov	in_port_t	sin_port;
76afe61c15SRodney W. Grimes	struct in_addr	sin_addr;
77afe61c15SRodney W. Grimes	char		sin_zero[8];
78afe61c15SRodney W. Grimes};
79afe61c15SRodney W. Grimes.Ed
80afe61c15SRodney W. Grimes.Pp
81afe61c15SRodney W. GrimesSockets may be created with the local address
82afe61c15SRodney W. Grimes.Dv INADDR_ANY
83db3357b8SSheldon Hearnto affect
84afe61c15SRodney W. Grimes.Dq wildcard
85afe61c15SRodney W. Grimesmatching on incoming messages.
86afe61c15SRodney W. GrimesThe address in a
87afe61c15SRodney W. Grimes.Xr connect 2
88afe61c15SRodney W. Grimesor
89afe61c15SRodney W. Grimes.Xr sendto 2
90afe61c15SRodney W. Grimescall may be given as
91afe61c15SRodney W. Grimes.Dv INADDR_ANY
92afe61c15SRodney W. Grimesto mean
93afe61c15SRodney W. Grimes.Dq this host .
94afe61c15SRodney W. GrimesThe distinguished address
95afe61c15SRodney W. Grimes.Dv INADDR_BROADCAST
96afe61c15SRodney W. Grimesis allowed as a shorthand for the broadcast address on the primary
97afe61c15SRodney W. Grimesnetwork if the first network configured supports broadcast.
98afe61c15SRodney W. Grimes.Sh PROTOCOLS
99afe61c15SRodney W. GrimesThe Internet protocol family is comprised of
100afe61c15SRodney W. Grimesthe
101afe61c15SRodney W. Grimes.Tn IP
102a2cc1fa2SGarrett Wollmannetwork protocol, Internet Control
103afe61c15SRodney W. GrimesMessage Protocol
104afe61c15SRodney W. Grimes.Pq Tn ICMP ,
105a2cc1fa2SGarrett WollmanInternet Group Management Protocol
106a2cc1fa2SGarrett Wollman.Pq Tn IGMP ,
107afe61c15SRodney W. GrimesTransmission Control
108afe61c15SRodney W. GrimesProtocol
109afe61c15SRodney W. Grimes.Pq Tn TCP ,
110afe61c15SRodney W. Grimesand User Datagram Protocol
111afe61c15SRodney W. Grimes.Pq Tn UDP .
112afe61c15SRodney W. Grimes.Tn TCP
113afe61c15SRodney W. Grimesis used to support the
114afe61c15SRodney W. Grimes.Dv SOCK_STREAM
115afe61c15SRodney W. Grimesabstraction while
116afe61c15SRodney W. Grimes.Tn UDP
117afe61c15SRodney W. Grimesis used to support the
118afe61c15SRodney W. Grimes.Dv SOCK_DGRAM
119b5e7e999SRuslan Ermilovabstraction.
120b5e7e999SRuslan ErmilovA raw interface to
121afe61c15SRodney W. Grimes.Tn IP
122afe61c15SRodney W. Grimesis available
123afe61c15SRodney W. Grimesby creating an Internet socket of type
124afe61c15SRodney W. Grimes.Dv SOCK_RAW .
125afe61c15SRodney W. GrimesThe
126afe61c15SRodney W. Grimes.Tn ICMP
127afe61c15SRodney W. Grimesmessage protocol is accessible from a raw socket.
128afe61c15SRodney W. Grimes.Pp
129c1f9914bSGleb SmirnoffThe
130c1f9914bSGleb Smirnoff.Nm
131c1f9914bSGleb Smirnoffaddress on an interface consist of the address itself, the
132c1f9914bSGleb Smirnoffnetmask, either broadcast address in case of a broadcast
133c1f9914bSGleb Smirnoffinterface or peers address in case of point-to-point interface.
134c1f9914bSGleb SmirnoffThe following
135afe61c15SRodney W. Grimes.Xr ioctl 2
136c1f9914bSGleb Smirnoffcommands are provided for a datagram socket in the Internet domain:
137c1f9914bSGleb Smirnoff.Pp
138c1f9914bSGleb Smirnoff.Bl -tag -width ".Dv SIOCGIFBRDADDR" -offset indent -compact
139c1f9914bSGleb Smirnoff.It Dv SIOCAIFADDR
140c1f9914bSGleb SmirnoffAdd address to an interface.
141c1f9914bSGleb SmirnoffThe command requires
142c1f9914bSGleb Smirnoff.Ft struct in_aliasreq
143c1f9914bSGleb Smirnoffas argument.
144c1f9914bSGleb Smirnoff.It Dv SIOCDIFADDR
145c1f9914bSGleb SmirnoffDelete address from an interface.
146c1f9914bSGleb SmirnoffThe command requires
147c1f9914bSGleb Smirnoff.Ft struct ifreq
148c1f9914bSGleb Smirnoffas argument.
149c1f9914bSGleb Smirnoff.It Dv SIOCGIFADDR
150c1f9914bSGleb Smirnoff.It Dv SIOCGIFBRDADDR
151c1f9914bSGleb Smirnoff.It Dv SIOCGIFDSTADDR
152afe61c15SRodney W. Grimes.It Dv SIOCGIFNETMASK
153c1f9914bSGleb SmirnoffReturn address information from interface. The returned value
154c1f9914bSGleb Smirnoffis in
155c1f9914bSGleb Smirnoff.Ft struct ifreq .
156c1f9914bSGleb SmirnoffThis way of address information retrieval is obsoleted, a
157c1f9914bSGleb Smirnoffpreferred way is to use
158c1f9914bSGleb Smirnoff.Xr getifaddrs 3
159c1f9914bSGleb SmirnoffAPI.
160afe61c15SRodney W. Grimes.El
16151b62b5aSYoshinobu Inoue.Ss MIB Variables
162a2cc1fa2SGarrett WollmanA number of variables are implemented in the net.inet branch of the
163a2cc1fa2SGarrett Wollman.Xr sysctl 3
16451b62b5aSYoshinobu InoueMIB.
16551b62b5aSYoshinobu InoueIn addition to the variables supported by the transport protocols
16651b62b5aSYoshinobu Inoue(for which the respective manual pages may be consulted),
16751b62b5aSYoshinobu Inouethe following general variables are defined:
1680f5d195dSDag-Erling Smørgrav.Bl -tag -width IPCTL_FASTFORWARDING
169a2cc1fa2SGarrett Wollman.It Dv IPCTL_FORWARDING
170a2cc1fa2SGarrett Wollman.Pq ip.forwarding
1710f5d195dSDag-Erling SmørgravBoolean: enable/disable forwarding of IP packets.
1720f5d195dSDag-Erling SmørgravDefaults to off.
1730f5d195dSDag-Erling Smørgrav.It Dv IPCTL_FASTFORWARDING
1740f5d195dSDag-Erling Smørgrav.Pq ip.fastforwarding
175bf59255fSAndre OppermannBoolean: enable/disable the use of
176bf59255fSAndre Oppermann.Tn fast IP forwarding
177bf59255fSAndre Oppermanncode.
1780f5d195dSDag-Erling SmørgravDefaults to off.
179bf59255fSAndre OppermannWhen
180bf59255fSAndre Oppermann.Tn fast IP forwarding
181bf59255fSAndre Oppermannis enabled, IP packets are forwarded directly to the appropriate network
182bf59255fSAndre Oppermanninterface with direct processing to completion, which greatly improves
183bf59255fSAndre Oppermannthe throughput.
184bf59255fSAndre OppermannAll packets for local IP addresses, non-unicast, or with IP options are
185bf59255fSAndre Oppermannhandled by the normal IP input processing path.
186bf59255fSAndre OppermannAll features of the normal (slow) IP forwarding path are supported
187bf59255fSAndre Oppermannincluding firewall (through
188bf59255fSAndre Oppermann.Xr pfil 9
189bf59255fSAndre Oppermannhooks) checking, except
1903ac17febSRuslan Ermilov.Xr ipsec 4
191bf59255fSAndre Oppermanntunnel brokering.
192bf59255fSAndre OppermannThe
193bf59255fSAndre Oppermann.Tn IP fastforwarding
194bf59255fSAndre Oppermannpath does not generate ICMP redirect or source quench messages.
195a2cc1fa2SGarrett Wollman.It Dv IPCTL_SENDREDIRECTS
196a2cc1fa2SGarrett Wollman.Pq ip.redirect
197a2cc1fa2SGarrett WollmanBoolean: enable/disable sending of ICMP redirects in response to
198a2cc1fa2SGarrett Wollman.Tn IP
199bf59255fSAndre Oppermannpackets for which a better, and for the sender directly reachable, route
200bf59255fSAndre Oppermannand next hop is known.
2016d249eeeSSheldon HearnDefaults to on.
202a2cc1fa2SGarrett Wollman.It Dv IPCTL_DEFTTL
203a2cc1fa2SGarrett Wollman.Pq ip.ttl
204a2cc1fa2SGarrett WollmanInteger: default time-to-live
205a2cc1fa2SGarrett Wollman.Pq Dq TTL
206a2cc1fa2SGarrett Wollmanto use for outgoing
207a2cc1fa2SGarrett Wollman.Tn IP
208a2cc1fa2SGarrett Wollmanpackets.
2093d140861SRuslan Ermilov.It Dv IPCTL_ACCEPTSOURCEROUTE
2103d140861SRuslan Ermilov.Pq ip.accept_sourceroute
2113d140861SRuslan ErmilovBoolean: enable/disable accepting of source-routed IP packets (default false).
2120e5ca0d8SGarrett Wollman.It Dv IPCTL_SOURCEROUTE
2130e5ca0d8SGarrett Wollman.Pq ip.sourceroute
2140e5ca0d8SGarrett WollmanBoolean: enable/disable forwarding of source-routed IP packets (default false).
215a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTEXPIRE
216a2cc1fa2SGarrett Wollman.Pq ip.rtexpire
217a2cc1fa2SGarrett WollmanInteger: lifetime in seconds of protocol-cloned
218a2cc1fa2SGarrett Wollman.Tn IP
219b5e7e999SRuslan Ermilovroutes after the last reference drops (default one hour).
220b5e7e999SRuslan ErmilovThis value varies dynamically as described above.
221a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTMINEXPIRE
222a2cc1fa2SGarrett Wollman.Pq ip.rtminexpire
223b5e7e999SRuslan ErmilovInteger: minimum value of ip.rtexpire (default ten seconds).
224b5e7e999SRuslan ErmilovThis value has no effect on user modifications, but restricts the dynamic
225a2cc1fa2SGarrett Wollmanadaptation described above.
226a2cc1fa2SGarrett Wollman.It Dv IPCTL_RTMAXCACHE
227a2cc1fa2SGarrett Wollman.Pq ip.rtmaxcache
228a2cc1fa2SGarrett WollmanInteger: trigger level of cached, unreferenced, protocol-cloned routes
229a2cc1fa2SGarrett Wollmanwhich initiates dynamic adaptation (default 128).
230a65cfc98SMaxim Konovalov.It Va ip.process_options
231a65cfc98SMaxim KonovalovInteger: control IP options processing.
232a65cfc98SMaxim KonovalovBy setting this variable to 0, all IP options in the incoming packets
233a65cfc98SMaxim Konovalovwill be ignored, and the packets will be passed unmodified.
234a65cfc98SMaxim KonovalovBy setting to 1, IP options in the incoming packets will be processed
235a65cfc98SMaxim Konovalovaccordingly.
236a65cfc98SMaxim KonovalovBy setting to 2, an
237a65cfc98SMaxim Konovalov.Tn ICMP
238a65cfc98SMaxim Konovalov.Dq "prohibited by filter"
2390af22117SMike Pritchardmessage will be sent back in response to incoming packets with IP options.
240a65cfc98SMaxim KonovalovDefault is 1.
241a65cfc98SMaxim KonovalovThis
242a65cfc98SMaxim Konovalov.Xr sysctl 8
243a65cfc98SMaxim Konovalovvariable affects packets destined for a local host as well as packets
244a65cfc98SMaxim Konovalovforwarded to some other host.
2454892c9a4SMaxim Konovalov.It Va ip.random_id
2464892c9a4SMaxim KonovalovBoolean: control IP IDs generation behaviour.
2474892c9a4SMaxim KonovalovSetting this
2484892c9a4SMaxim Konovalov.Xr sysctl 8
2494892c9a4SMaxim Konovalovto non-zero causes the ID field in IP packets to be randomized instead of
2504892c9a4SMaxim Konovalovincremented by 1 with each packet generated.
2514892c9a4SMaxim KonovalovThis closes a minor information leak which allows remote observers to
2524892c9a4SMaxim Konovalovdetermine the rate of packet generation on the machine by watching the
2534892c9a4SMaxim Konovalovcounter.
254b2df3ab1SMaxim KonovalovIn the same time, on high-speed links, it can decrease the ID reuse
255b2df3ab1SMaxim Konovalovcycle greatly.
2564892c9a4SMaxim KonovalovDefault is 0 (sequential IP IDs).
2574892c9a4SMaxim KonovalovIPv6 flow IDs and fragment IDs are always random.
25805b5066eSMaxim Konovalov.It Va ip.maxfragpackets
25905b5066eSMaxim KonovalovInteger: maximum number of fragmented packets the host will accept and hold
26005b5066eSMaxim Konovalovin the reassembling queue simultaneously.
26105b5066eSMaxim Konovalov0 means that the host will not accept any fragmented packets.
26205b5066eSMaxim Konovalov\-1 means that the host will accept as many fragmented packets as it receives.
26305b5066eSMaxim Konovalov.It Va ip.maxfragsperpacket
26405b5066eSMaxim KonovalovInteger: maximum number of fragments the host will accept and hold
26505b5066eSMaxim Konovalovin the reassembling queue for a packet.
26605b5066eSMaxim Konovalov0 means that the host will not accept any fragmented packets.
267a2cc1fa2SGarrett Wollman.El
268afe61c15SRodney W. Grimes.Sh SEE ALSO
269afe61c15SRodney W. Grimes.Xr ioctl 2 ,
270afe61c15SRodney W. Grimes.Xr socket 2 ,
271c1f9914bSGleb Smirnoff.Xr getifaddrs 3 ,
272a2cc1fa2SGarrett Wollman.Xr sysctl 3 ,
2730b992c1dSWolfram Schneider.Xr icmp 4 ,
274afe61c15SRodney W. Grimes.Xr intro 4 ,
2750b992c1dSWolfram Schneider.Xr ip 4 ,
2760f5d195dSDag-Erling Smørgrav.Xr ipfirewall 4 ,
277bf59255fSAndre Oppermann.Xr route 4 ,
278afe61c15SRodney W. Grimes.Xr tcp 4 ,
279bf59255fSAndre Oppermann.Xr udp 4 ,
280bf59255fSAndre Oppermann.Xr pfil 9
281afe61c15SRodney W. Grimes.Rs
282afe61c15SRodney W. Grimes.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
283afe61c15SRodney W. Grimes.%B PS1
284afe61c15SRodney W. Grimes.%N 7
285afe61c15SRodney W. Grimes.Re
286afe61c15SRodney W. Grimes.Rs
287afe61c15SRodney W. Grimes.%T "An Advanced 4.3 BSD Interprocess Communication Tutorial"
288afe61c15SRodney W. Grimes.%B PS1
289afe61c15SRodney W. Grimes.%N 8
290afe61c15SRodney W. Grimes.Re
291afe61c15SRodney W. Grimes.Sh HISTORY
292afe61c15SRodney W. GrimesThe
293afe61c15SRodney W. Grimes.Nm
294afe61c15SRodney W. Grimesprotocol interface appeared in
295afe61c15SRodney W. Grimes.Bx 4.2 .
296a2cc1fa2SGarrett WollmanThe
297a2cc1fa2SGarrett Wollman.Dq protocol cloning
298a2cc1fa2SGarrett Wollmancode appeared in
29946f84fcbSMike Pritchard.Fx 2.1 .
3000afc94c1SUlrich Spörlein.Sh CAVEATS
3010afc94c1SUlrich SpörleinThe Internet protocol support is subject to change as
3020afc94c1SUlrich Spörleinthe Internet protocols develop.
3030afc94c1SUlrich SpörleinUsers should not depend
3040afc94c1SUlrich Spörleinon details of the current implementation, but rather
3050afc94c1SUlrich Spörleinthe services exported.
306