Use this repository to create your own OpenWRT image by running Debian in a virtual machine (VM).
The VM is configured automatically with Vagrant (https://vagrantup.com).
Download and install Vagrant for your operating system.
Download and install VirtualBox for your operating system.
Open the Vagrantfile
in a text editor. Update the following VM parameters to match the number of CPU cores and RAM you have. Do not assign all RAM to the VM, your computer may become unresponsive otherwise.
vb.memory = "10240"
(10 GB)vb.cpus = 6
Open a terminal and go to the directory containing the Vagrantfile
, then type:
vagrant up
This downloads a Debian VM and the OpenWRT git repository. When finished, the next steps are shown:
default: openwrt setup complete. now type:
default: vagrant ssh
default: cd openwrt.git
default: make menuconfig
default: make -j6 V=99
The above commands instruct you to configure OpenWRT from scratch using menuconfig
. If you have a previous OpenWRT config file, use the following method to build it directly.
- Change the name of the config file to
openwrt.config.autobuild
- Place it next to the
Vagrantfile
and - Run
vagrant up
In the logs, look for using configuration file openwrt.config.autobuild
to be sure the config file is used.
Some platforms, like Raspberry Pi, require to copy the OpenWRT image to an SD card.
On OS X, this can be done with the following commands:
- Show available hard disks before adding the SD card:
diskutil list
- Attach empty micro SD card to OSX (4 GB or bigger)
- Show available hard disks after adding the SD card:
diskutil list
- In this example, the SD card showed up as
/dev/disk4
. Change disk number in the following commands to match your setup.IMPORTANT: don't mix up disk numbers, you could delete all your data!
- Unmount the SD card:
diskutil unmount /dev/disk4s1
- Copy the openwrt image to the SD card:
sudo dd if=openwrt-*.img of=/dev/disk4 bs=1m
- Press ctrl-t to get the status. If it says
156+0 records out
this means that 156 MB have been copied as the block sizebs
is one megabyte1m
. - Unmount the sd card:
diskutil unmount /dev/disk4s1
Some platforms require to flash the OpenWRT image to the router using TFTP.
On OS X, this can be done like this:
-
Disconnect from all WiFi and Ethernet networks
-
Set a static IP to your Ethernet device in systems settings. Look up the exact IP depending on your router model in the OpenWRT wiki. This example will use
192.168.3.2
with a netmask of255.255.255.0
-
Change to the directory containing your OpenWRT image
-
Start
tftp
with the IP of the router, in this example192.168.3.1
:tftp 192.168.3.1 > binary > trace > put openwrt-*.trx
You only have to do this if you intend to change the OpenWRT version.
Look up latest OpenWRT version on github.com/openwrt/openwrt/tags or git.openwrt.org/openwrt/openwrt.git
Current (as of 2019) is v18.06.4
In the Vagrantfile
of this repository, update the variable called GIT_TAG
:
export GIT_TAG=v18.06.4
The Vagrantfile
uses a Debian VM from the bento project as the disc size of the the default Debian and Ubuntu images, provided by Vagrant, is too small.
Latest version of the Debian image can be found at app.vagrantup.com/bento.
Current (as of 2019) is bento/debian-10
openwrt-vagrant
Copyright (C) 2019 Jahn Bertsch
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.