User Tools

Site Tools


doc:howto:vmware

OpenWrt on VMware HowTo

This article describes how to use OpenWRT as a virtual machine with VMware virtualisation.

Tested with:

  • Barrier Breaker 14.07 in combination with VMWare ESXi 5.5 Update 2 Build 2068190
  • Chaos Calmer 15.05 with VMware Fusion and ESXi 6.0

Things you need:

First of all, you need to download the image from list above on your machine. After that you extract & convert it to a vmdk image:

gunzip openwrt-x86-generic-combined-ext4.img.gz
qemu-img convert -f raw -O vmdk openwrt-x86-generic-combined-ext4.img openwrt-x86-generic-combined-ext4.vmdk

or

yum -y install qemu-img
wget https://downloads.openwrt.org/chaos_calmer/15.05/x86/64/openwrt-15.05-x86-64-combined-ext4.img.gz
gunzip openwrt-15.05-x86-64-combined-ext4.img.gz
qemu-img convert -f raw -O vmdk openwrt-15.05-x86-64-combined-ext4.img openwrt-15.05-x86-64-combined-ext4.vmdk

or on a Mac

brew install qemu
qemu-img convert -f raw -O vmdk ~/Downloads/openwrt-15.05-x86-64-combined-ext4.img openwrt-15.05-x86-64-combined-ext4.vmdk

after that, just create a new VM in Fusion, Workstation, or ESXi with "Linux\Other Linux 32-bit" with LSI BUS Logic & add the vmdk there. Use Intel PRO/1000 Network adapters. This may require editing the .vmx file to include following definition:

ethernet0.virtualDev = "e1000"

On Fusion I had to use the IDE drive controller type.

Quick Start… follow these steps to get a VM up and running on ESX in 15 minutes:

  1. you can download an OVA image from the following location: https://dl.dropboxusercontent.com/u/7976972/openwrt15cc.ova
  2. This image was made by Iben in September 2015 based on a July build of CHAOS CALMER 15.05 trunk r46767
  3. Import the OVA to VMware ESXi (tested with latest version 6 in July 2016)
  4. The base image only has 1 virtual NIC setup with DHCP
  5. Power on the VM - observe the MAC Address - find that on you DHCP server
  6. Confirm the OpenWRT VM's IP address by opening the console
  7. Press enter to get a prompt
  8. Type ifconfig | more to see the DHCP assigned IP address for the Bridge assigned to the NIC
  9. If you don't have a DHCP server on your network you can set the IP Address manually:
  10. vi /etc/config/network
  11. The whole goal here is to get the OpenWRT VM on the network so you can hit the LuCI Web User Interface with a web browser. This way we can update the base image.
  12. Once you've logged in to the LuCI web interface set a root password so you can ssh in
  13. With the Web UI navigate to the System/Flash Operations page and find this text:
  14. Flash new firmware image - Upload a sysupgrade-compatible image here to replace the running firmware. Check "Keep settings" to retain the current configuration (requires an OpenWrt compatible firmware image).
  15. On your admin system with the web browser download this file to prepare for the flash upgrade of OpenWRT: https://downloads.openwrt.org/chaos_calmer/15.05.1/x86/generic/openwrt-15.05.1-x86-generic-combined-ext4.img.gz
  16. Then upload that to your running OpenWRT system and click "Flash Image…"
  17. Reboot and login again.
  18. Current latest version is: BusyBox v1.23.2 (2016-01-02 14:04:44 CET) built-in shell (ash) CHAOS CALMER (15.05.1, r48532)
  19. Now you can add the second NIC to use the OpenWRT VM as a WAN router. I set mine up with both DHCP and Static IP addresses for the WAN - and the LAN interface was configured as a DHCP server.
  20. To prepare for testing: install iperf3 and nmap from the System/Software page of the Web UI.
  21. See the testing section below for details…
  22. That's pretty much it. I'm very happy with this new setup. I was also looking at M0n0wall (monowall), and pfsense to run as VMs but OpenWRT has a lot more going for it as far as an Open Source eco-system and developer/vendor support.

Testing

  1. Start the server on OpenWRT: iperf3 -s
  2. Download the iperf3 binaries for various Operating Systems from here: https://iperf.fr/iperf-download.php
  3. Then install and run the client on other machines on your network.
  4. iperf3 -c <ip-address-of-the-server>
  5. Here are some results from my system:
  6. 2012 MacBook with 802.11n on 5GHz –> 284 Mbits/sec
  7. 2011 MacMini with CentOS 7.1 –> 958 Mbits/sec
  8. Ubuntu VM running on same old Dell T110 ESXi host and OpenWRT VM –> 4.14 Gbits/sec

As you can see - the OpenWRT virtual machine running on VMware ESX is very capable of keeping up with your home internet router needs! And this is with only 1 virtual CPU and no tuning at all.

ToDo List

Here's a wish list of things we would like to accomplish with OpenWRT - consider this technical debt.

(Is there a better place to make these requests?)

  1. install open-vm-tools to enhance support on VMware hypervisors
  2. install cloud-init capabilities to allow auto-configuration on OpenStack based clouds like OPNFV
  3. create jenkins job as part of CI to download and convert the raw image to vmdk with each build
  4. create jenkins job as part of CI to download and convert the raw image to qcow2 with each build
  5. do these conversions for both stable and trunk
  6. integrate OpenWRT into the CI Pipeline for other network testing projects like OPNFV

Disk size and problems with veeam backup and enlarging the disk

Veeam backup and vmware will complain about the size of the virtual disk provided by the openwrt download because the disk is not multiple of 1KB. (this means: no backups available, and could be crucial in production environments)

Vmware won't let you enlarge the disk in the normal way, so one simple way is:

. make a snapshot of the vm, for possible rollback
. move the original disk (from openwrt downloads) on ide 0:1
. add a new disk, with a whole size, like 128 MB , on ide 0:0
. use sysrescuecdiso
. start the vm with the iso
. with dd copy the disc on ide 0:1 to ide 0:0 like
dd if=/dev/sdb of=/dev/sda
. enter fdisk /dev/sda and write the partition table
(without making changes, this helps sysrescuecd to see the partitions properly)
. do fsck -f on the sda2 partition
. with fdisk resize the sda2 partition to occupy all the space available 
(but still starting with the same sector of before, normally 9135)
. use resize2fs /dev/sda2
. do fsck -f /dev/sda2
. restart the machine and boot with openwrt check that the system uses the new partition
. stop the machine, delete the previous hd (with less than 128mb)
. restart the machine and verify that everything is ok.


doc/howto/vmware.txt · Last modified: 2016/07/30 20:51 by Iben