How to setup a virtualnetwork in Virtualbox

This is for discussing general topics about how to use VirtualBox.
Post Reply
edufissure
Posts: 79
Joined: 8. Sep 2018, 19:27

How to setup a virtualnetwork in Virtualbox

Post by edufissure »

Im a teacher and every student has a computer with Ubuntu( as host machine), as they boot the computer the router of the institute gives the computer a dynamic ip. Also we have a proxy.

This computers have virtualbox 6.1.16 and we work with virtual machines. We usually work in bridged mode, and we have to setup the proxy in the guest machine.

So i need advice,if its possible to make this:
  • - I need to make a DNS server in Ubuntu ( no matters version 18.04 or 20.04 prefer one)to practice. It would be a guest in virtualbox of the students pc. lets name it ubuntudns.
  • - I also need that this ubuntudns would have a static ip, because id have to use client dns to connect to it. So bridge mode doesnt work as it takes a dynamic ip every time we reboot the vm.
  • - I would need an client dns, another VM in the same network of ubuntudns ( obvious), it would ask for "resolver dns querys" to ubuntudns.
  • - Would be nice but not mandatory ubuntudns can go outside with internet
I have tried to put two adapters to ubuntudns one nat and other host-only. And then clientdns also host only..

But it doesnt work....

I also would like to know if its necessary/recommended to create a virtual network ( like vboxnet) in virtualbox, and if can have any ip range or it has it limited by the institute network.

Any ideas about how to setup if possible ? Specially ubuntudns

Thanks
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to setup a virtualnetwork in Virtualbox

Post by scottgus1 »

See Virtualbox Networks: In Pictures.

How you can set up depends on if you intend to build independent 'labs' in each student's PC, each having its own DNS server, or if you want a single DNS server on the school's network and all the students VMs attach to it.

If going with a single DNS server on the school's LAN, Bridged is the only setup that will puts all of your students computers and VMs on the school's LAN IP address range. Host-Only won't let a VM have access outside the VM's host computer. And NAT/NAT Network puts a 'router' with a network address translation between the VM and the school's network. (NAT/NAT Network might work, but I don't know for certain.) Then you can set a static IP address in the DNS server OS in the same IP range as the school's LAN.

If each student gets their own DNS server, then NAT Network would give a private 'LAN' for the client VM and DNS server VM to attach to, as well as access to the internet and an optional IP-range-adjustable(*) DHCP server on the private 'LAN'. DHCP could give the client an IP address, and you can set the DNS VM IP address to static in the VM's OS, in the same IP range of the DHCP server. (* mind the warning in the link above about setting the NAT Network's IP range before starting a VM on it.)
BillG
Volunteer
Posts: 5100
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: How to setup a virtualnetwork in Virtualbox

Post by BillG »

As Scott said, bridged networking it the only realistic option in this case. Virtual networks are only useful if all the guests are running on the same host.

How do the host machines know where the proxy server is? If they get this information from your router, the guests should receive it as well if they are bridged.
Bill
edufissure
Posts: 79
Joined: 8. Sep 2018, 19:27

Re: How to setup a virtualnetwork in Virtualbox

Post by edufissure »

Sorry for my bad english, my mother language is Spanish.
I thought i explained it:
So i need advice,if its possible to make this:

- I need to make a DNS server in Ubuntu ( no matters version 18.04 or 20.04 prefer one)to practice. It would be a guest in virtualbox of the students pc. lets name it ubuntudns.

So im a teacher of vocational education, and in this subject students have to learn DNS.
So in every computer of the class, every student has its computer, i want to virtualize a dns server, and a client that could connect to it, to make some tests and lab practices.
As said the host computer of the student has a dynamic ip, so i have to virtualize a guest vm with static ip, in a private network, which also be included the client DNS.

Hope i explained it better....

Thanks for your help
edufissure
Posts: 79
Joined: 8. Sep 2018, 19:27

Re: How to setup a virtualnetwork in Virtualbox

Post by edufissure »

BillG wrote:As Scott said, bridged networking it the only realistic option in this case. Virtual networks are only useful if all the guests are running on the same host.

