]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.socket.xml
random-util: Add an environment variable to disable RDRAND.
[thirdparty/systemd.git] / man / systemd.socket.xml
CommitLineData
514094f9 1<?xml version='1.0'?>
3a54a157 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
12b42c76 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
0307f791 4<!-- SPDX-License-Identifier: LGPL-2.1+ -->
1f812fea
LP
5
6<refentry id="systemd.socket">
798d3a52
ZJS
7 <refentryinfo>
8 <title>systemd.socket</title>
9 <productname>systemd</productname>
798d3a52
ZJS
10 </refentryinfo>
11
12 <refmeta>
13 <refentrytitle>systemd.socket</refentrytitle>
14 <manvolnum>5</manvolnum>
15 </refmeta>
16
17 <refnamediv>
18 <refname>systemd.socket</refname>
19 <refpurpose>Socket unit configuration</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23 <para><filename><replaceable>socket</replaceable>.socket</filename></para>
24 </refsynopsisdiv>
25
26 <refsect1>
27 <title>Description</title>
28
29 <para>A unit configuration file whose name ends in
30 <literal>.socket</literal> encodes information about an IPC or
31 network socket or a file system FIFO controlled and supervised by
32 systemd, for socket-based activation.</para>
33
34 <para>This man page lists the configuration options specific to
35 this unit type. See
36 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
37 for the common options of all unit configuration files. The common
bdac5608
ZJS
38 configuration items are configured in the generic [Unit] and
39 [Install] sections. The socket specific configuration options are
40 configured in the [Socket] section.</para>
798d3a52
ZJS
41
42 <para>Additional options are listed in
43 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
44 which define the execution environment the
45 <option>ExecStartPre=</option>, <option>ExecStartPost=</option>,
46 <option>ExecStopPre=</option> and <option>ExecStopPost=</option>
47 commands are executed in, and in
48 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
49 which define the way the processes are terminated, and in
50 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
51 which configure resource control settings for the processes of the
52 socket.</para>
53
847af199 54 <para>For each socket unit, a matching service unit must exist,
798d3a52
ZJS
55 describing the service to start on incoming traffic on the socket
56 (see
57 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
847af199 58 for more information about .service units). The name of the
798d3a52
ZJS
59 .service unit is by default the same as the name of the .socket
60 unit, but can be altered with the <option>Service=</option> option
61 described below. Depending on the setting of the
62 <option>Accept=</option> option described below, this .service
63 unit must either be named like the .socket unit, but with the
64 suffix replaced, unless overridden with <option>Service=</option>;
65 or it must be a template unit named the same way. Example: a
66 socket file <filename>foo.socket</filename> needs a matching
67 service <filename>foo.service</filename> if
964c4eda 68 <option>Accept=no</option> is set. If
847af199 69 <option>Accept=yes</option> is set, a service template
798d3a52
ZJS
70 <filename>foo@.service</filename> must exist from which services
71 are instantiated for each incoming connection.</para>
72
45f09f93 73 <para>No implicit <varname>WantedBy=</varname> or
798d3a52
ZJS
74 <varname>RequiredBy=</varname> dependency from the socket to the
75 service is added. This means that the service may be started
76 without the socket, in which case it must be able to open sockets
77 by itself. To prevent this, an explicit
78 <varname>Requires=</varname> dependency may be added.</para>
79
80 <para>Socket units may be used to implement on-demand starting of
81 services, as well as parallelized starting of services. See the
82 blog stories linked at the end for an introduction.</para>
83
df2f5817
LP
84 <para>Note that the daemon software configured for socket activation with socket units needs to be able
85 to accept sockets from systemd, either via systemd's native socket passing interface (see
86 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry> for
87 details about the precise protocol used and the order in which the file descriptors are passed) or via
88 traditional <citerefentry
89 project='freebsd'><refentrytitle>inetd</refentrytitle><manvolnum>8</manvolnum></citerefentry>-style
90 socket passing (i.e. sockets passed in via standard input and output, using
91 <varname>StandardInput=socket</varname> in the service file).</para>
48e6dd37
LP
92
93 <para>All network sockets allocated through <filename>.socket</filename> units are allocated in the host's network
94 namespace (see <citerefentry
95 project='man-pages'><refentrytitle>network_namespaces</refentrytitle><manvolnum>7</manvolnum></citerefentry>). This
96 does not mean however that the service activated by a configured socket unit has to be part of the host's network
97 namespace as well. It is supported and even good practice to run services in their own network namespace (for
98 example through <varname>PrivateNetwork=</varname>, see
99 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>), receiving only
100 the sockets configured through socket-activation from the host's namespace. In such a set-up communication within
101 the host's network namespace is only permitted through the activation sockets passed in while all sockets allocated
102 from the service code itself will be associated with the service's own namespace, and thus possibly subject to a a
103 much more restrictive configuration.</para>
798d3a52
ZJS
104 </refsect1>
105
c129bd5d 106 <refsect1>
aed5cb03
ZJS
107 <title>Automatic Dependencies</title>
108
109 <refsect2>
110 <title>Implicit Dependencies</title>
111
112 <para>The following dependencies are implicitly added:</para>
113
114 <itemizedlist>
115 <listitem><para>Socket units automatically gain a <varname>Before=</varname>
116 dependency on the service units they activate.</para></listitem>
117
e9dd6984
ZJS
118 <listitem><para>Socket units referring to file system paths (such as <constant>AF_UNIX</constant>
119 sockets or FIFOs) implicitly gain <varname>Requires=</varname> and <varname>After=</varname>
120 dependencies on all mount units necessary to access those paths.</para></listitem>
aed5cb03
ZJS
121
122 <listitem><para>Socket units using the <varname>BindToDevice=</varname>
123 setting automatically gain a <varname>BindsTo=</varname> and
124 <varname>After=</varname> dependency on the device unit
125 encapsulating the specified network interface.</para></listitem>
126 </itemizedlist>
127
128 <para>Additional implicit dependencies may be added as result of
129 execution and resource control parameters as documented in
130 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
131 and
132 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
133 </refsect2>
134
135 <refsect2>
136 <title>Default Dependencies</title>
137
138 <para>The following dependencies are added unless
139 <varname>DefaultDependencies=no</varname> is set:</para>
140
141 <itemizedlist>
142 <listitem><para>Socket units automatically gain a
143 <varname>Before=</varname> dependency on
144 <filename>sockets.target</filename>.</para></listitem>
145
146 <listitem><para>Socket units automatically gain a pair of
147 <varname>After=</varname> and <varname>Requires=</varname>
148 dependency on <filename>sysinit.target</filename>, and a pair of
149 <varname>Before=</varname> and <varname>Conflicts=</varname>
150 dependencies on <filename>shutdown.target</filename>. These
151 dependencies ensure that the socket unit is started before normal
152 services at boot, and is stopped on shutdown. Only sockets
153 involved with early boot or late system shutdown should disable
154 <varname>DefaultDependencies=</varname> option.</para></listitem>
155 </itemizedlist>
156 </refsect2>
45f09f93
JL
157 </refsect1>
158
798d3a52
ZJS
159 <refsect1>
160 <title>Options</title>
161
162 <para>Socket files must include a [Socket] section, which carries
163 information about the socket or FIFO it supervises. A number of
164 options that may be used in this section are shared with other
165 unit types. These options are documented in
166 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
167 and
168 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
169 The options specific to the [Socket] section of socket units are
170 the following:</para>
171
172 <variablelist class='unit-directives'>
173 <varlistentry>
174 <term><varname>ListenStream=</varname></term>
175 <term><varname>ListenDatagram=</varname></term>
176 <term><varname>ListenSequentialPacket=</varname></term>
177 <listitem><para>Specifies an address to listen on for a stream
178 (<constant>SOCK_STREAM</constant>), datagram
179 (<constant>SOCK_DGRAM</constant>), or sequential packet
180 (<constant>SOCK_SEQPACKET</constant>) socket, respectively.
181 The address can be written in various formats:</para>
182
183 <para>If the address starts with a slash
184 (<literal>/</literal>), it is read as file system socket in
185 the <constant>AF_UNIX</constant> socket family.</para>
186
187 <para>If the address starts with an at symbol
188 (<literal>@</literal>), it is read as abstract namespace
189 socket in the <constant>AF_UNIX</constant> family. The
190 <literal>@</literal> is replaced with a
191 <constant>NUL</constant> character before binding. For
192 details, see
193 <citerefentry project='man-pages'><refentrytitle>unix</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
194
195 <para>If the address string is a single number, it is read as
196 port number to listen on via IPv6. Depending on the value of
197 <varname>BindIPv6Only=</varname> (see below) this might result
198 in the service being available via both IPv6 and IPv4
199 (default) or just via IPv6.
200 </para>
201
202 <para>If the address string is a string in the format
69e3234d 203 <literal><replaceable>v.w.x.y</replaceable>:<replaceable>z</replaceable></literal>, it is interpreted
a07ab56a 204 as IPv4 address <replaceable>v.w.x.y</replaceable> and port <replaceable>z</replaceable>.</para>
798d3a52 205
a07ab56a
ZJS
206 <para>If the address string is a string in the format
207 <literal>[<replaceable>x</replaceable>]:<replaceable>y</replaceable></literal>, it is interpreted as
208 IPv6 address <replaceable>x</replaceable> and port <replaceable>y</replaceable>. An optional
69e3234d 209 interface scope (interface name or number) may be specified after a <literal>%</literal> symbol:
a07ab56a
ZJS
210 <literal>[<replaceable>x</replaceable>]:<replaceable>y</replaceable>%<replaceable>dev</replaceable></literal>.
211 Interface scopes are only useful with link-local addresses, because the kernel ignores them in other
212 cases. Note that if an address is specified as IPv6, it might still make the service available via
213 IPv4 too, depending on the <varname>BindIPv6Only=</varname> setting (see below).</para>
798d3a52 214
359a5bcf 215 <para>If the address string is a string in the format
a07ab56a
ZJS
216 <literal>vsock:<replaceable>x</replaceable>:<replaceable>y</replaceable></literal>, it is read as CID
217 <replaceable>x</replaceable> on a port <replaceable>y</replaceable> address in the
218 <constant>AF_VSOCK</constant> family. The CID is a unique 32-bit integer identifier in
219 <constant>AF_VSOCK</constant> analogous to an IP address. Specifying the CID is optional, and may be
220 set to the empty string.</para>
359a5bcf 221
798d3a52
ZJS
222 <para>Note that <constant>SOCK_SEQPACKET</constant> (i.e.
223 <varname>ListenSequentialPacket=</varname>) is only available
224 for <constant>AF_UNIX</constant> sockets.
225 <constant>SOCK_STREAM</constant> (i.e.
226 <varname>ListenStream=</varname>) when used for IP sockets
227 refers to TCP sockets, <constant>SOCK_DGRAM</constant> (i.e.
228 <varname>ListenDatagram=</varname>) to UDP.</para>
229
b938cb90 230 <para>These options may be specified more than once, in which
798d3a52
ZJS
231 case incoming traffic on any of the sockets will trigger
232 service activation, and all listed sockets will be passed to
233 the service, regardless of whether there is incoming traffic
234 on them or not. If the empty string is assigned to any of
235 these options, the list of addresses to listen on is reset,
236 all prior uses of any of these options will have no
237 effect.</para>
238
239 <para>It is also possible to have more than one socket unit
240 for the same service when using <varname>Service=</varname>,
241 and the service will receive all the sockets configured in all
242 the socket units. Sockets configured in one unit are passed in
243 the order of configuration, but no ordering between socket
244 units is specified.</para>
245
246 <para>If an IP address is used here, it is often desirable to
247 listen on it before the interface it is configured on is up
248 and running, and even regardless of whether it will be up and
249 running at any point. To deal with this, it is recommended to
250 set the <varname>FreeBind=</varname> option described
251 below.</para></listitem>
252 </varlistentry>
253
254 <varlistentry>
255 <term><varname>ListenFIFO=</varname></term>
256 <listitem><para>Specifies a file system FIFO to listen on.
257 This expects an absolute file system path as argument.
258 Behavior otherwise is very similar to the
259 <varname>ListenDatagram=</varname> directive
260 above.</para></listitem>
261 </varlistentry>
262
263 <varlistentry>
264 <term><varname>ListenSpecial=</varname></term>
265 <listitem><para>Specifies a special file in the file system to
266 listen on. This expects an absolute file system path as
267 argument. Behavior otherwise is very similar to the
268 <varname>ListenFIFO=</varname> directive above. Use this to
269 open character device nodes as well as special files in
270 <filename>/proc</filename> and
271 <filename>/sys</filename>.</para></listitem>
272 </varlistentry>
273
274 <varlistentry>
275 <term><varname>ListenNetlink=</varname></term>
276 <listitem><para>Specifies a Netlink family to create a socket
277 for to listen on. This expects a short string referring to the
278 <constant>AF_NETLINK</constant> family name (such as
279 <varname>audit</varname> or <varname>kobject-uevent</varname>)
280 as argument, optionally suffixed by a whitespace followed by a
281 multicast group integer. Behavior otherwise is very similar to
282 the <varname>ListenDatagram=</varname> directive
283 above.</para></listitem>
284 </varlistentry>
285
286 <varlistentry>
287 <term><varname>ListenMessageQueue=</varname></term>
288 <listitem><para>Specifies a POSIX message queue name to listen
289 on. This expects a valid message queue name (i.e. beginning
290 with /). Behavior otherwise is very similar to the
291 <varname>ListenFIFO=</varname> directive above. On Linux
292 message queue descriptors are actually file descriptors and
293 can be inherited between processes.</para></listitem>
294 </varlistentry>
295
8c7c9839
PS
296 <varlistentry>
297 <term><varname>ListenUSBFunction=</varname></term>
3d314510
LP
298 <listitem><para>Specifies a <ulink
299 url="https://www.kernel.org/doc/Documentation/usb/functionfs.txt">USB
00bb64ec 300 FunctionFS</ulink> endpoints location to listen on, for
3d314510 301 implementation of USB gadget functions. This expects an
e9dd6984 302 absolute file system path of FunctionFS mount point as the argument.
00bb64ec 303 Behavior otherwise is very similar to the <varname>ListenFIFO=</varname>
a8eaaee7 304 directive above. Use this to open the FunctionFS endpoint
3d314510
LP
305 <filename>ep0</filename>. When using this option, the
306 activated service has to have the
22065311
ZJS
307 <varname>USBFunctionDescriptors=</varname> and
308 <varname>USBFunctionStrings=</varname> options set.
81eb21b9 309 </para></listitem>
8c7c9839
PS
310 </varlistentry>
311
74bb646e
SS
312 <varlistentry>
313 <term><varname>SocketProtocol=</varname></term>
a7c64e14 314 <listitem><para>Takes one of <option>udplite</option>
e9dd6984
ZJS
315 or <option>sctp</option>. The socket will use the UDP-Lite
316 (<constant>IPPROTO_UDPLITE</constant>) or SCTP
317 (<constant>IPPROTO_SCTP</constant>) protocol, respectively.</para>
74bb646e
SS
318 </listitem>
319 </varlistentry>
320
798d3a52
ZJS
321 <varlistentry>
322 <term><varname>BindIPv6Only=</varname></term>
a7c64e14 323 <listitem><para>Takes one of <option>default</option>,
798d3a52
ZJS
324 <option>both</option> or <option>ipv6-only</option>. Controls
325 the IPV6_V6ONLY socket option (see
3ba3a79d 326 <citerefentry project='die-net'><refentrytitle>ipv6</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
327 for details). If <option>both</option>, IPv6 sockets bound
328 will be accessible via both IPv4 and IPv6. If
329 <option>ipv6-only</option>, they will be accessible via IPv6
330 only. If <option>default</option> (which is the default,
331 surprise!), the system wide default setting is used, as
332 controlled by
333 <filename>/proc/sys/net/ipv6/bindv6only</filename>, which in
334 turn defaults to the equivalent of
335 <option>both</option>.</para>
336 </listitem>
337 </varlistentry>
338
339 <varlistentry>
340 <term><varname>Backlog=</varname></term>
341 <listitem><para>Takes an unsigned integer argument. Specifies
342 the number of connections to queue that have not been accepted
343 yet. This setting matters only for stream and sequential
344 packet sockets. See
345 <citerefentry><refentrytitle>listen</refentrytitle><manvolnum>2</manvolnum></citerefentry>
346 for details. Defaults to SOMAXCONN (128).</para></listitem>
347 </varlistentry>
348
349 <varlistentry>
350 <term><varname>BindToDevice=</varname></term>
e9dd6984
ZJS
351 <listitem><para>Specifies a network interface name to bind this socket to. If set, traffic will only
352 be accepted from the specified network interfaces. This controls the
353 <constant>SO_BINDTODEVICE</constant> socket option (see <citerefentry
354 project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
355 details). If this option is used, an implicit dependency from this socket unit on the network
356 interface device unit is created
357 (see <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
358 Note that setting this parameter might result in additional dependencies to be added to the unit (see
c129bd5d 359 above).</para></listitem>
798d3a52
ZJS
360 </varlistentry>
361
362 <varlistentry>
363 <term><varname>SocketUser=</varname></term>
364 <term><varname>SocketGroup=</varname></term>
365
e9dd6984
ZJS
366 <listitem><para>Takes a UNIX user/group name. When specified, all <constant>AF_UNIX</constant>
367 sockets and FIFO nodes in the file system are owned by the specified user and group. If unset (the
368 default), the nodes are owned by the root user/group (if run in system context) or the invoking
369 user/group (if run in user context). If only a user is specified but no group, then the group is
798d3a52
ZJS
370 derived from the user's default group.</para></listitem>
371 </varlistentry>
372
373 <varlistentry>
374 <term><varname>SocketMode=</varname></term>
375 <listitem><para>If listening on a file system socket or FIFO,
376 this option specifies the file system access mode used when
377 creating the file node. Takes an access mode in octal
378 notation. Defaults to 0666.</para></listitem>
379 </varlistentry>
380
381 <varlistentry>
382 <term><varname>DirectoryMode=</varname></term>
383 <listitem><para>If listening on a file system socket or FIFO,
384 the parent directories are automatically created if needed.
385 This option specifies the file system access mode used when
386 creating these directories. Takes an access mode in octal
387 notation. Defaults to 0755.</para></listitem>
388 </varlistentry>
389
390 <varlistentry>
391 <term><varname>Accept=</varname></term>
1bdecfb8 392 <listitem><para>Takes a boolean argument. If yes, a service
798d3a52 393 instance is spawned for each incoming connection and only the
1bdecfb8 394 connection socket is passed to it. If no, all listening
798d3a52
ZJS
395 sockets themselves are passed to the started service unit, and
396 only one service unit is spawned for all connections (also see
397 above). This value is ignored for datagram sockets and FIFOs
398 where a single service unit unconditionally handles all
1bdecfb8 399 incoming traffic. Defaults to <option>no</option>. For
798d3a52
ZJS
400 performance reasons, it is recommended to write new daemons
401 only in a way that is suitable for
964c4eda 402 <option>Accept=no</option>. A daemon listening on an
798d3a52
ZJS
403 <constant>AF_UNIX</constant> socket may, but does not need to,
404 call
405 <citerefentry><refentrytitle>close</refentrytitle><manvolnum>2</manvolnum></citerefentry>
406 on the received socket before exiting. However, it must not
407 unlink the socket from a file system. It should not invoke
408 <citerefentry><refentrytitle>shutdown</refentrytitle><manvolnum>2</manvolnum></citerefentry>
964c4eda 409 on sockets it got with <varname>Accept=no</varname>, but it
798d3a52 410 may do so for sockets it got with
964c4eda
LP
411 <varname>Accept=yes</varname> set. Setting
412 <varname>Accept=yes</varname> is mostly useful to allow
798d3a52 413 daemons designed for usage with
b5c7d097 414 <citerefentry project='freebsd'><refentrytitle>inetd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52 415 to work unmodified with systemd socket
3b1c5241
SL
416 activation.</para>
417
e9dd6984
ZJS
418 <para>For IPv4 and IPv6 connections, the <varname>REMOTE_ADDR</varname> environment variable will
419 contain the remote IP address, and <varname>REMOTE_PORT</varname> will contain the remote port. This
420 is the same as the format used by CGI. For <constant>SOCK_RAW</constant>, the port is the IP
421 protocol.</para></listitem>
798d3a52
ZJS
422 </varlistentry>
423
55301ec0
LP
424 <varlistentry>
425 <term><varname>Writable=</varname></term>
426 <listitem><para>Takes a boolean argument. May only be used in
427 conjunction with <varname>ListenSpecial=</varname>. If true,
428 the specified special file is opened in read-write mode, if
b938cb90 429 false, in read-only mode. Defaults to false.</para></listitem>
55301ec0
LP
430 </varlistentry>
431
3e5f04bf
RM
432 <varlistentry>
433 <term><varname>FlushPending=</varname></term>
434 <listitem><para>Takes a boolean argument. May only be used when
435 <option>Accept=no</option>. If yes, the socket's buffers are cleared after the
436 triggered service exited. This causes any pending data to be
437 flushed and any pending incoming connections to be rejected. If no, the
438 socket's buffers won't be cleared, permitting the service to handle any
439 pending connections after restart, which is the usually expected behaviour.
440 Defaults to <option>no</option>.
441 </para></listitem>
442 </varlistentry>
443
798d3a52
ZJS
444 <varlistentry>
445 <term><varname>MaxConnections=</varname></term>
446 <listitem><para>The maximum number of connections to
447 simultaneously run services instances for, when
964c4eda 448 <option>Accept=yes</option> is set. If more concurrent
798d3a52
ZJS
449 connections are coming in, they will be refused until at least
450 one existing connection is terminated. This setting has no
451 effect on sockets configured with
964c4eda 452 <option>Accept=no</option> or datagram sockets. Defaults to
798d3a52
ZJS
453 64.</para></listitem>
454 </varlistentry>
455
456 <varlistentry>
9d565427
SS
457 <term><varname>MaxConnectionsPerSource=</varname></term>
458 <listitem><para>The maximum number of connections for a service per source IP address.
cfaf4b75 459 This is very similar to the <varname>MaxConnections=</varname> directive
9d565427
SS
460 above. Disabled by default.</para>
461 </listitem>
462 </varlistentry>
463
464 <varlistentry>
798d3a52 465 <term><varname>KeepAlive=</varname></term>
e9dd6984
ZJS
466 <listitem><para>Takes a boolean argument. If true, the TCP/IP stack will send a keep alive message
467 after 2h (depending on the configuration of
468 <filename>/proc/sys/net/ipv4/tcp_keepalive_time</filename>) for all TCP streams accepted on this
469 socket. This controls the <constant>SO_KEEPALIVE</constant> socket option (see <citerefentry
470 project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry> and
471 the <ulink url="http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/">TCP Keepalive
472 HOWTO</ulink> for details.) Defaults to <option>false</option>.</para></listitem>
798d3a52
ZJS
473 </varlistentry>
474
475 <varlistentry>
476 <term><varname>KeepAliveTimeSec=</varname></term>
b938cb90 477 <listitem><para>Takes time (in seconds) as argument. The connection needs to remain
798d3a52
ZJS
478 idle before TCP starts sending keepalive probes. This controls the TCP_KEEPIDLE
479 socket option (see
3ba3a79d 480 <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
481 and the <ulink
482 url="http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/">TCP
483 Keepalive HOWTO</ulink> for details.)
484 Defaults value is 7200 seconds (2 hours).</para></listitem>
485 </varlistentry>
486
487 <varlistentry>
488 <term><varname>KeepAliveIntervalSec=</varname></term>
e9dd6984
ZJS
489 <listitem><para>Takes time (in seconds) as argument between individual keepalive probes, if the
490 socket option <constant>SO_KEEPALIVE</constant> has been set on this socket. This controls the
491 <constant>TCP_KEEPINTVL</constant> socket option (see <citerefentry
492 project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry> and
493 the <ulink url="http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/">TCP Keepalive
494 HOWTO</ulink> for details.) Defaults value is 75 seconds.</para></listitem>
798d3a52
ZJS
495 </varlistentry>
496
497 <varlistentry>
498 <term><varname>KeepAliveProbes=</varname></term>
7ca41557 499 <listitem><para>Takes an integer as argument. It is the number of
798d3a52
ZJS
500 unacknowledged probes to send before considering the
501 connection dead and notifying the application layer. This
502 controls the TCP_KEEPCNT socket option (see
3ba3a79d 503 <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
504 and the <ulink
505 url="http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/">TCP
506 Keepalive HOWTO</ulink> for details.) Defaults value is
507 9.</para></listitem>
508 </varlistentry>
509
510 <varlistentry>
511 <term><varname>NoDelay=</varname></term>
512 <listitem><para>Takes a boolean argument. TCP Nagle's
513 algorithm works by combining a number of small outgoing
514 messages, and sending them all at once. This controls the
515 TCP_NODELAY socket option (see
e9dd6984 516 <citerefentry project='die-net'><refentrytitle>tcp</refentrytitle><manvolnum>7</manvolnum></citerefentry>).
798d3a52
ZJS
517 Defaults to <option>false</option>.</para></listitem>
518 </varlistentry>
519
520 <varlistentry>
521 <term><varname>Priority=</varname></term>
e9dd6984
ZJS
522 <listitem><para>Takes an integer argument controlling the priority for all traffic sent from this
523 socket. This controls the <constant>SO_PRIORITY</constant> socket option (see <citerefentry
524 project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
525 details.).</para></listitem>
798d3a52
ZJS
526 </varlistentry>
527
528 <varlistentry>
529 <term><varname>DeferAcceptSec=</varname></term>
530
531 <listitem><para>Takes time (in seconds) as argument. If set,
532 the listening process will be awakened only when data arrives
533 on the socket, and not immediately when connection is
534 established. When this option is set, the
535 <constant>TCP_DEFER_ACCEPT</constant> socket option will be
536 used (see
3ba3a79d 537 <citerefentry project='die-net'><refentrytitle>tcp</refentrytitle><manvolnum>7</manvolnum></citerefentry>),
798d3a52
ZJS
538 and the kernel will ignore initial ACK packets without any
539 data. The argument specifies the approximate amount of time
540 the kernel should wait for incoming data before falling back
2dd67817 541 to the normal behavior of honoring empty ACK packets. This
798d3a52
ZJS
542 option is beneficial for protocols where the client sends the
543 data first (e.g. HTTP, in contrast to SMTP), because the
544 server process will not be woken up unnecessarily before it
545 can take any action.
546 </para>
547
548 <para>If the client also uses the
549 <constant>TCP_DEFER_ACCEPT</constant> option, the latency of
550 the initial connection may be reduced, because the kernel will
551 send data in the final packet establishing the connection (the
552 third packet in the "three-way handshake").</para>
553
554 <para>Disabled by default.</para>
555 </listitem>
556 </varlistentry>
557
558 <varlistentry>
559 <term><varname>ReceiveBuffer=</varname></term>
560 <term><varname>SendBuffer=</varname></term>
e9dd6984
ZJS
561 <listitem><para>Takes an integer argument controlling the receive or send buffer sizes of this
562 socket, respectively. This controls the <constant>SO_RCVBUF</constant> and
563 <constant>SO_SNDBUF</constant> socket options (see <citerefentry
564 project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
565 details.). The usual suffixes K, M, G are supported and are understood to the base of
566 1024.</para></listitem>
798d3a52
ZJS
567 </varlistentry>
568
569 <varlistentry>
570 <term><varname>IPTOS=</varname></term>
c6a79245
LP
571 <listitem><para>Takes an integer argument controlling the IP Type-Of-Service field for packets
572 generated from this socket. This controls the <constant>IP_TOS</constant> socket option (see
573 <citerefentry
574 project='die-net'><refentrytitle>ip</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
575 details.). Either a numeric string or one of <option>low-delay</option>, <option>throughput</option>,
576 <option>reliability</option> or <option>low-cost</option> may be specified.</para></listitem>
798d3a52
ZJS
577 </varlistentry>
578
579 <varlistentry>
580 <term><varname>IPTTL=</varname></term>
c6a79245
LP
581 <listitem><para>Takes an integer argument controlling the IPv4 Time-To-Live/IPv6 Hop-Count field for
582 packets generated from this socket. This sets the
583 <constant>IP_TTL</constant>/<constant>IPV6_UNICAST_HOPS</constant> socket options (see <citerefentry
584 project='die-net'><refentrytitle>ip</refentrytitle><manvolnum>7</manvolnum></citerefentry> and
585 <citerefentry
586 project='die-net'><refentrytitle>ipv6</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
587 details.)</para></listitem>
798d3a52
ZJS
588 </varlistentry>
589
590 <varlistentry>
591 <term><varname>Mark=</varname></term>
e9dd6984
ZJS
592 <listitem><para>Takes an integer value. Controls the firewall mark of packets generated by this
593 socket. This can be used in the firewall logic to filter packets from this socket. This sets the
594 <constant>SO_MARK</constant> socket option. See <citerefentry
595 project='die-net'><refentrytitle>iptables</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
596 details.</para></listitem>
798d3a52
ZJS
597 </varlistentry>
598
599 <varlistentry>
600 <term><varname>ReusePort=</varname></term>
e9dd6984
ZJS
601 <listitem><para>Takes a boolean value. If true, allows multiple
602 <citerefentry><refentrytitle>bind</refentrytitle><manvolnum>2</manvolnum></citerefentry>s to this TCP
603 or UDP port. This controls the <constant>SO_REUSEPORT</constant> socket option. See <citerefentry
604 project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
605 details.</para></listitem>
798d3a52
ZJS
606 </varlistentry>
607
608 <varlistentry>
609 <term><varname>SmackLabel=</varname></term>
610 <term><varname>SmackLabelIPIn=</varname></term>
611 <term><varname>SmackLabelIPOut=</varname></term>
612 <listitem><para>Takes a string value. Controls the extended
613 attributes <literal>security.SMACK64</literal>,
614 <literal>security.SMACK64IPIN</literal> and
615 <literal>security.SMACK64IPOUT</literal>, respectively, i.e.
616 the security label of the FIFO, or the security label for the
617 incoming or outgoing connections of the socket, respectively.
618 See <ulink
619 url="https://www.kernel.org/doc/Documentation/security/Smack.txt">Smack.txt</ulink>
620 for details.</para></listitem>
621 </varlistentry>
622
623 <varlistentry>
624 <term><varname>SELinuxContextFromNet=</varname></term>
625 <listitem><para>Takes a boolean argument. When true, systemd
626 will attempt to figure out the SELinux label used for the
627 instantiated service from the information handed by the peer
628 over the network. Note that only the security level is used
629 from the information provided by the peer. Other parts of the
630 resulting SELinux context originate from either the target
631 binary that is effectively triggered by socket unit or from
632 the value of the <varname>SELinuxContext=</varname> option.
633 This configuration option only affects sockets with
634 <varname>Accept=</varname> mode set to
1bdecfb8 635 <literal>yes</literal>. Also note that this option is useful
798d3a52
ZJS
636 only when MLS/MCS SELinux policy is deployed. Defaults to
637 <literal>false</literal>. </para></listitem>
638 </varlistentry>
639
640 <varlistentry>
641 <term><varname>PipeSize=</varname></term>
642 <listitem><para>Takes a size in bytes. Controls the pipe
643 buffer size of FIFOs configured in this socket unit. See
644 <citerefentry><refentrytitle>fcntl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
645 for details. The usual suffixes K, M, G are supported and are
646 understood to the base of 1024.</para></listitem>
647 </varlistentry>
648
649 <varlistentry>
650 <term><varname>MessageQueueMaxMessages=</varname>,
651 <varname>MessageQueueMessageSize=</varname></term>
652 <listitem><para>These two settings take integer values and
653 control the mq_maxmsg field or the mq_msgsize field,
654 respectively, when creating the message queue. Note that
655 either none or both of these variables need to be set. See
3ba3a79d 656 <citerefentry project='die-net'><refentrytitle>mq_setattr</refentrytitle><manvolnum>3</manvolnum></citerefentry>
798d3a52
ZJS
657 for details.</para></listitem>
658 </varlistentry>
659
660 <varlistentry>
661 <term><varname>FreeBind=</varname></term>
c6a79245
LP
662 <listitem><para>Takes a boolean value. Controls whether the socket can be bound to non-local IP
663 addresses. This is useful to configure sockets listening on specific IP addresses before those IP
664 addresses are successfully configured on a network interface. This sets the
665 <constant>IP_FREEBIND</constant>/<constant>IPV6_FREEBIND</constant> socket option. For robustness
666 reasons it is recommended to use this option whenever you bind a socket to a specific IP
667 address. Defaults to <option>false</option>.</para></listitem>
798d3a52
ZJS
668 </varlistentry>
669
670 <varlistentry>
671 <term><varname>Transparent=</varname></term>
672 <listitem><para>Takes a boolean value. Controls the
c6a79245 673 <constant>IP_TRANSPARENT</constant>/<constant>IPV6_TRANSPARENT</constant> socket option. Defaults to
798d3a52
ZJS
674 <option>false</option>.</para></listitem>
675 </varlistentry>
676
677 <varlistentry>
678 <term><varname>Broadcast=</varname></term>
e9dd6984
ZJS
679 <listitem><para>Takes a boolean value. This controls the <constant>SO_BROADCAST</constant> socket
680 option, which allows broadcast datagrams to be sent from this socket. Defaults to
798d3a52
ZJS
681 <option>false</option>.</para></listitem>
682 </varlistentry>
683
684 <varlistentry>
685 <term><varname>PassCredentials=</varname></term>
e9dd6984
ZJS
686 <listitem><para>Takes a boolean value. This controls the <constant>SO_PASSCRED</constant> socket
687 option, which allows <constant>AF_UNIX</constant> sockets to receive the credentials of the sending
688 process in an ancillary message. Defaults to <option>false</option>.</para></listitem>
798d3a52
ZJS
689 </varlistentry>
690
691 <varlistentry>
692 <term><varname>PassSecurity=</varname></term>
e9dd6984
ZJS
693 <listitem><para>Takes a boolean value. This controls the <constant>SO_PASSSEC</constant> socket
694 option, which allows <constant>AF_UNIX</constant> sockets to receive the security context of the
695 sending process in an ancillary message. Defaults to <option>false</option>.</para></listitem>
798d3a52
ZJS
696 </varlistentry>
697
a3d19f5d
LP
698 <varlistentry>
699 <term><varname>PassPacketInfo=</varname></term>
700 <listitem><para>Takes a boolean value. This controls the <constant>IP_PKTINFO</constant>,
701 <constant>IPV6_RECVPKTINFO</constant> and <constant>NETLINK_PKTINFO</constant> socket options, which
702 enable reception of additional per-packet metadata as ancillary message, on
703 <constant>AF_INET</constant>, <constant>AF_INET6</constant> and <constant>AF_UNIX</constant> sockets.
704 Defaults to <option>false</option>.</para></listitem>
705 </varlistentry>
706
798d3a52
ZJS
707 <varlistentry>
708 <term><varname>TCPCongestion=</varname></term>
e9dd6984
ZJS
709 <listitem><para>Takes a string value. Controls the TCP congestion algorithm used by this
710 socket. Should be one of <literal>westwood</literal>, <literal>veno</literal>,
711 <literal>cubic</literal>, <literal>lp</literal> or any other available algorithm supported by the IP
712 stack. This setting applies only to stream sockets.</para></listitem>
798d3a52
ZJS
713 </varlistentry>
714
715 <varlistentry>
716 <term><varname>ExecStartPre=</varname></term>
717 <term><varname>ExecStartPost=</varname></term>
718 <listitem><para>Takes one or more command lines, which are
719 executed before or after the listening sockets/FIFOs are
720 created and bound, respectively. The first token of the
721 command line must be an absolute filename, then followed by
722 arguments for the process. Multiple command lines may be
723 specified following the same scheme as used for
724 <varname>ExecStartPre=</varname> of service unit
725 files.</para></listitem>
726 </varlistentry>
727
728 <varlistentry>
729 <term><varname>ExecStopPre=</varname></term>
730 <term><varname>ExecStopPost=</varname></term>
731 <listitem><para>Additional commands that are executed before
732 or after the listening sockets/FIFOs are closed and removed,
733 respectively. Multiple command lines may be specified
734 following the same scheme as used for
735 <varname>ExecStartPre=</varname> of service unit
736 files.</para></listitem>
737 </varlistentry>
738
739 <varlistentry>
740 <term><varname>TimeoutSec=</varname></term>
741 <listitem><para>Configures the time to wait for the commands
742 specified in <varname>ExecStartPre=</varname>,
743 <varname>ExecStartPost=</varname>,
744 <varname>ExecStopPre=</varname> and
745 <varname>ExecStopPost=</varname> to finish. If a command does
746 not exit within the configured time, the socket will be
747 considered failed and be shut down again. All commands still
748 running will be terminated forcibly via
749 <constant>SIGTERM</constant>, and after another delay of this
750 time with <constant>SIGKILL</constant>. (See
751 <option>KillMode=</option> in
752 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>.)
753 Takes a unit-less value in seconds, or a time span value such
754 as "5min 20s". Pass <literal>0</literal> to disable the
755 timeout logic. Defaults to
756 <varname>DefaultTimeoutStartSec=</varname> from the manager
757 configuration file (see
758 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
759 </para></listitem>
760 </varlistentry>
761
762 <varlistentry>
763 <term><varname>Service=</varname></term>
764 <listitem><para>Specifies the service unit name to activate on
765 incoming traffic. This setting is only allowed for sockets
766 with <varname>Accept=no</varname>. It defaults to the service
767 that bears the same name as the socket (with the suffix
768 replaced). In most cases, it should not be necessary to use
c129bd5d
LP
769 this option. Note that setting this parameter might result in
770 additional dependencies to be added to the unit (see
771 above).</para></listitem>
798d3a52
ZJS
772 </varlistentry>
773
774 <varlistentry>
775 <term><varname>RemoveOnStop=</varname></term>
e9dd6984
ZJS
776 <listitem><para>Takes a boolean argument. If enabled, any file nodes created by this socket unit are
777 removed when it is stopped. This applies to <constant>AF_UNIX</constant> sockets in the file system,
778 POSIX message queues, FIFOs, as well as any symlinks to them configured with
779 <varname>Symlinks=</varname>. Normally, it should not be necessary to use this option, and is not
780 recommended as services might continue to run after the socket unit has been terminated and it should
781 still be possible to communicate with them via their file system node. Defaults to
798d3a52
ZJS
782 off.</para></listitem>
783 </varlistentry>
784
785 <varlistentry>
786 <term><varname>Symlinks=</varname></term>
3ecc7fc3
LP
787 <listitem><para>Takes a list of file system paths. The specified paths will be created as symlinks to the
788 <constant>AF_UNIX</constant> socket path or FIFO path of this socket unit. If this setting is used, only one
789 <constant>AF_UNIX</constant> socket in the file system or one FIFO may be configured for the socket unit. Use
790 this option to manage one or more symlinked alias names for a socket, binding their lifecycle together. Note
791 that if creation of a symlink fails this is not considered fatal for the socket unit, and the socket unit may
792 still start. If an empty string is assigned, the list of paths is reset. Defaults to an empty
793 list.</para></listitem>
798d3a52
ZJS
794 </varlistentry>
795
8dd4c05b
LP
796 <varlistentry>
797 <term><varname>FileDescriptorName=</varname></term>
798 <listitem><para>Assigns a name to all file descriptors this
799 socket unit encapsulates. This is useful to help activated
a8eaaee7 800 services identify specific file descriptors, if multiple fds
8dd4c05b
LP
801 are passed. Services may use the
802 <citerefentry><refentrytitle>sd_listen_fds_with_names</refentrytitle><manvolnum>3</manvolnum></citerefentry>
803 call to acquire the names configured for the received file
804 descriptors. Names may contain any ASCII character, but must
a8eaaee7 805 exclude control characters and <literal>:</literal>, and must
8dd4c05b 806 be at most 255 characters in length. If this setting is not
b938cb90 807 used, the file descriptor name defaults to the name of the
8dd4c05b
LP
808 socket unit, including its <filename>.socket</filename>
809 suffix.</para></listitem>
810 </varlistentry>
811
8b26cdbd
LP
812 <varlistentry>
813 <term><varname>TriggerLimitIntervalSec=</varname></term>
db985064 814 <term><varname>TriggerLimitBurst=</varname></term>
8b26cdbd
LP
815
816 <listitem><para>Configures a limit on how often this socket unit my be activated within a specific time
817 interval. The <varname>TriggerLimitIntervalSec=</varname> may be used to configure the length of the time
818 interval in the usual time units <literal>us</literal>, <literal>ms</literal>, <literal>s</literal>,
1f15ce28 819 <literal>min</literal>, <literal>h</literal>, … and defaults to 2s (See
8b26cdbd 820 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> for details on
1f15ce28
LP
821 the various time units understood). The <varname>TriggerLimitBurst=</varname> setting takes a positive integer
822 value and specifies the number of permitted activations per time interval, and defaults to 200 for
823 <varname>Accept=yes</varname> sockets (thus by default permitting 200 activations per 2s), and 20 otherwise (20
824 activations per 2s). Set either to 0 to disable any form of trigger rate limiting. If the limit is hit, the
825 socket unit is placed into a failure mode, and will not be connectible anymore until restarted. Note that this
826 limit is enforced before the service activation is enqueued.</para></listitem>
8b26cdbd
LP
827 </varlistentry>
828
798d3a52
ZJS
829 </variablelist>
830
831 <para>Check
832 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
833 and
834 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>
835 for more settings.</para>
836
837 </refsect1>
838
839 <refsect1>
840 <title>See Also</title>
841 <para>
842 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
843 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
d1698b82 844 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
798d3a52
ZJS
845 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
846 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
847 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
848 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
849 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
8dd4c05b
LP
850 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
851 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
852 <citerefentry><refentrytitle>sd_listen_fds_with_names</refentrytitle><manvolnum>3</manvolnum></citerefentry>
798d3a52 853 </para>
798d3a52
ZJS
854 <para>
855 For more extensive descriptions see the "systemd for Developers" series:
856 <ulink url="http://0pointer.de/blog/projects/socket-activation.html">Socket Activation</ulink>,
857 <ulink url="http://0pointer.de/blog/projects/socket-activation2.html">Socket Activation, part II</ulink>,
858 <ulink url="http://0pointer.de/blog/projects/inetd.html">Converting inetd Services</ulink>,
859 <ulink url="http://0pointer.de/blog/projects/socket-activated-containers.html">Socket Activated Internet Services and OS Containers</ulink>.
860 </para>
861 </refsect1>
1f812fea
LP
862
863</refentry>