OpenWrt in VirtualBox

This documents descripes howto run the OpenWrt x86 port in VirtualBox.

Prerequisites

  • Download and install VirtualBox
  • Get an OpenWrt image:

Convert OpenWrt raw image

This step is only required for older releases and snapshots. 10.03.1 and later provides native VirtualBox images.

Uncompress your image if needed:

gunzip openwrt.img.gz

Convert it to native VirtualBox format:

VBoxManage convertfromraw --format VDI openwrt.img openwrt.vdi 

VM Setup in VirtualBox

  • Start VirtualBox

Initial Form

  • Click New

Wizard

  • Click Next

OpenWrt and Kernel version

  • Choose a Name for your virtual machine
  • Choose Linux for your Operating System
  • Choose Linux 2.6 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 your .vdi or .vmdk file using the dialog
  • Select your drive from the list and click Select
  • Click Next and Finish

  • Right click your machine's entry on the machine list and choose Settings

  • add a disconnected, serial port to the machine (default is none available)

Troubleshooting

  • If your virtual machine won't boot, make sure your hard disk is connected using IDE (not SATA)
    • Right click your machine's entry on the machine list and choose Settings then select Storage
    • If you see that your hard disk image is connected to a SATA controller; under Storage Tree select the SATA Controller entry and then click Remove Controller
    • Click Add Controller and then select IDE Controller
    • Select the IDE Controller you just added and then click Add Attachment and choose Add Hard Disk
    • Add your OpenWRT image as before
  • If your virtual machine still won't boot, make sure you have a Serial Port enabled.
    • Enable a serial port under Settings then Serial Ports
  • If your virtual machine boots but doesn't activate the console
    • Press Enter

Set up networking with clients

  1. In the VirtualBox Settings for Network configure:
    • Adapter 1 to internal network with name OpenWrt-lan
    • Adapter 2 to Bridged adapter or NAT
  2. Boot up OpenWrt and add to /etc/config/network
    config 'interface' 'wan'
            option 'proto' 'dhcp'
            option 'ifname' 'eth1'
  3. Start the wan with ifup wan
  4. Create a new Virtual machine with your client operating system of choice
  5. On the client set Adapter 1 to internal network with name OpenWrt-lan
  6. Boot client

Back to top

doc/howto/virtualbox.txt · Last modified: 2012/04/07 22:31 by cybjit