User Tools

Site Tools


OpenWrt in VirtualBox

This document describes how to run the OpenWrt x86 port in VirtualBox.


  • Download and install VirtualBox
  • Get an OpenWrt image:
    • Either use an existing image,
      • Download the generic combined image, e.g. chaos_calmer/15.05/x86/)
      • Uncompress the image if needed: gunzip openwrt.img.gz
      • Convert it to native VirtualBox format: VBoxManage convertfromraw --format VDI openwrt.img openwrt.vdi (in virtualbox version 5.0.12 the "--format VDI" is at the end of command)
      • For vmdk format : VirtualBox format: VBoxManage convertfromraw --format VMDK openwrt.img openwrt.vmdk
    • Or compile your own image (Target System → x86 and Target Images → Build VirtualBox image files). ext4 needs to be enabled first.

VM Setup in VirtualBox

  • Start VirtualBox

Initial Form

  • Click New to add a virtual machine (VM)

OpenWrt and Kernel version

  • Choose a Name for your virtual machine
  • Choose Linux for your Operating System
  • Choose Other Linux (32 bit) for your Version
  • Click Next
  • Optionally decrease RAM size from 256 MB to something smaller
  • Click Next

  • Choose Use existing hard disk
  • Click the file icon to open Virtual Media Manager

  • Click Add and choose your .vdi or .vmdk file using the dialog
  • Select your image in the list and click Select
  • Click Next and Finish

  • This concludes the VM setup!
  • Click Start to boot the OpenWrt VM

  • GRUB greets you, and boots using one of the available configurations (unless you intervene)
  • dmesg boot messages scroll by
  • Press Enter to activate the console


  • If your virtual machine boots but doesn't activate the console
    • Press Enter
  • If you rebuild the disk image, and VirtualBox complains about invalid UUIDs for the disk
    • You need to remove the disk from both the VM and also from the Virtual Media Manager
    • Then add the disk image to the VM again

Setting up networking

Enable Internet access through VirtualBox's NAT gateway

  • halt the VM if it runs
  • Open the VM's settings
  • In the Network tab
    • Configure Adapter 1 to use NAT
    • Configure Adapter 2 to use Bridge Adapter
      • Select your host machine's interface , e.g.wlp2s0 is wireless interface in Ubuntu 15.0
      • Best to disable promiscuous mode or its your choice
  • Boot into your openwrt VM
  • In file /etc/config/network do the following

 config 'interface' 'wan'
                  option 'proto' 'dhcp'
                  option 'ifname' 'eth0'
 config 'interface' 'lan'
                  #option type 'bridge'
                  option ifname 'eth1'
                  #option ip6assign '60'

  • Reboot openwrt VM

Your OpenWrt VM now has Internet access through VirtualBox's NAT gateway.

Set up networking with other VirtualBox VMs

  • halt the VM if it runs
  • Open the VM's settings
  • In the Network tab
    • Configure Adapter 1 to use internal network, and choose a name for it
    • If you also need Internet connectivity, configure another adapter to use NAT, as above.
  • Boot the VM
  • In file /etc/config/network configure the lan interface to use eth0, and set an interface type and address
    config interface 'lan'
            option ifname 'eth0'
            option type 'bridge'
            option proto 'static' 
            option ipaddr ''
            option netmask ''
    #       option ip6assign '60'  # Unused, no IPv6 in this example
  • If you want to use VirtualBox's internal network's DHCP server, use option proto 'dhcp'
  • Bring up the lan interface with ifup lan

Your OpenWrt VM can now interface with other VirtualBox VMs on your host that are also configured to use the internal network you set up.

doc/howto/virtualbox.txt · Last modified: 2016/06/24 10:17 by apparichit