Debian Codegraph @

upstream/debian-unstable/man2/IP_LOCAL_PORT_RANGE.2const

raw
1 .\" Copyright, the authors of the Linux man-pages project
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .TH IP_LOCAL_PORT_RANGE 2const 2025-11-25 "Linux man-pages 6.18"
6 .SH NAME
7 IP_LOCAL_PORT_RANGE
8 \-
9 default local port range
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .BR "#include <netinet/in.h>" " /* Definition of " IP* " constants */"
16 .B #include <sys/socket.h>
17 .P
18 .BI int\~setsockopt(int\~ sockfd ,\~IPPROTO_IP,\~IP_LOCAL_PORT_RANGE,
19 .BI " const\~uint32_t\~*" val ,\~sizeof(uint32_t));
20 .BI int\~getsockopt(int\~ sockfd ,\~IPPROTO_IP,\~IP_LOCAL_PORT_RANGE,
21 .BI " uint32_t\~*" val ,\~sizeof(uint32_t));
22 .fi
23 .SH DESCRIPTION
24 Set or get the per-socket default local port range.
25 .P
26 This option can be used to clamp down the global local port range,
27 defined by the
28 .I /proc/sys/net/ipv4/ip_local_port_range
29 interface,
30 for a given socket.
31 .P
32 The option takes an
33 .I uint32_t
34 value with
35 the high 16 bits set to the upper range bound,
36 and the low 16 bits set to the lower range bound.
37 Range bounds are inclusive.
38 The 16-bit values should be in host byte order.
39 .P
40 The lower bound has to be less than the upper bound
41 when both bounds are not zero.
42 Otherwise, setting the option fails with EINVAL.
43 .P
44 If either bound is outside of the global local port range, or is zero,
45 then that bound has no effect.
46 .P
47 To reset the setting,
48 pass zero as both the upper and the lower bound.
49 .SH ERRORS
50 See
51 .BR IPPROTO_IP (2const).
52 See
53 .BR setsockopt (2).
54 See
55 .BR ip (7).
56 .SH HISTORY
57 Linux 6.3.
58 .SH SEE ALSO
59 .BR IPPROTO_IP (2const),
60 .BR setsockopt (2),
61 .BR proc_sys_net_ipv4 (5),
62 .BR ip (7)