Automated configuration and advanced monitoring suite for OpenWrt routers. This repository contains scripts to rapidly deploy a secure, optimized OpenWrt setup (WISP mode, SQM, DoH) and a comprehensive Telegram monitoring system.
- Automated Setup (
OpenWrtSetup.sh): Configures WISP, LAN, WiFi, Tailscale, SQM (CAKE), DNS over HTTPS (DoH), mDNS/ZeroConf (umdns/avahi), and ZRAM with a single script. Supports Dry-Run and idempotency. - Verification (
OpenWrtSetupTest.sh): Validates system health, network configurations, storage limits, and routing post-setup. - Telegram Monitoring: Real-time alerts for system resources, VPN status, brute-force attempts, and client connections.
- Multi-language Support: Telegram alerts support English (
en) and Indonesian (id).
- A router flashed with OpenWrt 23.05+
- Internet connection (via ethernet or tethering) for initial package downloads.
- Connect your PC to the router.
- Copy and Edit the configuration inside
setup/setup.conf, then transfer the entiresetupdirectory to the router via SCP:scp -O -r setup root@192.168.1.1:/tmp/
- SSH into the router:
ssh root@192.168.1.1
- Run the script:
sh /tmp/setup/OpenWrtSetup.sh --config /tmp/setup/setup.conf # Optional: run with --dry-run first to see what will change - Follow the prompts. The router will automatically reboot upon successful completion.
After the router reboots, transfer and run the test script:
scp -O OpenWrtSetupTest.sh root@192.168.11.1:/tmp/
ssh root@192.168.11.1
sh /tmp/OpenWrtSetupTest.shIf you want to automatically calculate and apply the optimal SQM (Smart Queue Management) values based on your actual internet speed, use the included SQM_Speedtest.sh script.
This script tests your download and upload speeds, performs a CPU Bottleneck Analysis to ensure your router can handle SQM at your current speed, and can automatically apply the optimized values directly to your live router or setup.conf.
To run on the router (Recommended for live configuration):
scp -O SQM_Speedtest.sh root@192.168.11.1:/tmp/
ssh root@192.168.11.1
sh /tmp/SQM_Speedtest.shThe TelegramMonitoring directory contains scripts to track router health, auth attempts, and DHCP events.
To get real-time Telegram alerts and keep an automated log in Google Sheets, you need to set up a Telegram Bot and a Google Apps Script Web App. Follow these steps:
- Message
@BotFatheron Telegram, send/newbot, and follow the prompts to get your HTTP API Token (token). - Message
@userinfobotor@GetMyIDBoton Telegram to retrieve your personal Telegram Chat ID (chatId).
- Create a new, empty Google Spreadsheet (e.g., name it
Router Monitoring Log). - In the Spreadsheet menu, go to Extensions -> Apps Script.
- Clear the default
Code.gscontent and paste the code from spreadsheet_google_apps_script.js. - Fill in your Telegram Token and Chat ID inside the variables at lines 19-20:
var token = "YOUR_TELEGRAM_BOT_TOKEN"; var chatId = "YOUR_TELEGRAM_CHAT_ID";
- Click the Save (floppy disk) icon.
- In the top-right corner of the Apps Script page, click Deploy -> New deployment.
- Click the gear icon next to "Select type" and choose Web app.
- Set the following options:
- Description:
Router Alerts and Logging Webhook - Execute as:
Me (your-email@gmail.com) - Who has access:
Anyone(This is critical! Your router needs access to post logs without authentication).
- Description:
- Click Deploy. Authorize Google permissions if prompted (click Advanced -> Go to Project (unsafe)).
- Copy the generated Web App URL (e.g.,
https://script.google.com/macros/s/YOUR_SCRIPT_ID/exec).
- Copy
TelegramMonitoring/telegram.conf.exampleand rename it totelegram.conf. - Open
TelegramMonitoring/telegram.confand paste your copied Web App URL:GAS_URL="https://script.google.com/macros/s/YOUR_SCRIPT_ID/exec" LANG="en" # Use "en" for English or "id" for Indonesian
- Transfer the directory to your router:
(Note: If you have already changed your router IP to a different temporary IP like
scp -O -r TelegramMonitoring root@192.168.11.1:/tmp/
192.168.12.1, make sure to use that IP instead!) - Run the installer:
ssh root@192.168.11.1 # (Or your router's current temporary IP) sh /tmp/TelegramMonitoring/install.sh
router_monitor.sh: Runs via cron. Checks RAM, Tailscale, WiFi status, latency, storage, CPU load, SQM status, and WAN IP changes.auth_monitor.sh: Runs continuously in background. Tracks successful/failed LuCI and SSH logins. Triggers alerts on brute-force attempts.dhcp_notify.sh: Hotplug script for DHCP events. Alerts when unknown devices connect/disconnect.99-wisp-notify: Hotplug script. Alerts when WISP connection drops or recovers, including downtime duration and signal strength.
-
"Operation not permitted" (wget/curl/apk): Your router's clock is out of sync, causing SSL verification to fail. The setup script attempts to fix this automatically using
ntpd. -
Subnet Conflict: If your upstream WISP network uses
192.168.1.x, ensure your router's LAN IP is changed (e.g., to192.168.11.1) to avoid routing loops. -
Double-NAT / Static WAN & DMZ Setup: If your OpenWrt router is your primary home router but sits behind an ISP router (Double-NAT):
- Select a Static IP: Choose a static IP for the OpenWrt WAN interface (e.g.,
192.168.1.2) that is outside the ISP router's DHCP pool range (e.g., if the ISP router DHCP pool starts at.50, values from.2to.49are safe). - Free up the IP: If a device is currently using your target IP, disconnect OpenWrt, restart the ISP router, and reconnect/restart the conflicting device so it gets forced into the new DHCP pool range (e.g.,
.50+). - Configure WAN in OpenWrt:
- Go to Network -> Interfaces.
- Edit WAN, change protocol to Static address, and click Switch protocol.
- Set IPv4 address to your chosen static IP (e.g.,
192.168.1.2). - Set IPv4 netmask to
255.255.255.0and IPv4 gateway to the ISP router's IP (e.g.,192.168.1.1). - Set Use custom DNS servers to the ISP router's IP or public DNS (e.g.,
1.1.1.1). - Save and apply.
[!NOTE] Even if using DNS over HTTPS (DoH) on OpenWrt, you should still configure custom WAN DNS servers. They act as bootstrap DNS resolvers so the DoH client can look up DoH endpoints upon boot, and provide a backup fallback if the DoH service fails.
- Enable DMZ on the ISP Router:
- Log into the ISP router, find DMZ settings, and enable it.
- Direct the DMZ target IP to the OpenWrt WAN IP (e.g.,
192.168.1.2). - For the WAN connection option in the DMZ settings, select the active fiber/GPON interface (typically named like
omci_ipv4_pppoe_1or set toAuto) rather than backup connections likedongle.
- Select a Static IP: Choose a static IP for the OpenWrt WAN interface (e.g.,
-
Telegram Rate Limits: Notifications are throttled to a maximum of 10 per minute to prevent spam.
-
IPv6 Issues / No IPv6 on Client Devices: If your router has IPv6 but client devices (PCs, phones) fail IPv6 tests, or if websites load extremely slowly / fail to load on IPv6:
- No IPv6 Internet on Clients (Single
/64Prefix): If your ISP only provides a single/64subnet without Prefix Delegation (common with WISP/cellular or locked-down ISP modems), OpenWrt restricts client routing by default. Fix this by disabling the source filter:uci set network.wan6.sourcefilter='0' # Use network.wwan6.sourcefilter='0' for WISP mode uci commit network /etc/init.d/network restart
- Large Packets Fail / Websites Hang (MTU/MSS Clamping): Common on PPPoE connections (like Telkom IndiHome). Fix this by enabling
mtu_fixon the firewall's WAN zone:uci set firewall.@zone[1].mtu_fix='1' uci commit firewall /etc/init.d/firewall restart
- No IPv6 Internet on Clients (Single
-
mDNS / Hostname Resolution (
.localvs.lan): OpenWrt's dnsmasq automatically serves<hostname>.lanfor all connected clients via regular DNS. This is the reliable hostname to use on Linux clients.Domain Resolution Method Linux Android/iOS <hostname>.landnsmasq DNS ✅ Always works ✅ Always works <hostname>.localmDNS (avahi) ⚠️ Unreliable✅ Works Why
.localfails on Linux: Modern Linux desktops run bothavahi-daemonandsystemd-resolved, and both try to claim the mDNS multicast socket (UDP 5353). This conflict causes avahi to silently fail to receive mDNS announcements, even though it appears to be running.Symptoms:
ping: zulvanet-rtr-00.local: Temporary failure in name resolution avahi-resolve -n zulvanet-rtr-00.local: Timeout reachedPermanent fix — disable systemd-resolved's mDNS responder (let avahi own port 5353):
sudo bash -c 'grep -q "^MulticastDNS" /etc/systemd/resolved.conf \ && sed -i "s/^MulticastDNS=.*/MulticastDNS=no/" /etc/systemd/resolved.conf \ || echo "MulticastDNS=no" >> /etc/systemd/resolved.conf' sudo systemctl restart systemd-resolved sudo systemctl restart avahi-daemon
Alternative — enable DNS fallback for
.local(changemdns4_minimal→mdns4in/etc/nsswitch.conf). The_minimalvariant has a hardNOTFOUND=returnstop;mdns4falls through to DNS. Since dnsmasq serves<hostname>.localvia a static address entry, this makes.localresolvable even when avahi fails:sudo sed -i 's/mdns4_minimal/mdns4/g' /etc/nsswitch.confUnderlying router cause (DSA/VLAN setups): If
vlan_filtering=1is set onbr-lanand the LAN interface uses a VLAN sub-interface (br-lan.1), WiFi AP ports are added to the bridge by hostapd without explicit VLAN 1 membership. This prevents mDNS multicast frombr-lan.1reaching WiFi clients. The setup script automatically installs a hotplug script (/etc/hotplug.d/net/30-bridge-vlan-wifi) to fix this on every boot whenMDNS_ENGINE=avahiis set. Requiresip-bridgepackage (apk add ip-bridge).
MIT