0

When a process in a VM (with multiple NICs) communicates with some other process on some other virtual machine (or maybe on the internet), it does it via a different IP address, at different times.

How is this IP address given to the process? Does it depend on the destination process's Network configuration?

1 Answer 1

1

An IP address is not bound to a process itself or "given" to a process. The IP is bound to a certain network adapter. That being said, it doesn't really matter if it's a VM or a bare-metal system. And the flavor (VMware, MS, etc.) of the VM doesn't matter either.

Oversimplified the process requests to create a so-called socket in order to communicate, this is mostly done through the TCP/IP stack which is handled by the OS. This way many processes can use the same IP (on different ports though).

Which network adapter the socket will get assigned is also handled by the OS, at least mostly (think about a browser on a system with multiple network adapters). There are ways to force an application to a certain port (e.g. ForceBindIP) other applications will let you choose an adapter (e.g. Wireshark), but there is no general answer here. If you have a specific problem you should ask directly.

5
  • We should add that the default source IP address is the one chosen by local routing (=handled by the OS), ie. 192.168.0.10/24 would be used to talk to 192.168.0.11, or 10.20.30.40/24 to talk to 10.20.30.99.
    – Zac67
    Jun 21, 2022 at 15:24
  • correct (unless more than one adapter can use similar routes, then it goes by metric... etc.)
    – Albin
    Jun 21, 2022 at 15:30
  • Yes, absolutely! I've only used trivial examples for commenting.
    – Zac67
    Jun 21, 2022 at 15:39
  • @Albin, so this means that the bind () function which is called to assign a socket to a process is called by the OS? Jun 22, 2022 at 3:55
  • There is no general bind-function. What exactly are you referring to? (The binding of an IP to an adapter is done through the settings in the operating system).
    – Albin
    Jun 22, 2022 at 10:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .