【转】为什么只有偶数个源端口被指定为短暂的TCP源端口?

https://access.redhat.com/solutions/3307511

Why only even number source ports are assigned as ephemeral TCP source port?

 SOLUTION 已验证 - 已更新 2018年二月15日17:39 - 

English 

环境

  • Red Hat Enterprise Linux 7.3 and above

问题

  • RHEL host is not assigning random source ports for the new connection.
  • Source port randomization doesn't work.
  • RHEL 7.3 system is assigning even source ports for the connect call.

决议

  • As a part of enhancement, this is an accepted behaviour from RHEL7.3 and above systems as a result of commit happened in RHEL7.3 .

  • This commit segregates the allocation of ports from available local port range for connect() and bind() call and will try to favour even ports to connect() call leaving odd ports for bind() calls.

Raw

- bind() call associates the socket with its local address, whereas
- connect() is used to connect to a remote [server] address (source port/system for a new connection)

根源

  • Before RHEL7.3 there was no segregation of ports between bind() and connect() call, where in order to create new connection system used to scan through all available port range /proc/sys/net/ipv4/ip_local_port_range to find a random port and this whole process consumes a considerable amount of time on a busy system.

  • On a busy host, when the system makes a connect() call, in order to save a significant amount of time to scan for the available source port , the port range has been by-fragmented in 2 parts :

  • Even port range will favour the connect() call or will provide the priority to connect() call.

  • Odd port range will favour the bind() call or will provide the priority to bind() call.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值