An example of installing OpenWrt on a Xiaomi Redmi AX6000 router from Linux
Greetings!

In this note I’ll tell you how I chose a router and installed a Linux-based firmware on it — OpenWrt 🧑💻. All actions were performed in the distribution environment of LMDE6 (Debian 12).

Preface

Recently I found myself needing to replace my router, since the old one didn’t satisfy my needs in terms of functionality. One of these needs was the ability to connect the router to a secure network via the OpenConnect protocol. I knew that this functionality is available in the OpenWrt firmware😎.

OpenWrt is an open source Linux-based operating system designed to run on routers and other embedded devices. Unlike standard firmware, OpenWrt provides a full-fledged file system with the ability to install and manage packages, which allows you to modify and extend the device’s functionality.

openwrt.org

The main reason for choosing this firmware is, of course, Linux under the hood🔥.

As for choosing a router for OpenWrt, I didn’t overthink it much. A quick Google search led me to an article on Habr, which lists devices with detailed descriptions that are known to work with this firmware. I settled on a router from Xiaomi: Redmi AX6000, since it’s top for the money a reasonable price-to-performance ratio🚀.

Here are some of its specifications:

ModelRedmi AX6000
CPUMediaTek MT7986A
CPU MHz2000
CPU Cores_numcores4
Flash MB128
RAM MB512
WLAN HardwareMediaTek MT7976GN, MediaTek MT7976AN
Ethernet 1Gbit ports4

Source

I bought the router on one of the marketplaces a few months ago for 7400 rub. Now its price has gone up a bit (around 9000 rub), but nevertheless this model remains a good choice in its segment.

Among the downsides: the router was released for the Chinese market, so its stock firmware is in Chinese🤯. Also, the seller may not include an adapter for a European outlet, so you’ll have to buy one separately💰:

The default web interface address of the router:

BASH
http://192.168.31.1
Click to expand and view more

pain

Finding any settings was difficult for me🤕.

Preparation

I installed OpenWrt on the purchased router using scripts from a GitHub project — XMiR-Patcher. This project is designed for flashing Xiaomi routers with alternative firmware, such as OpenWrt.

Briefly about the main scripts in the repository:

By the way, XMiR-Patcher works on Linux, as well as MacOS and Windows. It requires a Python🐍 interpreter version 3.8 or higher.

Let’s get started with preparation. Open the terminal and install the version control system git and the python module for working with a virtual environment:

BASH
sudo apt install git python3-venv
Click to expand and view more

Now let’s clone the xmir-patcher repository files and set up the virtual environment (venv):

BASH
git clone https://github.com/openwrt-xiaomi/xmir-patcher

cd xmir-patcher

python3 -m venv venv

source ./venv/bin/activate

python3 -m pip install -r requirements.txt
Click to expand and view more

Click to view a description of the commands above

If everything went smoothly, exit venv with the command:

BASH
deactivate
Click to expand and view more

Now we need to determine the latest version of OpenWrt supported by the router. For the Redmi AX6000, go to the router’s page on the OpenWrt website and find the line “Supported Current Rel”. At the time of writing, this is OpenWrt version 23.05.4:

After finding out the version, go to the downloads section, to the page for the needed release:

Here we’re interested in filogic — mediatek:

By the way, here’s the page we need for version 23.05.4.

On this page we need the link to the file named xiaomi_redmi-router-ax6000-stock-initramfs-factory.ubi:

Download the needed file into the firmware directory in the parent directory of xmir-patcher using curl:

BASH
curl -fLO https://archive.openwrt.org/releases/23.05.4/targets/mediatek/filogic/openwrt-23.05.4-mediatek-filogic-xiaomi_redmi-router-ax6000-stock-initramfs-factory.ubi \
    --output-dir ./firmware/
Click to expand and view more

Preparation is complete, let’s move on to the actual flashing⬇️.

Installing OpenWrt

While in the ./xmir-patcher directory, run the run.sh script, which should bring up an interactive menu:

BASH
./run.sh
Click to expand and view more

Select option 1. Here we’ll be asked to enter the router’s IP address:

BASH
1

# default address
192.168.31.1
Click to expand and view more

Next, select 2 to connect to the device and install the exploit😱:

BASH
2
Click to expand and view more

The script will prompt you to enter the router’s web interface password, we enter it:

Next, the script should enable the SSH server on the router for further configuration:

It’s probably worth doing a full backup (option 4), but honestly I didn’t do it🫣.

After completing the previous step, we move on to installing the firmware file from the firmware directory, which we downloaded earlier with curl. Select option 7:

BASH
7
Click to expand and view more

⚠️Never turn off the router’s power during the update!

At the end of the command output you should see “The firmware has been successfully flashed” and a message about sending the reboot command to the router via SSH:

In my case, the script displayed a timeout message while waiting for a response to the restart command:

But the router rebooted successfully, and when navigating in the web browser to the router’s address (the address had changed) I saw the already-familiar Luci interface😌:

BASH
http://192.168.1.1
Click to expand and view more

Successful success, in my case. Don’t forget to set an administrator password.

Installing system updates

The next step is installing OpenWrt system updates. To do this, go to the page where we previously got the firmware and download in your web browser the file named xiaomi_redmi-router-ax6000-stock-squashfs-sysupgrade.bin:

Or copy the link and download it via terminal:

BASH
curl -fLO https://archive.openwrt.org/releases/23.05.4/targets/mediatek/filogic/openwrt-23.05.4-mediatek-filogic-xiaomi_redmi-router-ax6000-stock-squashfs-sysupgrade.bin
Click to expand and view more

Next, go to the router’s web interface, here: http://192.168.1.1/cgi-bin/luci/admin/system/flash:

And upload the update file in the Flash new firmware image section:

Confirm:

❗️Never turn off the router’s power during the update!

Done:

The OpenWrt installation is complete😌.

Afterword

I expected the router flashing process to be more complicated, but it turned out to be quite simple, since most of the work was done by the scripts of the xmir-patcher project. After installing OpenWrt, I successfully configured the router’s client connection to the OpenConnect server, which I deployed in docker in one of the previous articles. I might write a note on this topic so I don’t forget it myself. I also set up selective routing through OpenConnect based on a specified list of DNS addresses… but that’s a different story😎.

All the best!

Sources used

Copyright Notice

Author: Ivan Cherniy

Link: https://r4ven.me/en/hardware/primer-ustanovki-openwrt-na-router-xiaomi-redmi-ax6000-iz-pod-linux/

License: CC BY-NC-SA 4.0

Blog materials may be used with attribution to the author and source, for non-commercial purposes, and under the same license.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut