【问题标题】:Android 7 reserved IP ports restrictionAndroid 7 保留 IP 端口限制
【发布时间】:2017-04-06 23:40:31
【问题描述】:

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

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

我想修改文件并排除我使用的端口。事实上,我已经植根了我的设备,修改了文件,但内核没有接收到更改。 即使文件已被修改,如果我重新启动设备,更改也会丢失。

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

【问题讨论】:

    标签: android android-7.0-nougat


    【解决方案1】:

    来自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
    

    所以,我想知道是否有办法绕过这个限制?

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

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

    既然你已经植根了你的设备,你可以试试sysctl。这些链接可能会有所帮助:Android Edit Sysctl Settingshttps://forum.xda-developers.com/showthread.php?t=1470125

    【讨论】:

    • 如何查看手机的预留端口?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-05
    • 1970-01-01
    • 1970-01-01
    • 2022-11-05
    • 2017-10-02
    • 2017-08-13
    • 1970-01-01
    相关资源
    最近更新 更多