Prerequisites
-
Download and install VirtualBox
-
Get an OpenWrt image:
-
Either use an existing image,
-
Download the generic combined image for x86 (32-bit), e.g. chaos_calmer/15.05.1/x86/) LEDE 17.01.1 x86
-
Download the generic combined image for x86_x64 (64-bit), e.g. chaos_calmer/15.05.1/x86/64) LEDE 17.01.1 x86_x64
-
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.
-
Notes
for x86_x64 (64-bit) make sure Intel VT-x or AMD-V is enabled, If you do not see this option in your motherboard, you must check the motherboard manual and specifications to identify whether the motherboard supports virtualization technology, Some of the old motherboards on Desktop or Laptop do not offer this feature, x86 is ok.
VM Setup in VirtualBox
-
Start VirtualBox
-
Click New to add a virtual machine (VM)
-
Choose a Name for your virtual machine
-
Choose
Linux
for your Operating System -
Choose
Other Linux (32 bit)
orOther Linux (64 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
Troubleshooting
-
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
-
-
If your virtual machine is booting and one of the messages seen is
Waiting for root device PARTUUID=-02…
and you compiled the image-
Make sure the machine you compiled the image on has the command
hexdump
anddd
installed on it before compiling the image
-
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 thelan
interface to useeth0
, and set an interface type and addressconfig interface 'lan' option ifname 'eth0' option type 'bridge' option proto 'static' option ipaddr '192.168.1.1' option netmask '255.255.255.0' # 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 withifup 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.