大网数据广告活动
服务器运维问答

Ports of server with UDP are all open

· 52CE 我爱测

I'm a developer working on a CentOS7 server. Today I want to check the status of all ports of the server. First I execute the command: firewall-cmd --zone=public --list-ports and I get this: 110/tcp 443/tcp 80/tcp 995/tcp 143/tcp…

问题原文

原帖链接 · Yves · CC BY-SA 3.0

I'm a developer working on a CentOS7 server. Today I want to check the status of all ports of the server.

First I execute the command: firewall-cmd --zone=public --list-ports and I get this:

110/tcp 443/tcp 80/tcp 995/tcp 143/tcp 3306/tcp 993/tcp

All of ports above are opened by me so everything's fine.

Then I use another Linux PC and use nc to scan ports of the server (saying that the ip of the server is a.a.a.a):

nc -v -z -w2 a.a.a.a 1-4000

I get the same result.

After that, I use nc to scan ports using UDP:

nc -v -z -w2 -u a.a.a.a 1-4000

To my surprise, it seems that all of ports are opened because I get the result as below:

Connection to a.a.a.a port 1 [udp/tcpmux] succeeded!
found 0 associations
found 1 connections:
     1: flags=82<CONNECTED,PREFERRED>
    outif (null)
    src b.b.b.b port 62086
    dst a.a.a.a port 2
    rank info not available

Connection to a.a.a.a port 2 [udp/compressnet] succeeded!
found 0 associations
found 1 connections:
     1: flags=82<CONNECTED,PREFERRED>
    outif (null)
    src b.b.b.b port 60795
    dst a.a.a.a port 3
    rank info not available

Connection to a.a.a.a port 3 [udp/compressnet] succeeded!
found 0 associations
found 1 connections:
     1: flags=82<CONNECTED,PREFERRED>
    outif (null)
    src b.b.b.b port 50133
    dst a.a.a.a port 4
    rank info not available

Connection to a.a.a.a port 4 [udp/*] succeeded!
found 0 associations
found 1 connections:
     1: flags=82<CONNECTED,PREFERRED>
    outif (null)
    src b.b.b.b port 64246
    dst a.a.a.a port 5
    rank info not available

Connection to a.a.a.a port 5 [udp/rje] succeeded!
found 0 associations
found 1 connections:
     1: flags=82<CONNECTED,PREFERRED>
    outif (null)
    src b.b.b.b port 50334
    dst a.a.a.a port 6
    rank info not available
...
...

Now I'm confused.
Why do all of ports are opened for UDP? Is it safe? If it's not safe, why doesn't the firewall close them?
For me, "port is open" means that some program or the system is listening on it. For example, 80/tcp means that my web program is listening on the port 80. If I'm right, does it mean that the server is listening on all of ports with UDP?
Or "port is open" just means that the firewall doesn't block the port so that you can use some program to listen on it?

已采纳解答

原帖链接 · Ulfy · CC BY-SA 3.0

The UDP response is a false-positive, you can disregard this. UDP is a connectionless/stateless protocol so it isn't expecting anything back... no response, bad response... it's all the same. TCP is a stateful protocol, as both endpoints retain information about each other's state, acknowledgements are required, and it can retransmit.

Reading about stateless protocols: https://en.wikipedia.org/wiki/Stateless_protocol

TCP State: https://upload.wikimedia.org/wikipedia/commons/a/a2/Tcp_state_diagram_fixed.svg

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-07-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。