Creating a VLAN with Oracle virtual box

 

I am sure you have arrived in this post, looking for the way to create VLAN in Oracle VirtualBox. You are in the right place. But the thing is, if you need to create a real VLAN, your switch port should have been tagged to 802.1Q VLAN tagging. Then network interface in the OS you are running within VirtualBox should be configured to have 802.1Q VLAN. There is nothing special in the general VirtualBox configuration other than assigning the “Bridge Network”.

But, if you want to simulate the purpose of VLAN when you do not have a switch tagged with 802.1Q VLAN, you can do it with Oracle VirtualBox. That would give you the private access within your VirtualBoxes. Same like many other Vms, Oracle virtual box also supports creating a Virtual LAN. To do this first we need to understand the different types of network types in Virtual Box.

  • Not Attached
  • Network Address Translation (NAT)
  • NAT Network
  • Bridge Network
  • Internal Network
  • Host Only Network
  • Generic Network

I do not want to repeat the details of all about network types. If  you are concern about it, please refer to this link ==>> (6.2. Introduction to networking modes)

Each different types os networking methods can be used to achieve different kinds of tasks. In our case, we would use “Internal Network”. This will help us create private Virtual LANs by names which would work similar to VLAN and stay communicating in private.

 

Steps :

  1. Go to settings, Click on “network” tab
  2. Click on “Enable Network Adapter” in one of the adapter tab.
  3. In “Attached to” select box, choose “Internal Network”
  4. For the name input box, provide a VLAN name if you do not have already one. It is your choice.

The below screenshot will describe you more.

Oracle Virtual box VLAN Configuration
Oracle Virtual box VLAN Configuration

Now you are done. After you have installed the OS, your will have an interface in your OS, which has a private IP that can only communicate within the same network. With this types of network, even the host computer doesn’t have access to guest. So you stay private and safe.

Update:

If you need more detailed guide on setting up a Virtual Network using Oracle VirtualBox, please go to my latest blog post here, Setting up a local network using VirtualBox – Linux – Windows

5 comments Add yours
  1. Hi!
    Thanks for your article, its easy.
    I have a question: I built two VLAN network with “NAT Network”. I have two Host in the VLANs. For example: 192.168.10.2 and 192.168.20.5. How can they see each other in the VirtualBox?

  2. Hi,
    Am I missin g something? where is the rest of the article explaining how to configure VLANs? I only see how to set up a Virtual Machine with internal network adapter

  3. This by function would allow you to reason out how they could be identified as VLANS in a lab. The part that makes it hard to believe that this is an article about creating VLANs in virtualbox, is that you could also consider it equivallent to LANs as well. Thus, making it a wash and mute point to make a guide on how to make VLANs in virtualbox. I encourage you heavily to reconsider putting this back together with consideration to trunking VLANs into a physical switch.

  4. I tried your script and I am havnig trouble getting it to work. I have two networks configured but it only appears to be working on one device. For example I can ping a site fine, try again and get nothing, ping another fine, then nothing. Both of the networks have the same gateway- 192.168.0.1, which I have a feeling may be causing the problem? It looks like when the routing tables are being created, the default gateway is specified by IP only. Should the device be specified here as well?? Any feedback would be great. Thanks. -Jason

Leave a Reply

Your email address will not be published. Required fields are marked *


*

Please wrap all source codes with [code][/code] tags.