gpt4 book ai didi

Android 7保留IP端口限制

转载 作者:太空狗 更新时间:2023-10-29 13:53:43 29 4
gpt4 key购买 nike

在 Android 7 中,有一系列保留的 IP 端口。这在文件 /proc/sys/net/ipv4/ip_local_reserved_ports 中指示:32100-32600

我的应用程序使用该范围内的一个端口,我收到错误“绑定(bind):地址已使用”。
所以,我想知道是否有办法绕过这个限制?

我想修改文件并排除我使用的端口。事实上,我已经对我的设备进行了 root 操作,修改了文件,但内核并未接收到更改。即使文件已被修改,如果我重新启动设备,更改也会丢失。

有没有办法绕过这个限制?或者以某种方式强制内核考虑我的更改?

最佳答案

来自 https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt :

ip_local_reserved_ports - list of comma separated ranges
Specify the ports which are reserved for known third-party
applications. These ports will not be used by automatic port
assignments (e.g. when calling connect() or bind() with port
number 0). Explicit port allocation behavior is unchanged.

The format used for both input and output is a comma separated
list of ranges (e.g. "1,2-4,10-10" for ports 1, 2, 3, 4 and
10). Writing to the file will clear all previously reserved
ports and update the current list with the one given in the
input.

Note that ip_local_port_range and ip_local_reserved_ports
settings are independent and both are considered by the kernel
when determining which ports are available for automatic port
assignments.

You can reserve ports which are not in the current
ip_local_port_range, e.g.:

$ cat /proc/sys/net/ipv4/ip_local_port_range
32000 60999
$ cat /proc/sys/net/ipv4/ip_local_reserved_ports
8080,9148

although this is redundant. However such a setting is useful
if later the port range is changed to a value that will
include the reserved ports.

Default: Empty

So, I wanted to know if there is a way around this restriction?

我建议您使用不同的端口,否则您的系统可能会变得不稳定,因为系统服务可能正在使用该保留范围内的端口。

Is there a way to circumvent this restriction? Or somehow force the kernel to take into account my changes?

由于您已对设备进行 root,因此您可以尝试 sysctl。这些链接可能会有所帮助:Android Edit Sysctl Settingshttps://forum.xda-developers.com/showthread.php?t=1470125 .

关于Android 7保留IP端口限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42112735/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com