6184 words
31 minutes

Xiaomi AX3000T OpenWrt Guide: HomeProxy Traffic Splitting and WireGuard Remote Management

Xiaomi AX3000T OpenWrt Guide: HomeProxy Traffic Splitting and WireGuard Remote Management

Scope: Xiaomi AX3000T, focusing on hardware model RD03 and the installation route that retains the stock Xiaomi Bootloader. The examples use OpenWrt 25.12.6. This article provides a reusable decision process; it is not an unconditional universal flashing script for all AX3000T hardware versions, all stock firmware, and all Bootloaders.

Nature of this article: A reusable tutorial compiled from a real deployment record. It retains the verified main workflow and representative failures, while removing private information such as personal servers, home network details, device public keys, subscription tokens, and usernames. The VPS_PUBLIC_IP, <...>, and WireGuard 10.77.0.0/24 subnets in the examples are for demonstration only; replace them yourself.

Risk warning: Flashing involves writing to NAND flash and modifying NVRAM boot parameters. Writing the wrong MTD partition may make the device unbootable. Before executing ubiformat or nvram set, you must confirm the device model, stock boot partition, image type, and backup and recovery conditions yourself. Do not combine commands from different boot states in this article and execute them directly.

I. What You Can Ultimately Achieve

After completion, you will have the following structure:

Terminal window
Internet
│
上级光猫 / 路由器
│
AX3000T WAN
│
┌───────────────────┐
│ Xiaomi AX3000T │
│ OpenWrt / LuCI │
│ HomeProxy │
│ sing-box │
│ WireGuard client │
└───────────────────┘
│ │
LAN / Wi-Fi │ 加密 UDP 隧道
│ ▼
家中设备 公网 VPS (WireGuard Hub)
▲
│
手机蜂窝网络 WireGuard

The three goals are separated here to prevent them from interfering with each other:

  1. OpenWrt base system: Routing, Wi-Fi, DNS, LuCI, and package management work normally.
  2. HomeProxy + sing-box: Decide whether to connect directly or use an existing proxy node based on rules; the focus is resolving rule, DNS, and kernel compatibility issues.
  3. WireGuard remote management: A phone securely accesses the router management address through a VPS, without exposing the home LAN by default and without forwarding all home internet traffic to the VPS.

The latter two parts are optional modules: readers who only need OpenWrt can stop after completing the basic configuration.

II. Environment and Preparation

Item Example in This Article Description
Target device Xiaomi AX3000T (RD03) Subject to the device nameplate and device detection results
Stock firmware Example 1.0.64 Whether SSH unlocking applies depends on the actual version and vulnerability status
Chip platform MediaTek MT7981 / Filogic Not equivalent to every product called AX3000T
OpenWrt 25.12.6 This version uses the APK package manager
Bootloader route Retain the stock Bootloader The firmware file name must not contain ubootmod
Operating computer macOS / Linux Windows can use equivalent SSH and SCP tools
Flashing helper XMiR-Patcher Use only versions from trusted project repositories
Management connection Ethernet cable or temporary wired AP OpenWrt Wi-Fi is usually disabled on first boot
Remote access VPS with publicly reachable UDP Required only when enabling the WireGuard module

It is recommended to prepare in advance: a stable power supply, a reliable LAN management channel, at least one complete stock MTD backup, another disk that can store the backup independently, and accessible OpenWrt device documentation. A Mac without an RJ45 Ethernet port can connect to the router through a LAN↔LAN auxiliary AP, but you must disable the auxiliary AP's DHCP service in advance and avoid management IP conflicts.

192.168.31.1 (Xiaomi stock) and 192.168.1.1 (OpenWrt) in the following sections are common default management addresses. If your device has been modified, replace them with the actual addresses; these private addresses are not the author's real network topology.

III. Confirm the Model and Obtain Stock SSH Access

3.1 Check in the Stock Management Interface

  1. Log in to the Xiaomi stock management backend and check the current firmware version.
  2. Check the chassis label and hardware model, and confirm it is RD03.
  3. Do not blindly update to an unknown version just for flashing; different stock versions may affect the SSH unlock path.
  4. Confirm that the computer can access the router's stock management address.

3.2 Install XMiR-Patcher

Run in the computer's terminal:

Terminal window
git clone https://github.com/openwrt-xiaomi/xmir-patcher.git
cd xmir-patcher
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -r requirements.txt
python3 menu.py

Refer to the tool's current interface. Some versions can obtain SSH through a menu function similar to the following:

Terminal window
Connect to device (install exploit)
Read full device info
Create full backup

Connect and attempt to unlock first, then read the full device information. If the tool indicates that the current version is not supported, stop here; do not force-apply exploits or flashing methods for other models.

Stock SSH sometimes requires compatibility with older SSH host key algorithms. Only when the target is indeed a stock router that you manage yourself and you have verified the target host identity may you use the following for this connection only:

Terminal window
ssh -o HostKeyAlgorithms=+ssh-rsa \
-o PubkeyAcceptedAlgorithms=+ssh-rsa \
root@192.168.31.1

This is a compatibility measure for a specific legacy system and should not globally disable SSH security verification. When a host fingerprint prompt appears on the first connection, verify it before accepting; if stock unlocking uses a temporary default password, set a new OpenWrt root password immediately after flashing is complete.

3.3 Read Key Device Status

After successfully entering stock system SSH, run the read-only commands:

Terminal window
cat /proc/cmdline
cat /proc/mtd
uname -a

Pay special attention to:

  • Whether it is the expected mediatek/filogic and RD03 hardware.
  • firmware=0 or firmware=1 in /proc/cmdline.
  • Whether mtd8 is named ubi, whether mtd9 is named ubi1, and whether the capacity matches the device documentation.
  • Whether these commands are being run in the stock system rather than an already-flashed OpenWrt.

