Skip to content

Instantly share code, notes, and snippets.

@HackingGate
Created September 7, 2025 08:55
Show Gist options
  • Select an option

  • Save HackingGate/2d648b4b44b7da7f61398a6c70cdc181 to your computer and use it in GitHub Desktop.

Select an option

Save HackingGate/2d648b4b44b7da7f61398a6c70cdc181 to your computer and use it in GitHub Desktop.
OpenWrt v6plus Setup Script
#!/bin/sh
# OpenWrt v6plus Setup Script
# Slightly modified from: https://qiita.com/site_u/items/24bc0823986784cfb96c
# This script automates the configuration of MAP-E for v6plus on OpenWrt.
echo "--- [Step 1/5] Configuring IPv6 network device ---"
# Add a new network device for IPv6
uci add network device >/dev/null 2>&1
uci set network.@device[-1].name='lan1'
uci set network.@device[-1].mtu='1500'
uci set network.@device[-1].ipv6='1'
uci set network.@device[-1].mtu6='1500'
uci commit network
/etc/init.d/network reload
echo "Network device configured."
echo ""
echo "--- [Step 2/5] Installing required packages ---"
# Update package lists and install necessary packages
opkg update
opkg install bash
opkg install map
echo "Packages installed."
echo ""
echo "--- [Step 3/5] Downloading configuration scripts ---"
# Download the main configuration script
wget --no-check-certificate -O /usr/sbin/map-e-v6plus.sh https://raw.githubusercontent.com/HackingGate/config-software/main/map-e-v6plus.sh
chmod +x /usr/sbin/map-e-v6plus.sh
# Backup the original map.sh and download the modified version
if [ -f "/lib/netifd/proto/map.sh" ] && [ ! -f "/lib/netifd/proto/map.sh.bak" ]; then
echo "Backing up existing map.sh to map.sh.bak"
cp /lib/netifd/proto/map.sh /lib/netifd/proto/map.sh.bak
fi
wget --no-check-certificate -O /lib/netifd/proto/map.sh https://raw.githubusercontent.com/site-u2023/map-e/main/map.sh.new
echo "Scripts downloaded."
echo ""
echo "--- [Step 4/5] Persisting configuration for sysupgrade ---"
# Add the custom scripts to /etc/sysupgrade.conf to be preserved during firmware upgrades.
grep -qxF "/usr/sbin/map-e-v6plus.sh" /etc/sysupgrade.conf || echo "/usr/sbin/map-e-v6plus.sh" >> /etc/sysupgrade.conf
grep -qxF "/lib/netifd/proto/map.sh" /etc/sysupgrade.conf || echo "/lib/netifd/proto/map.sh" >> /etc/sysupgrade.conf
echo "Configuration set to persist across upgrades."
echo ""
echo "--- [Step 5/5] Running the MAP-E configuration script ---"
# Execute the script to apply MAP-E settings. Errors are suppressed.
bash /usr/sbin/map-e-v6plus.sh 2> /dev/null
echo "MAP-E configuration applied."
echo ""
echo "--- Setup Complete ---"
echo "The system will now reboot to finalize the changes."
echo "After rebooting, you can check available IPv4 ports with the command:"
echo "cat /tmp/map-wanmap.rules | awk '/PORTSETS/'"
echo ""
echo "Rebooting in 5 seconds..."
sleep 5
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment