THE PATCH PUBLISHED IN THIS ARTICLE IS NOT COMPLETE. AT LEAST THE VIRTUAL MACHINE WILL CRASH SPORADICALLY UPON RECEIVING NETWORK PACKETS USING THE VIRTUAL INTERFACES. I WIIL TRY TO FIX THIS ASAP.
- 5x 1Gbit copper ports (+ 1x SFP copper/fiber)
- 5x 100 MBit copper ports
- 128 MB of RAM and FLASH
- 802.11 b/g/n wireless interface
- a micro USB 2.0 port (that can be used to attach storage using an OTG cable)
- a small color touch display
- a CISCO-style RJ45 console port
All that is covered by a solid metal chassis and sold for ~120 € – not that bad.The LINUX-based routerOS offers an intuitive CLI – but there is no way to install private packages. So I had a look at openwrt.org to check if OpenWrt is running on this thingy… – it does. But after digging a little bit deeper I found something really awesome: it is possible to run up to 7 virtual instances of OpenWrt on top of the router OS using a mechanism called Metarouter. And each of the instances can be connected to the environment (the external network / other instances, …) using
- the physical network ports of the router and
- virtual interfaces connected to other virtual/physical interfaces using (LINUX-) bridges.
That creates the ability to reduce the footprint of my hardware infrastructure significantly by using (buzzword mode on) consolidation via virtualization (buzzword mode off). In fact, by using Metarouter(s) I’m able to replace two „fat“ routers (one running a public access point [currently a WRT 54G], another on used inside our home network [a TPLINK WR1043ND]) and a smaller one (TPLINK 703N) running my private JABBER server by one box. And the concept of having bridges connecting virtual and physical interfaces makes the whole setup a way easier to handle (splitting the network into a private and public network using just one WRT54G + OpenWrt was no fun). And at the end of the day I can keep all my configurations used in the old OpenWrt based setup…
The sad thing: MikroTik only provided support (by publishing patches) for OpenWrt up to Backfire (10.3, first release in 4/2010, 2.6.31) – and I was not able to find any sign that they will continue. Happily liquidcz from the MikroTik forum was able to create a patch usable for Attitude Adjustment (12.09, 4/2013, kernel 3.3). This worked fine – but the successor of AA – Barrier Breaker (10/2014, kernel 3.10.49) brought lots of updates (mainly related to the packages – but also to the kernel). I picket up liquidcz patch and adapted it to be usable with Barrier Breaker. And it was easier then expected :). So this is the outline on how to build OpenWrt Barrier Breaker to be used as a virtual instance on a MikroTik router:
build the firmware image for Mikrotik metarouter
wget http://openwrt.naberius.de/barrier_breaker/mr-mips/openwrt_metarouter_1407.patch git clone git://git.openwrt.org/14.07/openwrt.git barrier_breaker cd barrier_breaker patch -p1 &lt; ../openwrt_metarouter_1407.patch make defconfig make prereq make menuconfig # select 'Mikrotik MetaROUTER MIPS' as target system; save and exit, build... make -j $(nproc)
The created image is placed in bin/mr-mips/.
build additional packages
./scripts/feeds update -a ./scripts/feeds install -a make menuconfig # select the packages you need and run make again... make -j $(nproc)
You can find the packages in bin/mr-mips/packages/.
build all packages
# the option CONFIG_ALL=y (build all packages) didn't work for me # I removed all packages and re-installed them using the flag -d m - default for newly installed packages ./scripts/feeds remove -a ./scripts/feeds install -a -d m make -j $(nproc)
- if a build using make -j $(nproc) fails, rerun with make -j1
- if it still fails, rerun with make -j1 V=s
- if the builder is not able to fetch a packet, check if you could find another source and adapt the Makefile located in the packages// director
Since the flash storage of the router is accessible via FTP, the created image can be pushed down to the device using curl…
curl -T openwrt-mr-mips-rootfs.tar.gz ftp://192.168.1.120 --user admin:
Creating a virtual instance on the router is done using CLI metarouter command:
[admin@MikroTik] &gt; metarouter import-image file-name=openwrt-mr-mips-rootfs.tar.gz imported: 100% looking up /rw/vm/8 [admin@MikroTik] &gt; metarouter print Flags: X - disabled # NAME MEMORY-SIZE DISK-SIZE USED-DISK STATE 0 mr8 16MiB unlimited 6711kiB running [admin@MikroTik] &gt; metarouter console mr8 ... BusyBox v1.22.1 (2015-01-10 00:19:59 CET) built-in shell (ash) Enter 'help' for a list of built-in commands. _______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M ----------------------------------------------------- BARRIER BREAKER (Barrier Breaker, r43889) ----------------------------------------------------- * 1/2 oz Galliano Pour all ingredients into * 4 oz cold Coffee an irish coffee mug filled * 1 1/2 oz Dark Rum with crushed ice. Stir. * 2 tsp. Creme de Cacao ----------------------------------------------------- root@OpenWrt:/# free total used free shared ... Mem: 13480 10468 3012 -/+ buffers: 10468 3012
As you could see, BB is very demanding in the context of memory (even a stripped BB firmware – more or less all services from the default image removed, no IPv6 support – needs at least 9 MB). Since the stock router offers ~110 MB of free RAM you can easily run up to 4 instances where each uses 24 MB.
The setup of network interfaces is well documented in the metarouter manual and straight forward.
If you need to store a lot of data you can use the micro USB port to attach any USB storage using an OTG-cable:
[admin@MikroTik] &gt; store disk print Flags: S - system # NAME TOTAL-SPACE FREE-SPACE STATUS 0 S system 126976KiB 43440KiB ready 1 usb1 985192KiB 967532KiB ready
IMPORTANT: The USB drive must be formated with the (proprietary) MetaFS filesystem – so all data on the USB drive is lost.
Since the storage of the router is exported via FTP, curlftpfs can be used to mount a folder located on the attached USB drive into the local file system of an OpenWrt instance. Do not try to abuse the system as NAS device – the storage access eats the CPU (if you do a file transfer to the USB storage the CPU usage goes up to 100%).
ressources / links
original patch created by liquidcz: here
patch for Barrier Breaker: openwrt_metarouter_1407.patch
default fw image (Barrier Breaker, r43889): openwrt-mr-mips-default-image-rootfs.tar.gz
lowered memory footprint: openwrt-mr-mips-small-image-rootfs.tar.gz
image builder: OpenWrt-ImageBuilder-mr-mips-for-linux-x86_64.tar.bz2
binary packages: here