Key principle: This installation process first writes to the currently inactive UBI partition, then switches the boot parameters. Do not assume that your device should also write /dev/mtd8 just because someone else's device wrote /dev/mtd8.

IV. Fully Back Up Stock Partitions

XMiR-Patcher usually provides the Create full backup function. Before flashing, back up the entire Flash / all MTD partitions, not just save the configuration file exported from the router's web page.

Check the backup in the project directory:

Terminal window
find backups -maxdepth 1 -type f -name 'mtd*.bin' -exec ls -lh {} \;

It is recommended to confirm at least the following:

  • Backup of the entire Flash and partitions such as BL2, FIP, Factory, Nvram, Bdata, ubi, and ubi1 have been generated.
  • The file size matches the partition size shown in /proc/mtd.
  • Generate a SHA-256 manifest to make it easier to check later whether the backup files are corrupted.
Terminal window
cd backups
shasum -a 256 mtd*.bin > SHA256SUMS.local
cd ..

Note: Backups may contain Wi-Fi calibration information, MAC addresses, serial numbers, stock configuration, or other unique device data. Do not upload backups/, full_info.txt, or raw partition images to blogs, Git repositories, or public cloud drives. A second copy on the same machine is not off-site backup; preferably place it on another medium and save it encrypted.

V. Download and Verify the OpenWrt Image

This article demonstrates the route of retaining the stock Bootloader. Taking OpenWrt 25.12.6 as an example, the target platform is mediatek/filogic.

Two files need to be distinguished:

File Type Purpose Do Not Confuse
*-initramfs-factory.ubi Boot image written for the first time from the stock system Not the final sysupgrade file
*-squashfs-sysupgrade.bin Install the official system after entering the temporary OpenWrt environment Should not be used directly as the stock UBI first-flash image

Example download commands (run in the computer terminal):

Terminal window
VERSION=25.12.6
BASE="https://downloads.openwrt.org/releases/${VERSION}/targets/mediatek/filogic"
PREFIX="openwrt-${VERSION}-mediatek-filogic-xiaomi_mi-router-ax3000t"
mkdir -p firmware
cd firmware
curl -fL --retry 3 -O "${BASE}/${PREFIX}-initramfs-factory.ubi"
curl -fL --retry 3 -O "${BASE}/${PREFIX}-squashfs-sysupgrade.bin"
curl -fL --retry 3 -O "${BASE}/sha256sums"
# View the checksum values for the two matching items in the official list
# Note: verify the items whose filenames match exactly, not the ubootmod items
grep -F "${PREFIX}-initramfs-factory.ubi" sha256sums
grep -F "${PREFIX}-squashfs-sysupgrade.bin" sha256sums
# Compare the actual SHA-256 of the local file
shasum -a 256 "${PREFIX}-initramfs-factory.ubi"
shasum -a 256 "${PREFIX}-squashfs-sysupgrade.bin"
# Extract the two exact matches from the official sha256sums and compare them automatically
awk -v a="${PREFIX}-initramfs-factory.ubi" \
-v b="${PREFIX}-squashfs-sysupgrade.bin" \
'$2 == "*" a || $2 == a || $2 == "*" b || $2 == b { print }' sha256sums > SHA256SUMS.selected
# Two entries must be extracted, and each item must pass verification
if [ "$(wc -l < SHA256SUMS.selected | tr -d ' ')" -ne 2 ]; then
echo '文件名与校验清单不匹配,停止操作' >&2
exit 1
fi
shasum -a 256 -c SHA256SUMS.selected || exit 1
# Return to the xmir-patcher project directory and use the relative path firmware/ for subsequent operations
cd ..

As an official verification example for the specific 25.12.6 version, this article verified:

Terminal window
initramfs-factory.ubi
4ec4eb9d5d9e03cf437c0942d9389343e3b70536fbe3a84827db04fcb8482c2f
squashfs-sysupgrade.bin
286dbbaf16588c22daeaf6dbc8ca02573a1c30fbeb8592e3ba58b865c8726043

These two values correspond only to the exact file names and version above and are not universal checksums for other OpenWrt versions. When updating the version, re-download the official sha256sums. **Continue only when both items are OK. If SHA256SUMS.selected is empty, it means the file name or manifest format does not match, and you must not continue flashing.

Official image directory: https://downloads.openwrt.org/releases/25.12.6/targets/mediatek/filogic/

VI. Initial Flash: From the Stock System to OpenWrt

This part is the riskiest operation in the entire guide. If any check does not match the table below, stop flashing.

6.1 Upload the Initial Flash Image

Run this on the computer to transfer the file to the router's temporary memory directory /tmp:

Terminal window
scp -O \
-o HostKeyAlgorithms=+ssh-rsa \
-o PubkeyAcceptedAlgorithms=+ssh-rsa \
"firmware/openwrt-25.12.6-mediatek-filogic-xiaomi_mi-router-ax3000t-initramfs-factory.ubi" \
root@192.168.31.1:/tmp/ax3000t-initramfs.ubi

Uploading itself does not write to NAND. You can use sha256sum to verify the remote file; if the stripped-down stock system lacks this command, you can transfer it back over SSH and use the local cmp to perform a byte-for-byte comparison:

Terminal window
ssh -o HostKeyAlgorithms=+ssh-rsa \
-o PubkeyAcceptedAlgorithms=+ssh-rsa \
root@192.168.31.1 \
'cat /tmp/ax3000t-initramfs.ubi' \
| cmp - 'firmware/openwrt-25.12.6-mediatek-filogic-xiaomi_mi-router-ax3000t-initramfs-factory.ubi' \
&& echo '传输文件逐字节一致'

Only when you see "transferred files are byte-for-byte identical" does this comparison succeed; if SSH fails or cmp reports a difference, do not continue flashing.

6.2 Confirm the Boot Partition and Choose the Only Correct Branch

Run the following again under the stock SSH:

Terminal window
cat /proc/cmdline
grep -E '^mtd(8|9):' /proc/mtd
command -v ubiformat

Compare against the official OpenWrt AX3000T installation instructions:

Stock boot marker Currently running partition (must be confirmed on site) Initial flash target (inactive partition) Key NVRAM values
firmware=1 mtd=ubi1 /dev/mtd8 (ubi) flag_boot_rootfs=0, flag_last_success=0
firmware=0 mtd=ubi /dev/mtd9 (ubi1) flag_boot_rootfs=1, flag_last_success=1

Only when the actual /proc/cmdline, the partition table, and the official documentation all match may you choose the corresponding branch. The following commands are all run in the stock router SSH, and only one of the groups may be executed.

Branch A: Confirm firmware=1 mtd=ubi1

Terminal window
ubiformat /dev/mtd8 -y -f /tmp/ax3000t-initramfs.ubi
nvram set boot_wait=on
nvram set uart_en=1
nvram set flag_boot_rootfs=0
nvram set flag_last_success=0
nvram set flag_boot_success=1
nvram set flag_try_sys1_failed=0
nvram set flag_try_sys2_failed=0
nvram commit

Branch B: Confirm firmware=0 mtd=ubi

Terminal window
ubiformat /dev/mtd9 -y -f /tmp/ax3000t-initramfs.ubi
nvram set boot_wait=on
nvram set uart_en=1
nvram set flag_boot_rootfs=1
nvram set flag_last_success=1
nvram set flag_boot_success=1
nvram set flag_try_sys1_failed=0
nvram set flag_try_sys2_failed=0
nvram commit

After execution, read back and confirm using nvram get flag_boot_rootfs, nvram get flag_last_success, etc.; you may reboot only after the flash command returns normally without errors:

Terminal window
reboot

6.3 Enter the OpenWrt Temporary System for the First Time

After rebooting:

  1. Connect the management device to the AX3000T's OpenWrt LAN port. For this model, the official instructions specifically recommend using the middle LAN port on the chassis to avoid differences between the stock dynamic WAN/LAN assignment and OpenWrt's fixed port positions.
  2. Set the computer to obtain an IP automatically via DHCP. When using an auxiliary AP, ensure the AP is operating in transparent bridge mode and DHCP is disabled.
  3. Try opening http://192.168.1.1 and check the device name and OpenWrt version.
  4. If the page shows System running in recovery (initramfs) mode, it means you have entered the temporary boot environment. This only means the first stage succeeded; it does not mean the formal installation is complete.

If you cannot connect, first check the network port, Ethernet cable, DHCP address, and gateway; do not immediately write to flash again.

6.4 Install the Formal sysupgrade Image

In the LuCI interface of the temporary OpenWrt, go to:

Terminal window
System → Backup / Flash Firmware → Flash new firmware image

Select ...-squashfs-sysupgrade.bin on the computer and verify the uploaded SHA-256. For the first installation from initramfs, uncheck Keep settings (retain configuration) to perform a clean install; then confirm the flash and wait for the reboot.

Alternatively, you can use SSH to copy the formal image to /tmp/ in the temporary environment and then execute sysupgrade -n <path-to-image>; but the prerequisite is still that the device and Bootloader layout match exactly.

After the formal system reboots successfully, check:

Terminal window
ubus call system board
mount
df -h /overlay

Verify that initramfs has been exited, Overlay is writable, and LuCI works normally, then immediately set a strong root management password.

VII. Basic Network Configuration for OpenWrt

7.1 WAN, LAN, Wi-Fi

It is recommended to first achieve a minimal working setup:

  1. Configure WAN using DHCP, PPPoE, or a static address as required by the actual network.
  2. Keep an available management subnet for LAN and confirm it does not conflict with the upstream LAN.
  3. Enable 2.4 GHz and 5 GHz wireless, set the SSID and a strong password for each; choose WPA2/WPA3 according to device and client capabilities.
  4. Set the Wi-Fi country/region code according to the device's physical location, regardless of the region where the proxy node is located.
  5. First verify local Wi-Fi, LuCI, and basic internet access, then install traffic splitting, themes, or VPN.

7.2 How to Troubleshoot Package Download Failures

OpenWrt 25.12 and later versions use apk; do not copy the old opkg install commands verbatim.

Terminal window
apk update
apk search luci-i18n-base-zh-cn

If the update fails, troubleshoot in the following order:

Terminal window
ip -4 route show default
ifstatus wan
ping -c 3 1.1.1.1
nslookup downloads.openwrt.org
date -u
  • WAN has no IPv4/gateway: Check upstream address assignment and interface configuration.
  • IP is reachable, but domain name resolution fails: Check the DNS distributed by WAN DHCP, LAN DNS forwarding, and resolver, rather than repeatedly reinstalling the firmware.
  • DNS is normal, but HTTPS/package downloads are interrupted: Continue checking IPv4/IPv6, routing, time, MTU, certificates, and specific downloader errors.
  • Kernel module installation fails: Check the exact current kernel version and kmods source; do not force-install .ko from another version.

Some LuCI pages mark WAN in red as a firewall zone; this does not equal a link failure; rely on the actual interface status and network tests.

7.3 Installing LuCI Simplified Chinese

Terminal window
apk update
apk add luci-i18n-base-zh-cn

Then select Simplified Chinese in System → System → Language and Style. If the router itself has unstable downloads, you can download the official APK for the corresponding version and architecture on your computer, verify the source, and then transfer it to /tmp via SCP.

apk add --allow-untrusted /tmp/xxx.apk bypasses the signature trust verification for that local package; do not use it as the default solution for all download failures. Consider using it only after you have truly verified a trusted source, the package contents, and the risks.

8. Optional Module: HomeProxy + sing-box Traffic Splitting

This module is for legally managing proxy nodes and networks that you own or are authorized to use. HomeProxy is the LuCI management layer, and sing-box is the actual traffic processing core; subscription format, proxy core, rule sets, and DNS are four parts that need to be verified separately.

8.1 Why You Cannot Enable It Just by Importing a Subscription

Subscription content may be just a node list, or it may include global mode and empty rules. Having nodes does not mean having a correct routing traffic-splitting policy.

To achieve "direct connection for specific domestic traffic and proxying for other traffic that matches the rules," you should at least complete:

  • Trusted node import and connectivity checks (for example, Hysteria2, VLESS).
  • Primary TCP/UDP node selection and fallback policy.
  • Target traffic-splitting rules, rule set updates, and exceptions for LAN and reserved addresses.
  • DNS splitting and hijacking policy; evaluate the situation with UDP, IPv6, and client-built-in DoH.
  • Network recovery and locally available management entry points when the service is abnormal.

"Bypass mainland China" is a type of rule policy, and it does not guarantee that every domestic address, CDN, domain, and application will be routed as expected. Do not use the fact that a single website opens to prove that the full traffic splitting is correct.

8.2 Check System Resources and Package Compatibility

Terminal window
ubus call system board
df -h /overlay
free -m
apk update
apk search sing-box

Choose sing-box or sing-box-tiny according to your core needs; it is not recommended to install two conflicting variants at the same time; first read the build features of the current repository and confirm that the required QUIC/HY2, VLESS, DNS, and transparent proxy functions are actually available.

Dry run before installation:

Terminal window
apk add --simulate sing-box-tiny firewall4 kmod-nft-tproxy ucode-mod-digest

A dry run showing successful dependency resolution does not mean the actual installation is complete; after installation, you also need to check available RAM, Overlay, and runtime logs.

The HomeProxy management package should be obtained from a trusted maintenance project, and you should verify the OpenWrt/ImmortalWrt distribution, 25.12 APK format, CPU architecture, and sing-box version. A LuCI all.apk from one distribution may happen to run on another distribution, but this is not an official compatibility guarantee. Prioritize versions and build methods explicitly supported by the maintainer; do not mix an entire third-party package source into official OpenWrt and then perform bulk upgrades.

Reference: https://github.com/immortalwrt/homeproxy

  1. Install the proxy core and confirm that sing-box version is available.
  2. Install the HomeProxy page and confirm that the LuCI menu can be opened.
  3. Import nodes (do not paste sensitive subscription URLs or UUIDs into logs, screenshots, or public repositories).
  4. Set a primary node that definitely exists and the necessary UDP nodes; verify the routing mode, DNS, and rule set.
  5. First perform configuration checks with transparent proxy disabled:
Terminal window
# Only for the version where HomeProxy actually generates this path
sing-box check --config /var/run/homeproxy/sing-box-c.json
  1. Keep the LAN SSH management channel available; start it for a short test first, and only then consider persistence and auto-start on boot.
  2. Separately verify whether basic access, the proxy egress, and the domestic egress meet expectations, and record how to restore direct connection if they fail.

8.4 Two Typical Compatibility Failures

Fault A: The configuration generator reports an empty object or null value.

For example: attempt to set property on null value. This may be because the primary node ID saved by HomeProxy is invalid, or because the generation script does not match the configuration structure. You should first check whether the primary node reference actually exists, rather than deleting all subscriptions and reinstalling:

Terminal window
id="$(uci -q get homeproxy.config.main_node)"
[ -n "$id" ] && uci -q get "homeproxy.$id" || echo '主节点未配置或引用失效'

If it is confirmed invalid, select a node that actually exists in LuCI again and save it, then regenerate and check the configuration.

Fault B: sing-box 1.13 rejects legacy sniff inbound fields.

Some older HomeProxy builds still generate inbound configuration fields that have already been removed, such as sniff / sniff_override_destination; in this case, sing-box check will fail. The official sing-box migration approach is to use, in route.rules, rule actions such as action: sniff to replace the old fields. Prioritize upgrading to a HomeProxy version compatible with the current sing-box; if you must patch the generator yourself, back up the original file first, check the differences, and then perform an offline generation check. Simply deleting the old fields may change the traffic-splitting semantics and is not suitable as a general “one-click fix command”.

Reference: https://sing-box.sagernet.org/migration/

8.5 How to Validate, Rather Than Only Checking “Service Running”

Terminal window
pidof sing-box
/etc/init.d/homeproxy enabled; echo "exit=$?"
df -h /overlay
free -m

Ensure the test terminal actually accesses the internet through the AX3000T and has no additional local VPN, then test HTTPS responses to multiple targets and the egress IP before and after starting/stopping the proxy. Do not record real public IPs in test logs; you may record only CHANGED, UNCHANGED, and HTTP status. You should also confirm that the router can restore direct connection after the proxy is turned off.

Terminal window
curl --noproxy '*' -4 -sS -o /dev/null \
-w 'status=%{http_code} duration=%{time_total}s\n' \
--max-time 15 https://www.example.com

example.com is only used as an ordinary HTTPS connectivity example and does not serve as a “domestic/international” traffic-splitting determination. Real traffic-splitting validation requires independently selected, available test sites that are mutually independent, and cross-checking DNS, gateway, and egress addresses.

9. Optional Module: Glass Theme (Decoupled from Network Functions)

The theme only changes the presentation layer of LuCI and is not responsible for networking, DNS, proxy, or VPN. In this practice, Argon was tried first, and finally switched to Glass; the initial installation anomaly came from a repository/download issue, not an OpenWrt routing function failure.

The Glass maintainer has published an APK package repository for OpenWrt 25.12+. The following example applies only when you have verified and trust this third-party project and the repository still uses the corresponding release method:

