OpenWrt on VirtualBox HowTo - Inconsistency

All,

I am trying to setup a VirtualBox VM that would be the closest to emulating a Bare Metal Router with a LAN Subnet.

Read through the OpenWrt on VirtualBox HowTo

When reading the wiki entry, it seemed the goal was to set up an x86 OpenWRT router so it would work to emulate that of an actual device with several Private-range subnets (10.0.0.0/8 or 172.16.0.0/12, or 192.168.0.0/16) ranges and a WAN interface connecting to the LAN of the host.

.

I've been using a post over at the VirtualBox forums to piece together what's being done in the HowTo, and to make a few diagrams of my own about what the different Adapter types actually mean.

I've integrated all of the relevant diagrams into a single one based on the How To.

Below are the diagrams I made from the forum post diagram, please let me know if any of them are incorrect or inconsistent.

I visualized how the network layout of the HowTo might look based on the OpenWRT posts' visual and text descriptions of the Adapter Strategies to make the integrated diagram, but I'm still confused about the intent of the HowTo.

The Adapter Strategies are in VirtualBox here in the Attached to: dropdown:

VirtualBox Adapter Strategies:

(based on this VirtualBox Forums Post)

The, HowTo, seems a little inconsistent / or maybe just confusing in the following areas:

  • In the VM Setup section, it says that the optional eth2 interface is configured in VirtualBox as a Bridged Adapter, which would place the adapter on the Host LAN, thus not passing the traffic through the OpenWRT VM from the Guests.

  • It mentions setting up 3x Host-Only Adapters without mentioning the Bridged Adapter at all.

But instead I found a private vlan for a management interface, and a Bridged Aadapter, with a Host Only Adapter.

And I'm confuse about how to proceed to make this match the standard layout of an actual embeded systems router that I bought off the shelf, so I can model it in my machine and approximately make it work the same way on the production Linksys E5400 I have.

HowTo Result Desired Layout
So far above is what I think I have based on following the HowTo. And above is what I think I should have to model it after the production E5400, but I don't know which VirtualBox Network config I should use to achieve this, I really don't think it's the Bridged Adapter because the point is to keep the private IPs behind the firewall of the OpenWRT router.

So then I need to know which VirtualBox Adapter Strategy to pick instead;

It almost seems to me like it should go into a Host-Only Adapter config for vboxnet1 or something, but I'm unsure about this.

The HowTo seems a little out of wack for modeling a real router virtually, since it's adding the guests to the Physical LAN via a Bridged Adapter which isn't the case in the bare metal world. (Maybe it's the intent?)

Now in the Bare Metal world, I would also have 4 ports for four different subnets, possibly with the same interface split into virtual nics. But none the less I would still have private subnets.

And incase of a screw up, I'd have a Serial TTY going into the physical device serving as the Management mng interface, at least in the beginning.

Please help me to select the VirtualBox Adapter Strategy that would be the closest to emulating a Bare Metal Router with a LAN Subnet.

You do not need a serial adapter for virtual machine - you have graphic console for that.
Yes, you can connect subnet with management interface via host-only network, but then clients must be other VM-s in other subnet.

1 Like

My intent was not to say that I needed a serial console, but rather to point to an equivalent in real life on the bare metal.

The HowTo states that the management interface is just put in place to make setting up the configuration easier since the Virtual ox Graphical Console sometimes doesn't display what you type.

If this detracts from the goal of my question to make it easier to read, I'm happy to remove it.


Conversely, my goal with the question is to find out which Virtual box "Attached to:" drop-down item I should use if I want to create a private LAN that would operate like that of the actual bare metal router on the non-WAN ports within the VM.

The problem with virtualization is that you need to be very much on top of the details (networking setup in particular) for your preferred hypervisor, which makes the situation 'uncommon' or more difficult. By default, most virtualization environments set up a virtual (NATed) subnet, to give the VM easy internet access - but that doesn't give other systems on your LAN access to this VM (you may get access via localhost and port forwarding). If you do want to host a server- or router VM, that is not sufficient, you need to make your VM a direct peer on your LAN (without the virtual NAT in the way), but this requires more complex configurations on the hypervisor host (be it via bridging and tap interfaces (some virtualization environments provide helpers for doing so, others expect you to do the configuration) or by passing through the whole PCIe network card into the VM).

If you are a beginner, a bog standard device running OpenWrt on the bare iron (this might very well be x86_64 with two network cards, but any supported device will do) makes it much easier for you.

If you are familiar with your virtualization environment, none of these questions tend to come up, because then you will be familiar with these details already anyways (as mentioned, it's not at all specific to router uses, but already comes up with (almost) any kind of server VM).

1 Like

Okay I got it to work.

Had to use the Internal Net Adapter strategy to get it working.

The Internal Net Adapter mimics adding a dumb-switch/unmanaged switch to the network;

In real life if you plug a network card from OpenWRT on an x86 into a dumb-switch/unmanaged switch, it can be used as a gateway for any other non-router machines plugged into the same switch.

To simulate the same thing in Virtualbox what you do is:2. 3. 4. 1. 2. 4.

How to Plug two machines into a dumb-switch/unmanaged switch in VirtualBox:

Setting up the OpenWRT x86 VM so it is plugged into the dumb-switch:

  1. Open Virtualbox.

  2. Click the OpenWRT VM in the left sidebar panel.

  3. Click the Settings gear at the top.

  4. The OpenWRT VV.V.V.V Setting dialog will appear.

    3.1 Select an adapter tab that is not yet used.

      - `Adapter 1` - `eth0`
      - `Adapter 2` - `eth1`
      - `Adapter 3` - `eth2`
      - `Adapter 4` - `eth3`
    
         - **NOTE:** In my case `eth0/Adapter 1` it was set to `Host-Only Adapter`
                  - Used for a `mng` connection into the router.
    
         - **NOTE:** In my case `eth1/Adapter 2` was a `NAT`
    
         - **NOTE:** **I clicked the `Adapter 3` tab, before proceeding**
    

    3.2 From the Attached to: dropdown select Internal Net.

      - If they had any sense they would call this dropdown `unmanaged switch`, but it's not called that.
    

    3.3 Then in the Name: textbox I typed openwrt_intnet_lan.

     - **NOTE:** Any client that will be "plugged" into this switch will have to have the same name written here so VirtualBox knows that OpenWRT and the router are plugged into the same dumb switch.  It's like writing a label on the physical-switch that reads `openwrt_intnet_lan`, so you know which switch it is, and that both machines are physically plugged into it.
    

Setting up a client VM so it is plugged into the dumb-switch:

  1. Open Virtualbox.

  2. Click the Client VM in the left sidebar panel.

  3. Click the Settings gear at the top.

  4. The Client Setting dialog will appear.

    3.1 Select an adapter tab that is not yet used.

      - `Adapter 1` - `eth0`
      - `Adapter 2` - `eth1`
      - `Adapter 3` - `eth2`
      - `Adapter 4` - `eth3`
    
         - **NOTE:** In my case `eth0/Adapter 1` was already set to `NAT`, 
                     but in order to make sure the packets went though OpenWRT router later, 
                     I disabled it, and left it there just in case.
    
         - **NOTE:** I clicked `Adapter 2`.
    

    3.2 From the Attached to: dropdown select Internal Net.

    1. In the Name: textbox type openwrt_intnet_lan

Now both devices will be plugged into the same dumb-switch/unmanaged virtual switch.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.