If a network interface has two different IP addresses 1 and 2 assigned to it. and the port numbers in (IP address 1, port number) and (IP address 2, port number) are the same number, does it mean the same port for two different IP addresses? In other words, do different IP addresses correspond to nonoverlapping sets of ports? Thanks.
-
Port numbers are addresses for _some_ layer-4 protocols (TCP and UDP), and IP knows nothing about them, just as IP know nothing about MAC address, DLCI, VPI/VCI, etc. The network layers are separate. – Ron Maupin Feb 13 '19 at 19:32
-
About your `0.0.0.0` confusion, if you understand [IPv4 math](https://networkengineering.stackexchange.com/a/53994/8499), you will understand that `0.0.0.0/0` actually matches _every_ IPv4 address. That is why it is used for a default route. _All_ IPv4 networks are subnets of `0.0.0.0/0`, and _every_ IPv4 address is part of that network. – Ron Maupin Feb 13 '19 at 20:19
-
Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer. – Ron Maupin Dec 14 '19 at 20:18
1 Answers
They might and they might not.
Generally, a port X on IP address A (A:X) is different from port X on IP address B (B:X). Think of a port as a subaddress of an IP address. You can e.g. have two completely different web servers running on TCP A:80 and on TCP B:80.
It is however very common that a server application binds its listener to 0.0.0.0:X - port X on any IP address on the local machine. So, on the transport layer the ports are different, but on the application layer they can both be held by the same process with the same function.
The function can also differ by IP address, depending on the application - a web server could serve different pages or an SMTP server could serve different domains or require authentication on one IP but not on the other. A DHCP server would (obviously) serve different scopes.

- 81,287
- 3
- 67
- 131
-
Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/89847/discussion-on-answer-by-zac67-do-different-ip-addresses-correspond-to-nonoverlap). – Ron Maupin Feb 17 '19 at 17:10