Terminal window
# Run it over OpenWrt SSH; before actual execution, you can check the maintainer's latest README
mkdir -p /etc/apk/keys /etc/apk/repositories.d
wget -O /etc/apk/keys/glass-apk.rsa.pub \
https://raw.githubusercontent.com/rchen14b/luci-theme-glass/main/root/etc/apk/keys/glass-apk.rsa.pub
FEED='https://rchen14b.github.io/luci-theme-glass/apk/packages.adb'
touch /etc/apk/repositories.d/customfeeds.list
grep -qxF "$FEED" /etc/apk/repositories.d/customfeeds.list || \
printf '%s\n' "$FEED" >> /etc/apk/repositories.d/customfeeds.list
apk update
apk add luci-theme-glass

If you do not trust the third-party repository, cannot verify the source of the public key, or encounter signature anomalies, stop; do not globally disable verification just to install a theme. After installation, select Glass in System → System → Language and Style of LuCI.

If the theme causes the page to be inoperable, but you can still log in via LAN SSH, you can roll back to the default Bootstrap:

Terminal window
uci set luci.main.mediaurlbase='/luci-static/bootstrap'
uci commit luci
/etc/init.d/uhttpd restart

This operation only switches the theme and does not modify HomeProxy, WireGuard, or WAN. Reference project: https://github.com/rchen14b/luci-theme-glass.

10. Optional Module: Securely Managing the Router from the Internet with WireGuard

Here we use a structure with a public VPS as a relay Hub, suitable for scenarios where the home WAN is behind NAT and cannot be accessed directly from the public internet. Unlike a typical full-tunnel VPN, this tutorial uses a split tunnel and only forwards the WireGuard management subnet.

10.1 Planning Addresses and Least Privilege

All addresses below are examples, not actual deployment information:

Device WireGuard Virtual Address Purpose
VPS 10.77.0.1/24 WireGuard Hub
AX3000T 10.77.0.2/32 Accepts authorized management connections
Phone 10.77.0.3/32 Remote management client

Expected access permissions: Phone 10.77.0.3 → router 10.77.0.2, TCP 22/80/443. On the public VPS, bind the router and phone to separate WireGuard public keys and a single /32 address each, to prevent clients from impersonating other tunnel addresses. Do not configure allow policies from WireGuard to the entire home LAN or WAN; the VPS's 51820/UDP should only be used for WireGuard inbound.

10.2 VPS-Side Installation and Key Generation

Using Ubuntu 24.04 as an example:

Terminal window
sudo apt-get update
sudo apt-get install -y wireguard-tools
sudo install -d -m 700 /etc/wireguard
sudo sh -c 'umask 077; wg genkey > /etc/wireguard/wg0.key'
sudo sh -c 'wg pubkey < /etc/wireguard/wg0.key > /etc/wireguard/wg0.pub'

/etc/wireguard/wg0.key is the private key; do not put it in public logs, blogs, or version repositories. After obtaining the public keys of each endpoint, write the VPS's /etc/wireguard/wg0.conf:

Terminal window
[Interface]
Address = 10.77.0.1/24
ListenPort = 51820
PrivateKey = <仅填 VPS 本机私钥>
[Peer]
# Router
PublicKey = <ROUTER_PUBLIC_KEY>
AllowedIPs = 10.77.0.2/32
[Peer]
# Phone
PublicKey = <PHONE_PUBLIC_KEY>
AllowedIPs = 10.77.0.3/32

After saving, restrict file permissions and start the service:

Terminal window
sudo chmod 600 /etc/wireguard/wg0.conf
sudo wg-quick strip wg0 >/dev/null
sudo systemctl enable --now wg-quick@wg0
sudo wg show wg0
sudo ss -lunp | grep ':51820'

In the VPS cloud security group/host firewall, allow UDP 51820 separately. There is no need to expose LuCI's 80/443 or the router SSH port 22 directly to the public internet.

Clients forward traffic to each other through the same VPS, so the VPS needs IPv4 forwarding enabled:

Terminal window
echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/90-wireguard-forward.conf
sudo sysctl --system

Security note: Enabling IP forwarding only gives the host forwarding capability; it does not mean all forwarding should be allowed. The host firewall must restrict reachability between WireGuard peers.

10.3 OpenWrt-Side Installation and Interface Creation

Terminal window
apk update
apk add wireguard-tools kmod-wireguard luci-proto-wireguard

If kmod-wireguard (no such package) appears, first check the exact version of the currently running kernel and the corresponding OpenWrt kmods software repository, rather than immediately concluding that "WireGuard is not supported." This is especially easy to run into after an image upgrade or when the kernel version does not match.

Generate a dedicated key on the router:

Terminal window
umask 077
mkdir -p /etc/wireguard
wg genkey > /etc/wireguard/router.key
wg pubkey < /etc/wireguard/router.key > /etc/wireguard/router.pub
chmod 600 /etc/wireguard/router.key

Add the public key of router.pub to the router Peer on the VPS; write the VPS's public key into the OpenWrt peer configuration. The UCI snippet below is a new-device example; if a wg0 or vps_peer with the same name already exists, check first to avoid overwriting it.

Terminal window
cp /etc/config/network /etc/config/network.before-wg
uci set network.wg0='interface'
uci set network.wg0.proto='wireguard'
uci set network.wg0.private_key="$(cat /etc/wireguard/router.key)"
uci add_list network.wg0.addresses='10.77.0.2/32'
uci set network.vps_peer='wireguard_wg0'
uci set network.vps_peer.description='remote-management-vps'
uci set network.vps_peer.public_key='<VPS_PUBLIC_KEY>'
uci set network.vps_peer.endpoint_host='<VPS_PUBLIC_IP>'
uci set network.vps_peer.endpoint_port='51820'
uci set network.vps_peer.persistent_keepalive='25'
uci set network.vps_peer.route_allowed_ips='1'
uci add_list network.vps_peer.allowed_ips='10.77.0.0/24'
uci commit network
ifup wg0
ifstatus wg0
wg show wg0

