Networking is an art, bringing together the best from around the world
More and more Makers are starting to experiment with OpenWrt, but as a beginner Maker, it’s still hard to find a systematic entry-level resource online. Finding information is tough, and the barrier to entry for OpenWrt is relatively high. I hope this article is useful for those starting from scratch with OpenWrt.
OpenWrt originated from Cisco/Linksys, which released the WRT54G wireless router in 2003. That same year, someone discovered that its IOS was based on Linux. However, Linux is released under the GPL license, which means Cisco should have made the source code for WRT54G’s IOS public. In March 2003, Cisco, under public pressure, released the source code for WRT54G. Since then, there have been several third-party router firmware based on Cisco’s source code, and OpenWrt is one of them. Other similar third-party router firmware includes Merlin, DD-RT, Lede, and Tomato.
Features of OpenWrt:
-
Good extensibility, with over 1000 available packages for online installation;
-
A complete Linux workstation, with a read-write file system, making it easy for developers to learn and practice;
As more and more Makers start to experiment with OpenWrt, it is still difficult for a beginner Maker to find a systematic entry-level resource online. Finding information is tough, and the barrier to entry for OpenWrt is relatively high. I hope this guide to compiling, flashing, and using OpenWrt from scratch can lower the entry difficulty for beginners. Of course, compiling is not mandatory; stable firmware can generally be found for direct flashing.
Official Website:https://openwrt.org/zh/start
Setting Up the Compilation Environment
1. Install Ubuntu (compiling requires a Linux environment), download it from the official website, and choose the version according to your needs. You can install it on a virtual machine or a physical machine, with a graphical installation that is in Chinese. If you can’t even manage the installation, you might want to reconsider;
2. Remember not to change the software source, and press Ctrl + Alt + T to open the terminal;
3. Enter the following commands one by one (verify whether the installation is successful in time):
sudo apt-get install g++
sudo apt-get install libncurses5-dev
sudo apt-get install zlib1g-dev
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install unzip
sudo apt-get install autoconf
sudo apt-get install gawk
sudo apt-get install make
sudo apt-get install gettext
sudo apt-get install gcc
sudo apt-get install binutils
sudo apt-get install patch
sudo apt-get install bzip2
sudo apt-get install libz-dev
sudo apt-get install asciidoc
sudo apt-get install subversion
sudo apt-get install sphinxsearch
sudo apt-get install libtool
sudo apt-get install sphinx-common
The compilation environment is now set up.
Downloading OpenWrt Source Code and Compiling
OpenWrt source code comes in two types: one is the latest but not the most stable Trunk development version, and the other is the most stable Backfire version. It is recommended to download the official source code. Before downloading, create a folder locally:
mkdir openwrt
sudo chmod 777 openwrt
cd openwrt
Choose the version you want and execute the download command. When the download is complete, the version number will be displayed:
Trunk version download command:
svn co svn://svn.openwrt.org/openwrt/trunk/
Backfire version download command:
svn co svn://svn.openwrt.org/openwrt/branches/backfire/
Add software packages, change feeds.conf.default to feeds.conf:
cp feeds.conf.default feeds.conf
Update extensions and install them:
./scripts/feeds update -a
./scripts/feeds install -a
Note: If it is not the freshly downloaded source code, to keep the code up to date, you should regularly run the svn update command to update the source code.
Test the compilation environment:
make defconfig
At this point, you can start compiling your firmware. Enter the customization interface:
make menuconfig
If everything is normal, a configuration menu will appear where you can select the firmware platform (chip type), model, and the functions and components to add to the firmware. After configuring, save and exit the menu.
If you want to modify the source code, you should do so at this step, such as supporting large capacity Flash modifications. After finding out what files and where to modify online, you can find the files in the Ubuntu graphical interface, double-click to open the text editor, modify, and save.
Start compiling:
make
or
make V=99
or
make -j V=99
make is the compilation command, V=99 indicates output debug information, V must be uppercase. If you want the CPU to compile at full speed, add the -j parameter. It is best not to use the -j parameter for the first compilation.
Keep the network connected during the compilation process (as some source packages will be downloaded from the internet), so losing the connection may cause the compilation to stop. The time required for compilation is greatly related to the computer’s CPU and network environment; the first compilation takes longer, ranging from half an hour to 2-3 hours, while subsequent compilations take less time. After compilation, a bin folder will appear in the source code directory (e.g., trunk/bin/XXXX). If your router has the original firmware, you need to choose the XXX-factory.bin firmware to flash OpenWrt. If the router has already flashed OpenWrt, choose the upgrade firmware XXXX-sysupgrade.bin for the upgrade. You can find the firmware you need in the folder and transfer it out (via email, cloud storage, USB drive, etc.) to start flashing.
Flashing OpenWrt onto the Router
To use OpenWrt on a router, you must first flash the router firmware to OpenWrt, which is equivalent to installing the OpenWrt system. The installation methods may vary for different models of routers, but generally, there are three common methods:
-
Web upload firmware update
-
PFTP upload firmware update
-
Programmer write firmware
Which method or methods are suitable for your specific router model needs to be tried out by yourself.
Part Four: Getting Started with OpenWrt
To configure OpenWrt, there are generally two ways:
-
SSH login via command line control
-
Web login via web interface settings
After installing OpenWrt for the first time, you need to set a password to use SSH login. You can do this by logging in via telnet or web to set the password. In Windows, you can use Putty for telnet and SSH login, while in Linux or Mac, you can use the following commands:
ssh –l root 192.168.1.1 //Linux
ssh [email protected] //Mac
General commands are the same as those in common Linux distributions, but OpenWrt uses its own package manager: opkg. Use “opkg –help” to view help information. Here are some common operation commands:
opkg update //update package list
opkg install //install package online
opkg remove //remove package
Log in to the web management interface, provided that the OpenWrt system has the web interface installed, usually Luci. The login method is no different from that of ordinary routers; just open the browser and enter the router’s IP to access the login interface. The default IP for OpenWrt is 192.168.1.1.
At this point, the door to OpenWrt has been opened for you. Next, start trying to use OpenWrt for more intelligent applications, such as multi-line dialing to extract carrier bandwidth, binding domain names for remote control, mounting large capacity hard drives, setting up BT download machines, setting up network cameras, Samba/DLNA home NAS sharing, private cloud synchronization, FTP, personal websites/servers…
Long press the QR code to follow the premium network play