Separating the networks from 2 linux guests

Discussions related to using VirtualBox on Windows hosts.

Separating the networks from 2 linux guests

Postby SERXOL2 » 19. May 2021, 12:54

Having an issue of not understanding networking or the virtualbox client. Added 2 virtual addapters to each of the 2 linux guests. I need to staticly add a range of ips to each of the interface. The idea is : i assign to one interface of a linux vm an ip as 10.0.0.15/24 and on the other vm on one interface same network ip 10.0.0.16/24. Then i go to the other interface of the first linux vm and assign it an ip of 20.0.0.15/24 and on the other vm in the same network 20.0.0.16/24. My question is being in different networks they are still speaking. Im using bridged adapter for this configuration but tried most of the network types. Im trying to separate communication from the interfaces. so that 10.0.0.15/24 doesnt speak with 20.0.0.16/24.
thank you in advance!
SERXOL2
 
Posts: 4
Joined: 19. May 2021, 12:35

Re: Separating the networks from 2 linux guests

Postby mpack » 19. May 2021, 12:55

"NAT" is separate to begin with. You have to use "NAT Network" if you want NAT VMs to communicate with each other.
mpack
Site Moderator
 
Posts: 34544
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Separating the networks from 2 linux guests

Postby SERXOL2 » 19. May 2021, 13:15

I made the vms use NAt Network each of the adapter having its own nat network. run up the machines. assigned them static ip address and even if they are from diferent nat networks and different networks themself (10.x.x.x and 20.x.x.x) they are still comunicating. to see if they are communicating or not. Im using the ping -I 10.x.x.x 20.x.x.x and its still works.
SERXOL2
 
Posts: 4
Joined: 19. May 2021, 12:35

Re: Separating the networks from 2 linux guests

Postby mpack » 19. May 2021, 15:10

Why are you assigning static network addresses? If you use NAT (or NAT network) then VirtualBox implements a DHCP server, and it will expect the VMs to use their assigned addresses.

Virtualbox Networks: In Pictures.
mpack
Site Moderator
 
Posts: 34544
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Separating the networks from 2 linux guests

Postby BillG » 20. May 2021, 05:15

@SERXOL2

You seem to be confusing networks and subnets. If devices are in different networks they cannot communicate with each other unless there is a router connecting the networks.

Devices in the same network can communicate with other devices in the same network if they are in the same subnet. If they are in different subnets they need a router to communicate with each other, even if they are in the same network.

In your example you say that the vms have two adapters. What network are these two adapters attached to? To put them in two different networks, you would need to attach them to two different internal virtual networks. If you want them to be in the same network but in different subnets, attach them to the same internal virtual network.

When you are trying to emulate a physical setup using virtual devices, you have to be careful that you are using the same sort of thing. Devices using NAT behave like a physical PC on a LAN behind a NAT router. Devices connected to the same internal virtual network behave like physical PCs connected to the same switch. Devices connected to different internal virtual networks behave like PCs connected to different physical switches.
Bill
BillG
Volunteer
 
Posts: 4825
Joined: 19. Sep 2009, 04:44
Location: Sydney, Australia
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 7,8,Server

Re: Separating the networks from 2 linux guests

Postby SERXOL2 » 13. Jun 2021, 11:42

BillG wrote:@SERXOL2

You seem to be confusing networks and subnets. If devices are in different networks they cannot communicate with each other unless there is a router connecting the networks.

Devices in the same network can communicate with other devices in the same network if they are in the same subnet. If they are in different subnets they need a router to communicate with each other, even if they are in the same network.

In your example you say that the vms have two adapters. What network are these two adapters attached to? To put them in two different networks, you would need to attach them to two different internal virtual networks. If you want them to be in the same network but in different subnets, attach them to the same internal virtual network.

When you are trying to emulate a physical setup using virtual devices, you have to be careful that you are using the same sort of thing. Devices using NAT behave like a physical PC on a LAN behind a NAT router. Devices connected to the same internal virtual network behave like physical PCs connected to the same switch. Devices connected to different internal virtual networks behave like PCs connected to different physical switches.


The idea behind my question is that i have built a php web page hosted on apache2 on another virtual machine with a script that, when you enter an IP address in a form the script runs and changes the IP from a different virtual machine. This is made with ssh2 connection. The changing of the ip addresses works and im really glad that it works, but another functionality of this website is seeing if the ip addresses from these ssh2 connected virtual machines can talk with each other to see if they were successfully configured. The only bug that i have right now is that whatever ip addresses i assign to those virtual machines they still talk to each other. I don't know if its the problem of the Linux's or the VirtualBox client.
The command that i give when making the change of ip on a virtual machine is "sudo ip addr add <whatever ip i enter from the php> dev enp0s8/enp0s9/enp0s10". I read the visual representation of each of the network options and bridged would be the best option for me. So that lets say the 20.0.0.0 network shouldn't talk with 10.0.0.0 network. Again thanks in advance if anyone responds.
SERXOL2
 
Posts: 4
Joined: 19. May 2021, 12:35

4 Ubuntu 20.04 communicating with each other whatever the IP is.

Postby SERXOL2 » 13. Jun 2021, 12:50

Hello!
I am running 5 Linux Ubuntu 20.04 VMs on VirtualBox. Each vm has 4 network adapters enabled on it(4 interfaces). I am using 1 one of the vms to host a php page on apache2. This php page is connected through ssh to the rest of 4 vms. The php page that i have has 12 submit forms (3 submit forms for each interface). I am leaving 1 interface unchangeable for the ssh connection. I managed to configure the ssh connection successfully so that when i enter an IP address on the webpage the interfaces change on the 4 vms. The problem which i have right now is that whatever network option i choose for these adapter they communicate whatever the ip address i assign. Lets say i assign an ip such as 10.0.0.10/24 on the on of the interfaces of Vm1 then i assign 20.0.0.10/24 on another interface on Vm2. Whatever the mask i assign they always communicate. The one interface i left unchanged for ssh connection is with the bridge network option. What virtual network option should i choose so that when i assign ips of different networks to different ips i don't get a connection. Or where do you think i went wrong?

Thanks in advance for a response. :D
SERXOL2
 
Posts: 4
Joined: 19. May 2021, 12:35

Re: Separating the networks from 2 linux guests

Postby fth0 » 13. Jun 2021, 13:09

I believe your key problem is on the Linux side (and independent of VirtualBox):

For example, the command ping -I 10.0.0.15 20.0.0.16 will create an ICMP echo request packet with the IPv4 source address 10.0.0.15 and the IPv4 destination address 20.0.0.16. The Linux networking stack will then consult the IPv4 routing table (ip route) and send the packet over the network interface with the IPv4 address 20.0.0.15. The IPv4 source address 10.0.0.15 is not considered for the routing decision.
fth0
Volunteer
 
Posts: 2382
Joined: 14. Feb 2019, 03:06
Location: Germany
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...

Re: 4 Ubuntu 20.04 communicating with each other whatever the IP is.

Postby fth0 » 13. Jun 2021, 13:16

SERXOL2 wrote:Or where do you think i went wrong?

Please see my answer in your other thread Separating the networks from 2 linux guests.
fth0
Volunteer
 
Posts: 2382
Joined: 14. Feb 2019, 03:06
Location: Germany
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...

Re: Separating the networks from 2 linux guests

Postby scottgus1 » 15. Jun 2021, 03:08

Topics merged, as the problem is the same.
scottgus1
Site Moderator
 
Posts: 13002
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux


Return to VirtualBox on Windows Hosts

Who is online

Users browsing this forum: Google [Bot] and 37 guests