0

How can I make 3 VMs connect with each other as well as internet without using bridged adapter in Virtualbox?

I don't want to use bridged adapter because I use WiFi and this combination often doesn't work. I need to connect with internet to be able to download packages, and connect with each other so that I can form a Kubernetes Cluster.

I want to connect to them via SSH from another remote machine (using same or different network).

1
  • Hello. You could create 2 virtual interfaces: one for a dedicated internal network connecting the 3 (or more) nodes of your kubernetes cluster, and a 2nd one that allows internet access ? And see (on the right of this page) the "related" Q : unix.stackexchange.com/questions/251854/… Commented Jan 25, 2024 at 14:26

2 Answers 2

1

You may be able to create a new bridge for the three VMs, and also have them all inside a NAT network from your Host. (You may also find that putting them on the same NAT network allows them to contact each other - I haven't tested VirtualBox recently to check this.)

To allow incoming ssh connections to each machine you're going to need to Port Forward from your Host. Each VM will need a different port, for example, 50001, 50002, 50003.

0

An option is to use the host-only adapter, and route via IPtables. This is from host-only network into Wifi, you may need to set up the other direction too (duplicate first line and switch input and output interface and put the host-only net´s IP range as destination instead of source).

sudo iptables -I FORWARD -o wlp58s0 -i vobxnet0 -s 192.168.58.0/24 -m conntrack --ctstate NEW -j ACCEPT sudo iptables -I FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" sudo iptables -t nat -F POSTROUTING sudo iptables -t nat -A POSTROUTING -o wlp58s0 -j MASQUERADE 

The host-only network (name, IP) can be configured via Tools -> Network Manager.

Why not simply create a NAT network? I wanted to open up the virtual network only occasionally via script.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.