Just a curiosity, if I have a NIC that is associated with more than one IP addresses. Does port ties to an IP or NIC?

For example if I have a NIC that has two IPs, 1) and 2)

If I open port 1234 on, can I also open port 1234 on or that will be prohibited since the NIC already had port 1234.


  • 4
    The short answer is that yes you can do that, provided that you explicitly bind the socket you open to one of the two IPs rather than using the typical default which is to bind to all local IPs on the host. This SE question has a much more detailed answer which should help : stackoverflow.com/questions/14388706/… Jun 6, 2016 at 21:31

3 Answers 3


When you open a port, bound to an IP address, it is called a socket. Then, if you have multiple IP addresses, on each of them, you can open ports, always if hardware permits.

Regarding your question, these 2 connections can be established simultaneously. You also can have one service running on and another on, also using the same port.

If you read more info about OSI model, you can check that "port" relies on L4 (transport layer), and NICs exist between L2-L3.


Ip sockets bind to a combination of IP version, IP address, port number and transport protocol (some operating systems may also allow sockets for non-IP protocols, I will not go into those there). Whether those IP addresses are associated with the same NIC or not is irrelevent.

So yes you can bind a seperate socket (either from the same or different applications) to the same port on different addresses on the same interface. This is very common on web servers.

Note1: if you bind a socket to it will accept connections on ayn local IPv4 address and (while this socket exists) you will not be able to bind to the port on individual IPv4 IPs (at least not without extra socket options).

Note2: If you bind a socket to :: it will accept connections on any local IPv6 address. Depending on OS, configuration and socket options it may also accept connections on any local IPv4 address.


A Network Interface Card ( NIC ) consists of a port ( Hardware port ) and are bind with unique MAC address ( which could be changed under special circumstances eg visualization ). Port is just a cabling device. A NIC card have a port embedded in it.Interface = NIC ( port + other component ).

We can assign multiple ip address on a interface. There is only one primary address and other address bind to that interface are secondary addresses.Secondary IP address could also be advertised in routing protocols or could be used as gateways.

Word "Port" is also used in software where it identify specific process or type of service.Software port number could be bind to any of reachable IP address.

  • Ports bind to transport protocols (TCP and UDP), not IP addresses. Ports are layer-4 addresses for TCP and UDP. Some transport protocols don't have addresses or ports. It really has nothing to do with the IP address.
    – Ron Maupin
    Jun 7, 2016 at 1:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.