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