关于TCP/UDP的端口号的范围都是 0 ~ 65535
根据IANA定义,可以参考如下链接:
https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
IANA将这些端口分成了3类,Last Updated 2023-03-30
Port numbers are assigned in various ways, based on three ranges:
System Ports (0-1023), 也有地方称为 Well Known Ports 众知/周知 端口
User Ports (1024-49151), 也有地方称为 Registered Ports 可注册 端口
Dynamic and/or Private Ports (49152-65535)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
也许在实际我们的认识和一些现象中,只是将端口分为了2部分 0~1023 和 1024 ~ 65535 号端口
最明显的就是在Linux系统中(笔者在Redhat系统中测试发现),对于普通用户而言只能监听1024 ~ 65535 号端口
如下,我们可以通过如下命令就可以看到效果
[qq-5201351@Localhost ~]$ nc -l 1023 Ncat: bind to 0.0.0.0:1023: Permission denied. QUITTING. [qq-5201351@Localhost ~]$ nc -l 1024 & [1] 290059 [qq-5201351@Localhost ~]$ netstat -lanpt |grep 1024 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:1024 0.0.0.0:* LISTEN 290059/nc [qq-5201351@Localhost ~]$
可以看出普通用户只能监听1024及1024以后的端口,对于UDP端口也是如此,同样,对于65535号端口也是可以监听的,
另外:对于0号端口也是一个特殊的端口,通过文档看到 TCP/UDP 的0号端口都是Reserved
如果使用root用户去监听TCP或者UDP的0号端口,都会收到报错:Ncat: Invalid port number "0". QUITTING.
尊重别人的劳动成果 转载请务必注明出处: https://www.cnblogs.com/5201351/p/17278622.html
标签:1024,UDP,0.0,端口,TCP,Linux,Ports From: https://www.cnblogs.com/5201351/p/17278622.html