User Tools

Site Tools


doc:howto:virtualbox

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:howto:virtualbox [2012/10/03 05:43]
evoltech
doc:howto:virtualbox [2016/06/24 10:17] (current)
apparichit [Setting up networking]
Line 1: Line 1:
 +====== OpenWrt in VirtualBox ======
 +This document describes how to run the OpenWrt x86 port in [[https://​www.virtualbox.org|VirtualBox]].
 +
 +===== Prerequisites =====
 +  * Download and install [[https://​www.virtualbox.org/​wiki/​Downloads|VirtualBox]]
 +  * Get an OpenWrt image:
 +    * Either use an existing image,
 +      * Download the //generic combined// image, e.g. [[https://​downloads.openwrt.org/​chaos_calmer/​15.05/​x86/​generic/​openwrt-15.05-x86-generic-combined-ext4.img.gz|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 [[about:​toolchain|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
 +{{:​inbox:​virtualboxwrt1.png?​600|Initial Form}}
 +  * Click //New// to add a virtual machine (VM)
 +
 +{{:​inbox:​virtualboxwrt3.png?​600|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//
 +
 +{{:​inbox:​virtualboxwrt4.png?​600|}}
 +
 +  * Choose //Use existing hard disk//
 +  * Click the //file// icon to open //Virtual Media Manager//
 +{{:​inbox:​virtualboxwrt5.png?​600|}}
 +  * 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//
 +{{:​inbox:​virtualboxwrt6.png?​600|}}
 +
 +  * This concludes the VM setup!
 +  * Click //Start// to boot the OpenWrt VM
 +
 +{{:​inbox:​virtualboxwrt9.png?​600|}}
 +
 +  * [[doc:​techref:​bootloader|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
 +
 +
 +===== 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
 +       <​code>​ config '​interface'​ '​wan'​
 +                  option '​proto'​ '​dhcp'​
 +                  option '​ifname'​ '​eth0'​
 +              ​
 + ​config '​interface'​ '​lan'​
 +                  #option type '​bridge'​
 +                  option ifname '​eth1'​
 +                  #option ip6assign '​60'​
 +                  </​code>​
 +  * 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 <​code>​config 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</​code>​
 +
 +/* See this discussion thread for more info on the "​ip6assign"​ option: ​
 +http://​comments.gmane.org/​gmane.comp.embedded.openwrt.devel/​24053 */
 +
 +  * 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.