This configuration writes the router's private key to /etc/config/network, so OpenWrt configuration backups are also sensitive files; before sharing the output of uci show network, remove the private key and any credentials.

If, after ifup wg0, proto: none or NO_DEVICE appears, first check whether the actual protocol script exists:

Terminal window
ls -l /lib/netifd/proto/wireguard.sh
ubus call network get_proto_handlers

Right after installing the protocol package, the running netifd may not yet have loaded the new protocol. If you have a reliable LAN management/recovery channel, you may consider running /etc/init.d/network restart and then ifup wg0 again. This operation will temporarily disconnect the network and SSH, so it is not suitable to execute directly on the only remote entry point.

10.4 Phone-Side Configuration

Create a tunnel in the WireGuard mobile client; the phone's private key is generated and saved directly on the phone. Example:

Terminal window
[Interface]
Address = 10.77.0.3/32
PrivateKey = <PHONE_PRIVATE_KEY,不外传>
[Peer]
PublicKey = <VPS_PUBLIC_KEY>
Endpoint = <VPS_PUBLIC_IP>:51820
AllowedIPs = 10.77.0.0/24
PersistentKeepalive = 25

Also configure the phone's public key and AllowedIPs = 10.77.0.3/32 in the VPS's [Peer]. On the phone side, do not set AllowedIPs to 0.0.0.0/0, unless you explicitly want to route all of the phone's IPv4 traffic through the VPN; the current goal is only to remotely manage the router.

10.5 Firewall: Only Expose Router Management Services

On the OpenWrt router side: Create a separate zone for wg0, deny inbound traffic from WireGuard to the router by default, and only allow the specified phone address to access the management port.

Terminal window
cp /etc/config/firewall /etc/config/firewall.before-wg
uci set firewall.wgmgmt='zone'
uci set firewall.wgmgmt.name='wgmgmt'
uci add_list firewall.wgmgmt.network='wg0'
uci set firewall.wgmgmt.input='REJECT'
uci set firewall.wgmgmt.output='ACCEPT'
uci set firewall.wgmgmt.forward='REJECT'
uci set firewall.allow_phone_mgmt='rule'
uci set firewall.allow_phone_mgmt.name='Allow-Phone-WireGuard-Management'
uci set firewall.allow_phone_mgmt.src='wgmgmt'
uci set firewall.allow_phone_mgmt.src_ip='10.77.0.3/32'
uci set firewall.allow_phone_mgmt.dest_ip='10.77.0.2'
uci set firewall.allow_phone_mgmt.proto='tcp'
uci set firewall.allow_phone_mgmt.dest_port='22 80 443'
uci set firewall.allow_phone_mgmt.target='ACCEPT'
uci set firewall.allow_phone_mgmt.family='ipv4'
uci commit firewall
fw4 check
/etc/init.d/firewall reload

Here, do not add forwarding rules for wgmgmt → lan or wgmgmt → wan, so the phone is not automatically allowed to access other clients on the home network.

On the VPS side: You also need to allow wg0 → wg0 forwarding from the phone to the router, allow return packets for established connections, and deny access between other WireGuard peers. The specific rules cannot be applied directly without considering the VPS's existing firewall architecture:

  • A typical VPS may use UFW, native nftables, or iptables.
  • After Docker is installed, FORWARD may be set by Docker to DROP, and the DOCKER-USER chain may exist.
  • iptables-nft and iptables-legacy are two different rule backends; one backend showing ACCEPT does not mean the other backend allows traffic.
  • Docker 29 can optionally use the native nftables backend; in that case, DOCKER-USER may not exist or take effect, and rules must be migrated according to the official Docker documentation.

You can first perform a read-only audit:

Terminal window
sudo iptables -V
sudo iptables-nft -S FORWARD
sudo iptables-nft -S DOCKER-USER 2>/dev/null || true
sudo nft list ruleset
sudo systemctl is-active docker || true

If the VPS is indeed running Docker's iptables-nft backend, the DOCKER-USER chain exists, and wg0 is the dedicated management tunnel, you can use the following scenario-specific example. This is not a universal command for all VPSs; before executing it, save a snapshot of the current firewall and prepare a recovery entry point via the cloud provider console.

Terminal window
# Run on the VPS; only add restrictions to client-to-client forwarding for wg0 -> wg0
sudo iptables-nft -S DOCKER-USER >/dev/null || {
echo 'DOCKER-USER 不存在:不要执行此分支'; exit 1;
}
sudo iptables-nft -N WG_ONLY_MGMT 2>/dev/null || true
sudo iptables-nft -F WG_ONLY_MGMT
# Allow the phone to send to the specified TCP management port on the router
sudo iptables-nft -A WG_ONLY_MGMT -s 10.77.0.3/32 -d 10.77.0.2/32 \
-p tcp -m multiport --dports 22,80,443 -j ACCEPT
# Allow the router to send replies; do not open new reverse connections
sudo iptables-nft -A WG_ONLY_MGMT -s 10.77.0.2/32 -d 10.77.0.3/32 \
-m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables-nft -A WG_ONLY_MGMT -j DROP
# Add a redirect rule idempotently; will not change the global FORWARD policy
sudo iptables-nft -C DOCKER-USER -i wg0 -o wg0 -j WG_ONLY_MGMT 2>/dev/null || \
sudo iptables-nft -I DOCKER-USER 1 -i wg0 -o wg0 -j WG_ONLY_MGMT
sudo iptables-nft -S WG_ONLY_MGMT
sudo iptables-nft -S DOCKER-USER

This example only controls forwarding between peers: you still need to restrict local access from wg0 through the VPS's INPUT firewall, and check whether other existing earlier rules bypass the restrictions. For pure nftables, UFW, iptables-legacy, or Docker 29's native nftables backend, do not copy this script. In addition, the example rules are runtime-only: they may be lost after a VPS or Docker restart, so they must be persisted according to the actual firewall management system, and restart recovery must be verified separately.

