0

I am trying to have some VMs on two Ubuntu hosts using KVM (two seperate machines).

I want all these VMs to be accessible with their private IPs (or public IPs). I know the local IPs of the VMs can not be used since they are behind NAT. Kindly let me know the simplest options and requirements for this purpose.

To be more specific:

  1. How they should be physically connected (a cable, a hub, a router, etc..)? The two machines are currently connected to a WIFI router. But since WIFI routers are sometimes busy and have high latency, I am looking for a better option.

  2. How should the virtual machines be configured, so their IP addresses would be visible to others?

Thanks.

  • Are the 2 VMS on 2 separate machines? – Nathan.Eilisha Shiraini Jul 18 '18 at 8:48
  • Yes, I have two machines and two KVM installed on them. I on each machine I have about 5 VMs So I want all VMs be accessible from each other. – amir mohamad hatami Jul 18 '18 at 8:54
  • Are the two Ubuntu machines in the same local network? I forgot to address that. – Fanatique Jul 18 '18 at 9:03
  • Thanks, you have answered part of my question. The other part is how to connect these two machines physically (if possible with low latency) . (I mean a cable, a router a hub ,,...) – amir mohamad hatami Jul 18 '18 at 9:22
  • I'm asking again, are the two Ubuntu hosts in the same local network under the same router? What is the topology in your network? I need that information so I can answer your 1st question. – Fanatique Jul 18 '18 at 9:25
2

How should they be physically connected?

If the distance is not too great and you don't have many machines in your local network (e.g. it's only those 2 Ubuntu hosts), then your option would be to directly connect the 2 Ubuntu hosts to the router via an UTP cable (Ubuntu host 1 is connected to the Router via a cable, Ubuntu host 2 is connected to the Router via a cable as well). By using direct cable connection you'll avoid the higher latencies that WiFi has.

However, if the distance is too great and you have more machines that need a direct connection, then you can use a switch. The switch has to be connected via one of its ports to the router, and then you connect your machines to the other ports of the switch.

How should the IP addresses of the virtual machines be visible to other VMs/hosts?

Configure Public bridge networking for your virtual machines. This will assign them IP addresses in your local network, so you can access them via your host or other virtual machines that are configured in the same way.

See How to configure Public Bridge @ KVM Networking for a detailed guide on how to achieve that.

You can also check this article from VMware which explains what bridging is.

Note: If you want only the VMs to be able to access each other, and not access them from other hosts, you can use Private bridge configuration, which will setup a local network only for the virtual machines, so they will be in a seperate network.

  • Thanks, you have answered part of my question. The other part is how to connect these two machines physically (if possible with low latency) . (I mean a cable, a router a hub ,,...) – amir mohamad hatami Jul 18 '18 at 9:21
  • @amirmohamadhatami Please edit that into your question as well. And what do you mean physically connect them? Are the two Ubuntu machines under the same router? – Fanatique Jul 18 '18 at 9:22
  • I have already edited them. I mean the physical layer. They are connected to the same WIFI router but I guess it is not good because it has high latency – amir mohamad hatami Jul 18 '18 at 9:25
  • Simply using a cable connected to the router is more than enough to bypass the high latency. – Fanatique Jul 18 '18 at 9:35
  • Thanks and would that also work if I use a private bridge config? (Or I should set some settings in the router). To be more specific I am afraid that these public IPs change over the time and If they change I would have to reinstall my programs on the VMs which is time consuming. – amir mohamad hatami Jul 18 '18 at 9:38

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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