0

I am wondering if it is possible to have multiple virtual machines on a single physical machine listening on the same port number.

The problem I am facing now is that I have a software that communicates on a specific port number with an external machine. I have "X" number of external machines at various locations all using that same port number. So instead of buying "X" number of machines locally to communicate with them all, I've been tasked to see if I can use one machine using virtualisation to solve it.

I remember coming across VMWare player with the ability to bridge a particular physical network port to the virtual machine, so that theoretically solves it.

But are there other solutions? Ones that does not require me to get "X" number of physical network ports on the machine?

1

Possible if virtual machines have different IPs.

3
  • I apologize for my lack of knowledge on VMs but if all the communication goes to the same network port on the physical machine, how does the physical machine know where to route the packets to? Aren't the port numbers being exclusively map to particular VMs? – amsga Jun 19 '20 at 3:45
  • 1
    To commu icate using TCP/IP, each packet includes a source IP, source port, rest IP and dest port. Because the packets include both source and dest IPs they can be uniquely routed. A port number is associated with an IP address, not a VM. – davidgo Jun 19 '20 at 4:12
  • There can be multiple MAC addresses behind a single network port in Ethernet. Therefore, each VM network interface has its own MAC address, and normal Ethernet mechanisms are used to deliver Ethernet frames. – Tero Kilkanen Jun 19 '20 at 7:43
0

Use multiple IP addresses, one for each of the listening services 1 through X.

If one container or VM per listener, easy enough, one IP address each. Use container or VM networking to route.

Or, you can add multiple IP addresses to an interface on one host. Bind each listening service instance to its own IP address. In other words, don't have it listen on the unspecified address of ::. A well-known example, Apache httpd has a Listen directive which can be given an IP address. Use something similar for this software.

If you don't have enough IP addresses to do this, implement IPv6.


All of this assumes you only have TCP/IP to do routing. If you have a application aware load balancer, that could enable more criteria than a TCP 5 tuple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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