Do not run iptables -F, change FORWARD globally to ACCEPT, or directly overwrite Docker's default rules.

10.6 Verify Remote Management from a Cellular Network

  1. Run wg show wg0 on the router and confirm that there has been a recent handshake with the VPS.
  2. On the VPS, use wg show wg0 to confirm that both the router and phone peers are updating latest handshake and transfer counters.
  3. On the phone, turn off Wi-Fi and use the cellular network to connect to WireGuard.
  4. In the phone browser, visit http://10.77.0.2/cgi-bin/luci/; if trusted HTTPS is configured, prefer HTTPS.
  5. Also confirm that access to other unauthorized home LAN addresses fails, to verify that the least-privilege rules are actually in effect.
  6. Test separately whether automatic recovery works after rebooting the VPS, Docker, and router; without actual restart tests, you should not claim “permanently reliable.” This original record confirms that remote phone access succeeded, but does not confirm all restart scenarios or 24-hour stability.

WireGuard's latest handshake only proves peer key exchange; it cannot by itself prove that the VPS allows forwarding between clients, nor that the router firewall allows LuCI access.

11. Common Troubleshooting Reference Table

Symptom Check first Not recommended
XMiR-Patcher cannot unlock Model, stock firmware version, current tool support status Forcing an exploit for another model
Cannot access LuCI after flashing Physical LAN port, DHCP, computer gateway, temporary system state Immediately performing ubiformat a second time
Software feed update fails WAN, default route, DNS, time, HTTPS Repeatedly reflashing or arbitrarily switching to unfamiliar feeds
apk package signature is untrusted The package's actual source and key, architecture, version Globally disabling signature verification
HomeProxy menu does not appear Installation status, LuCI cache, rpcd and ACL Directly reinstalling OpenWrt
HomeProxy reports null value Main node reference, configuration generator Deleting all nodes and then randomly modifying JSON
sing-box reports legacy inbound fields Whether the generator matches the core version Deleting only the fields without verifying traffic-splitting semantics
WireGuard NO_DEVICE wireguard.sh, netifd protocol registration Repeatedly creating interfaces without checking
WireGuard has completed handshake but phone access fails VPS forwarding rules, Docker backend, router zone Setting all VPN input and forwarding to ACCEPT
Stops working after reboot systemd/procd autostart, rule persistence, Docker timing Treating “works once” as persistence verification

12. Maintenance, Backup, and Rollback

It is recommended to keep at least three types of backups, stored separately from public tutorials:

  1. Factory partition backups: original images such as MTD/Factory/NVRAM/Bootloader, kept offline and encrypted for personal use only.
  2. OpenWrt configuration backups: /etc/config, key custom scripts, and necessary /etc/wireguard files. Archives containing private keys must be encrypted and access-restricted, and must not be committed to public repositories.
  3. VPS backups: WireGuard configuration, necessary systemd units, custom firewall rules, and recovery instructions; avoid collecting or sharing plaintext private keys.

Common read-only health checks:

Terminal window
# OpenWrt
ubus call system board
ip -4 route show default
ifstatus wan
ifstatus wg0
wg show wg0
pidof sing-box || true
df -h /overlay
free -m
# VPS
# sudo systemctl status wg-quick@wg0 --no-pager
# sudo wg show wg0

If only a third-party LuCI theme is displaying incorrectly, consider restoring luci.main.mediaurlbase to /luci-static/bootstrap via SSH on an available LAN; if HomeProxy traffic splitting is abnormal, stop HomeProxy first and verify the routing/DNS recovery. Do not conflate "restoring a theme," "fixing the network," and "reflashing the firmware" into a single recovery action.

13. Boundaries and Trade-offs of This Solution

Choice Advantages Costs and Risks
Keep the factory Bootloader Fewer additional Bootloader changes Must strictly follow the factory UBI dual-partition and boot flag rules
Third-party HomeProxy management layer Configuring nodes and rules in LuCI is fairly intuitive Must match the core version; risk from maintaining third-party packages/scripts
sing-box-tiny May be more suitable when storage is tight Build features may differ; protocol support must be confirmed
Self-hosted WireGuard VPS relay Remote access still works behind home NAT, and access permissions can be narrowed VPS costs, forwarding firewall, key and update maintenance
Running Docker on the VPS at the same time Can reuse an existing server Docker's FORWARD, firewall backend, and restart timing may affect WG forwarding

Practical advice: Get basic routing running stably first, then add one component at a time, performing the corresponding health checks, connectivity verification, and configuration backups with each addition. Transparent proxying and remote management especially require retaining an independent LAN fallback entry point.


Official and Project References

Update note: This article is based on actual deployment records and relevant public documentation as of November 2, 2026. Firmware and packages will be updated; before execution, refer to the device's current state, official images, upstream repositories, and documentation for the current version. This article does not contain any actual VPS addresses, personal public keys, subscription links, or device identity information.

Share Article

If this article helped you, please share it with others!

