The meaning of port 0 in netstat output

4

1

What is the meaning of port 0 in netstat -an output in Windows? I'm asking about socket in Foreign address column:

0.0.0.0:0

I know that 0.0.0.0 address means, that host is listening on all interfaces, but what is the function of port zero?

Rafał Ryszkowski

Posted 2012-02-06T06:24:41.893

Reputation: 113

Analogous IPv6: http://superuser.com/questions/661188/what-is-in-the-local-address-of-netstat-output/802793#802793

– Ciro Santilli 新疆改造中心法轮功六四事件 – 2014-08-25T18:51:18.647

Answers

2

If you see this as the "Foreign" address, the meaning is slightly different – it's not about the interface; that would be the "Local" address.

All zeros in the "Foreign" column just mean that there is no remote address yet. The line represents a listening socket, which will accept connections from any address, any port. Those connections would be displayed as separate lines.

(From what I remember, in some early systems it used to be possible to create TCP sockets that would only accept connections from a specific host, a specific port, or both.)

user1686

Posted 2012-02-06T06:24:41.893

Reputation: 283 655

So to sum up: port 0 means ANY port? – Rafał Ryszkowski – 2012-02-06T08:03:23.113

1Yes. In the Foreign address, 0:0 means any remote host, any remote port. (Just to remind: this column is not about local interfaces.) – user1686 – 2012-02-06T08:34:58.813

1@RZR A TCP listening socket or any UDP socket will basically always be listening for connections or datagrams from any port. – David Schwartz – 2012-02-06T09:56:01.193

1… although a connect() on a UDP/IP socket will change this behaviour. – JdeBP – 2012-02-06T13:10:06.313