How do the host machines know where the proxy server is? If they get this information from your router, the guests should receive it as well if they are bridged.
In the pc of the student ( as said one pc per student), we boot computer and we have a dynamic ip, i suppose the proxy is configured. When we create a guest vm, we have to configure/setup the proxy in the networking settings of the guest vm that we create
Selection_517.png
Selection_517.png (75.8 KiB) Viewed 4975 times


the proxy is 192.168.2.1 port:3128

Thanks
fth0
Volunteer
Posts: 5661
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: How to setup a virtualnetwork in Virtualbox

Post by fth0 »

edufissure wrote:I have tried to put two adapters to ubuntudns one nat and other host-only. And then clientdns also host only..

But it doesnt work....
What you described in your initial post should work. You could even use the Internal Network networking mode instead of Host-Only, because the host does not need to participate in your internal network consisting of the ubuntudns and clientdns VMs. So from my POV the real questions are:

What doesn't work?

Do you want more than what you described (e.g. a connection between your internal network and the school network or Internet)?
edufissure
Posts: 79
Joined: 8. Sep 2018, 19:27

Re: How to setup a virtualnetwork in Virtualbox

Post by edufissure »

I need advice, becuase the system administrator is afraid that the DNS im trying to implement in lab, could damage the DNS of the school.
In the other hand i want that students could practice with one ubuntudns in a private network, but if the dns cant resolve the query, it could go outside internet and get the solution.
So clientdns would trying to solve for example www.google.com, and as in ubuntudns would not be solved, it would have to go to root dns servers in internet.
I dont know if its possible:
1 - Is possible ?
2 - Better use nat or bridge ? To go outside
3 - Better host only o virtual private network.

That are my doubts...
Thanks for the help
fth0
Volunteer
Posts: 5661
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: How to setup a virtualnetwork in Virtualbox

Post by fth0 »

I can understand your system administrator and IMHO the right solution would be to let your system administrator design and create the necessary setup themselves.

What you want is possible, of course, but needs some degree of networking knowledge, that goes beyond what the VirtualBox forums usually provide. If you've designed and created your setup with physical computers, then we can tell you how to do the same within VirtualBox VMs.
edufissure
Posts: 79
Joined: 8. Sep 2018, 19:27

Re: How to setup a virtualnetwork in Virtualbox

Post by edufissure »

fth0 wrote:I can understand your system administrator and IMHO the right solution would be to let your system administrator design and create the necessary setup themselves.

What you want is possible, of course, but needs some degree of networking knowledge, that goes beyond what the VirtualBox forums usually provide. If you've designed and created your setup with physical computers, then we can tell you how to do the same within VirtualBox VMs.
Sorry my english is very bad, but i think ive explained it already:

- Every computer of students have a host ubuntu, with network connected to private network of institute, and internet through a proxy. Every computer have a dynamic ip every time it boots.
- I want to have two virtual machines ( every student in their classrooms pc) , in same network... one with dnsserver and other with dnsclient. Becauuse if dns changes the ip, would be very confusing.
- I need that the ubuntudns virtualmachine (guest) could connect to internet, to solve dns querys,
- Which is the best way, now that is possible, to make this without affecting the network of the institute.

Thanks
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to setup a virtualnetwork in Virtualbox

Post by scottgus1 »

Though we have lots of gurus that can help solve this, if you're going to integrate your VMs into the school's network, then start altering the DNS reactions of the network, you stand a chance of damaging the school's network. We cannot know the different setups of the school's network.

Since your proposed VMs would provide DNS over your school's network, the VMs would be Bridged, and attached with wired Ethernet for best performance.

I agree with fth0: If you plan to put the DNS VMs on your school's network, further setup should be made through your school's IT department.

However, there is a way to block access to the school's network while allowing access to the school's internet: use a pfSense computer running in "Sandbox" mode, and a separate switch for your students. Hook it up like this:

School > (WAN) pfSense router/firewall (LAN) > your switch > your students' PCs, Bridged student VMs, your PC, and your Bridged DNS VMs.

pfSense will act as a router between your classroom switch and the rest of the school. The pfSense firewall rule described in the Sandbox link will allow internet from the school into your switch's LAN while preventing access to the school's LAN from your classroom switch.
Post Reply