@sehlceris/migrate-openwrt-router-config
v0.1.1
Published
Migrate OpenWrt router configurations between any two routers. Transfers VLANs, WiFi SSIDs, firewall rules, DHCP leases, and more — no hardcoded profiles needed.
Readme
migrate-openwrt-router-config
Migrate OpenWrt router configurations between any two routers. Transfers VLANs, WiFi SSIDs/passwords, firewall zones/rules, DHCP static leases, and more — with no hardcoded router profiles.
The tool auto-discovers hardware capabilities (LAN ports, radios, bands, ifname patterns) from backup files and interactively maps your source config onto the destination hardware.
Disclaimer
This has only been tested with one router transition: Belkin RT3200 (Linksys E8450) → GL-iNET MT6000 (Flint 2) Although this script should be generic enough and may be worth a try, please note that this has not been tested thoroughly. Be prepared and able to do a 30/30/30 reset on your router if things go wrong.
What it migrates
- VLANs / Bridge VLANs — network segmentation (LAN, IoT, Guest, Work, etc.)
- WiFi Networks — SSIDs, passwords, encryption, band assignments, client isolation
- Firewall — custom zones, rules, forwardings, port forwards (deduplicated with destination)
- DHCP — static leases, DHCP pools for custom networks
What it does NOT migrate (kept from destination)
- Installed packages
- WAN configuration (device, protocol, metrics)
- Radio hardware settings (channels, tx power, country code)
- SSH keys and certificates
- System hostname and timezone
- Root password
- Vendor-specific configs (GL-iNET, etc.)
Prerequisites
1. Back up both routers
Before running this tool, you need a backup .tar.gz from both your old (source) and new (destination) routers.
On each router:
- Open LuCI (usually
http://192.168.1.1) - Go to System → Backup / Flash Firmware
- Click Generate archive to download a
.tar.gzbackup
You should end up with two files, e.g.:
backup-old-router.tar.gz— the router you're migrating frombackup-new-router.tar.gz— the router you're migrating to (fresh or factory-reset)
2. System requirements
- Node.js >= 18
taravailable in PATH (standard on macOS/Linux)
Installation
Via npx (no install needed)
npx @sehlceris/migrate-openwrt-router-config <source-backup.tar.gz> <dest-backup.tar.gz>Global install
npm install -g @sehlceris/migrate-openwrt-router-config
migrate-openwrt <source-backup.tar.gz> <dest-backup.tar.gz>Local development (npm link)
git clone https://github.com/sehlceris/migrate-openwrt-router-config.git
cd migrate-openwrt-router-config
npm link
migrate-openwrt <source-backup.tar.gz> <dest-backup.tar.gz>Usage
Interactive mode (default)
migrate-openwrt backup-old-router.tar.gz backup-new-router.tar.gzThe tool will:
- Extract both backups into
source/,unmodified/, andmigrated/directories (next to the source backup) - Show you what it found in each backup
- Ask you to assign LAN ports to each VLAN/network
- Ask you which WiFi bands each SSID should broadcast on
- Show a migration plan summary
- Apply the migration and create
migrated-<date>.tar.gz
Folder mode
If both positional arguments are directories instead of .tar.gz files, the tool automatically uses folder mode — no extra flags needed. This is useful for testing and development.
migrate-openwrt source-config-dir/ dest-config-dir/In folder mode the tool:
- Skips tar extraction and archive creation
- Reads source and destination configs directly from the given directories
- Creates a
migrated/directory as a sibling of the destination directory - Overwrites
migrated/on re-run - Prints the migrated directory path instead of an archive path
Non-interactive mode
migrate-openwrt -y \
--port-map lan=lan1,lan2,lan3 \
--port-map iot=lan5 \
--port-map work=lan4 \
backup-old.tar.gz backup-new.tar.gzOptions
| Flag | Description |
| ------------------------- | ------------------------------------------ |
| -y, --non-interactive | Accept all defaults without prompting |
| --port-map NAME=PORTS | Assign LAN ports to a network (repeatable) |
After migration
- Review the files in
migrated/etc/config/before uploading - Have physical access to the router in case a factory reset is needed
- Set the root password separately after restoring the backup
How it works
- Extracts both backup archives
- Discovers destination hardware from its config (bridge ports, radios, ifname patterns, vendor)
- Extracts logical configuration from the source (VLANs, SSIDs, firewall rules, DHCP leases)
- Maps source config onto destination hardware (port assignment, band selection)
- Merges source config into a copy of the destination backup, preserving vendor-specific and hardware-specific settings
- Archives the result as an OpenWrt-compatible backup
Supported routers
Any OpenWrt-based router should work. Tested with:
- Belkin RT3200 (Linksys E8450) → GL-iNET MT6000 (Flint 2)
The tool handles differences in:
- LAN port count and naming
- WiFi driver types (mac80211 vs mtk)
- Bridge VLAN (DSA) configurations
- Vendor-specific extensions (GL-iNET glconfig, etc.)
Publishing to npm
# Log in to npm (one-time)
npm login
# Publish (scoped packages are private by default, use --access public)
npm publish --access publicLicense
MIT