Xiaomi AX3000T OpenWrt Guide: HomeProxy Traffic Splitting and WireGuard Remote Management
https://codqor.com/posts/ax3000t-openwrt-setup/
Author
Liam
Published at
Related PostsSmart
1
Xiaomi AX3000T Follow-up: OpenClash Primary/Backup Routing, WireGuard Coexistence, and Lag Troubleshooting
TechTwo weeks after flashing OpenWrt on the AX3000T: switching routing from HomeProxy to OpenClash (Meta core) with primary/backup lines, running WireGuard remote management alongside OpenClash, and tracing cross-ocean link lag from 41 KB/s to 7–8 MB/s.
2
My 256MB Router Can’t Run OpenClash, So I Built TinyLane and Open-Sourced It
TechThe Xiaomi AX3000T has only 256 MB of RAM, making OpenClash too much of a strain, so I packaged the sing-box core, a Go daemon, and a mobile panel into a single binary called TinyLane, with my daily readings at about 35 MB for the core and 20–28 MB for the panel. This article explains why I wrote it, what it can do, the memory pitfalls I hit, and how to install it; the project is open-sourced under GPL-3.0.
3
One API for Multiple TTS Providers: OpenAI Standard Parameter Mapping (MOSS Example)
TechWhen creating voiceovers for short videos, I used Edge TTS, Gemini, and MOSS together, each with different parameters. I later added /v1/audio/speech to my AI relay: clients call it using the OpenAI standard format while the gateway maps parameters per provider (for MOSS, just one line: voice→voice_id), and this article covers the parameter comparison table, mapping implementation, usage examples, and pitfalls.
4
Self-Hosting an Astro Blog: Pitfalls with R2 Image Hosting, D1, Caddy, and SEO
Techcodqor.com is itself an Astro static blog: posts are stored in Cloudflare D1, images in R2, pages are served from its own server via Caddy, comments use Turnstile, and there is an English mirror. This article records the build process and pitfalls in real chronological order, including overly long Bing titles, missed noindex directives, a build machine being cooled down, and the remediation approach after AdSense rejected the site for "low-value content."
5
Resend Email Sending from 0 to Launch: Domain Verification, Sending Relay, and Bounce Monitoring
TechA complete record of moving server notification emails from QQ Mail SMTP to Resend: choosing a new account and domain, DKIM/SPF/DMARC on Cloudflare, a sending API where only one relay holds the key, the gotchas that quota resets at UTC and receiving also consumes quota, Bark alerts for bounces, and protection against duplicate sends. Together with the previous post on Cloudflare receiving, it covers both sending and receiving.
Random PostsRandom

Comments

Leave a comment

Share your thoughts

Shown after review
Leave the name empty to post as “Anonymous”0 / 3000

Comments

Newest first · 5 at a time

Loading comments…

Profile Image of the Author
Liam
Notes on tech, life, and thoughts.
Categories
Tags
Latest Moments
Site Statistics
Posts
21
Categories
4
Tags
72
Total Words
87,292
Running Days
0 days
Last Activity
0 days ago
1
I. What You Can Ultimately Achieve
2
II. Environment and Preparation
3
III. Confirm the Model and Obtain Stock SSH Access
3.1 Check in the Stock Management Interface
3.2 Install XMiR-Patcher
3.3 Read Key Device Status
4
IV. Fully Back Up Stock Partitions
5
V. Download and Verify the OpenWrt Image
6
VI. Initial Flash: From the Stock System to OpenWrt
6.1 Upload the Initial Flash Image
6.2 Confirm the Boot Partition and Choose the Only Correct Branch
6.3 Enter the OpenWrt Temporary System for the First Time
6.4 Install the Formal sysupgrade Image
7
VII. Basic Network Configuration for OpenWrt
7.1 WAN, LAN, Wi-Fi
7.2 How to Troubleshoot Package Download Failures
7.3 Installing LuCI Simplified Chinese
8
8. Optional Module: HomeProxy + sing-box Traffic Splitting
8.1 Why You Cannot Enable It Just by Importing a Subscription
8.2 Check System Resources and Package Compatibility
8.3 Recommended Configuration Order
8.4 Two Typical Compatibility Failures
8.5 How to Validate, Rather Than Only Checking “Service Running”
9
9. Optional Module: Glass Theme (Decoupled from Network Functions)
10
10. Optional Module: Securely Managing the Router from the Internet with WireGuard
10.1 Planning Addresses and Least Privilege
10.2 VPS-Side Installation and Key Generation
10.3 OpenWrt-Side Installation and Interface Creation
10.4 Phone-Side Configuration
10.5 Firewall: Only Expose Router Management Services
10.6 Verify Remote Management from a Cellular Network
11
11. Common Troubleshooting Reference Table
12
12. Maintenance, Backup, and Rollback
13
13. Boundaries and Trade-offs of This Solution
14
Official and Project References
Table of Contents
1
I. What You Can Ultimately Achieve
2
II. Environment and Preparation
3
III. Confirm the Model and Obtain Stock SSH Access
3.1 Check in the Stock Management Interface
3.2 Install XMiR-Patcher
3.3 Read Key Device Status
4
IV. Fully Back Up Stock Partitions
5
V. Download and Verify the OpenWrt Image
6
VI. Initial Flash: From the Stock System to OpenWrt
6.1 Upload the Initial Flash Image
6.2 Confirm the Boot Partition and Choose the Only Correct Branch
6.3 Enter the OpenWrt Temporary System for the First Time
6.4 Install the Formal sysupgrade Image
7
VII. Basic Network Configuration for OpenWrt
7.1 WAN, LAN, Wi-Fi
7.2 How to Troubleshoot Package Download Failures
7.3 Installing LuCI Simplified Chinese
8
8. Optional Module: HomeProxy + sing-box Traffic Splitting
8.1 Why You Cannot Enable It Just by Importing a Subscription
8.2 Check System Resources and Package Compatibility
8.3 Recommended Configuration Order
8.4 Two Typical Compatibility Failures
8.5 How to Validate, Rather Than Only Checking “Service Running”
9
9. Optional Module: Glass Theme (Decoupled from Network Functions)
10
10. Optional Module: Securely Managing the Router from the Internet with WireGuard
10.1 Planning Addresses and Least Privilege
10.2 VPS-Side Installation and Key Generation
10.3 OpenWrt-Side Installation and Interface Creation
10.4 Phone-Side Configuration
10.5 Firewall: Only Expose Router Management Services
10.6 Verify Remote Management from a Cellular Network
11
11. Common Troubleshooting Reference Table
12
12. Maintenance, Backup, and Rollback
13
13. Boundaries and Trade-offs of This Solution
14
Official and Project References