What kind of network should i be using ... ?

This is for discussing general topics about how to use VirtualBox.
Post Reply
kajandata
Posts: 4
Joined: 24. Nov 2022, 09:00

What kind of network should i be using ... ?

Post by kajandata »

... in order to simulate a DIRECT CONNECTION between 2 computers without a router being involved?

I need to set this up at a friends place and was interested to test my configuration attempts in "virtual world" beforehand.
Up til now, i am using internal networking, but i read, that only newer hardware no longer makes twisted cabling a necessity. But in virtual world, i cannot alter cabling, therefore i need the functionality from the "hardware" to recognize the unusual setup for the connection to function properly. - I have not yet been able to configure the main vm to act as a bridge for internet access to the slave vm, and do not want to rely on dhcp, which would not be present at my friends home anyway. I did not get any connection to work between the 2 vms.

(host and guests are and will be debian)

Has anyone ever succeeded at simulating a direct connection?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: What kind of network should i be using ... ?

Post by scottgus1 »

A bit of background: A direct connection going through a single network cable requires the network cards in the PCs to auto-negotiate which sets of wires in the cable are which. Older network hardware couldn't do this, so a special "crossover" cable was required. For many years, network hardware can auto-negotiate, so regular network cable can be used.

All that is needed is to set static different-but-compatible IP addresses on the two network cards, in the same private IP range and identical net mask. Such as 192.168.20.1 & 192.168.20.2, net mask for both 255.255.255.0. Once the cable is plugged in, each computer can access the other's services using the other computer's static IP address. Windows and some other OS's will auto-apply APIPA addresses (169.254.#.# net mask 255.255.0.0) if the network card is set to use DHCP but there is no DHCP server on the network. These auto-chosen APIPA addresses can also be used for network service access. They may be different numbers each run of the network, though, so static IPs are easier to use across different runs.

See Virtualbox Networks: In Pictures . In Virtualbox, two or more VMs can network this way using Internal. The host and any number of VMs can network this way using Host-Only. (Internal defaults to not having a DHCP server. Host-Only's default DHCP server can be turned off.) You can include physical PCs outside the host and the VM(s) using Bridged, along with an unmanaged network switch between the physical PCs and the host.
kajandata wrote:I have not yet been able to configure the main vm to act as a bridge for internet access to the slave vm,
Internet access requires a router of some sort (either physical or as a service in an OS on the network) if you want to include VMs in the host's internet, and you're using old-school IPv4 addresses. IPv6 may be able to skip the router, but I don't know how to do that.
kajandata
Posts: 4
Joined: 24. Nov 2022, 09:00

Re: What kind of network should i be using ... ?

Post by kajandata »

scottgus1 wrote:(...) Older network hardware couldn't do this, so a special "crossover" cable was required. For many years, network hardware can auto-negotiate, so regular network cable can be used.
(...)

In Virtualbox, two or more VMs can network this way using Internal. The host and any number of VMs can network this way using Host-Only. (Internal defaults to not having a DHCP server. Host-Only's default DHCP server can be turned off.)
Excellent explanations, good wording, even circumventing my own (prior) translation mistakes!
Thank you for this uplifting answer.
I am using static IPv4 addresses now, and will investigate, if bridging will achieve, what i want (apt install bridge-tools).

The initial question has been answered to my utter satisfaction.
Thank you.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: What kind of network should i be using ... ?

Post by scottgus1 »

kajandata wrote:if bridging will achieve, what i want (apt install bridge-tools)
Virtualbox networking (including Bridged) does not require any other host OS tools like Linux bridge tools to work. Linux bridge tools are designed to merge the host's physical adapters together in various ways. This may get in the way of Virtualbox Bridged.

Thanks for the kind words, I'm glad I was able to help!
Post Reply