{"id":28398852,"url":"https://github.com/loglux/merlin-vpn-routing","last_synced_at":"2025-06-28T18:31:45.104Z","repository":{"id":169714372,"uuid":"321157226","full_name":"loglux/merlin-vpn-routing","owner":"loglux","description":"This tool helps to create VPN Routing Rules for AsusWRT Merlin OpenVPN Client","archived":false,"fork":false,"pushed_at":"2025-05-26T13:36:12.000Z","size":91,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-08T06:27:40.905Z","etag":null,"topics":["asus","asus-routers","asuswrt-merlin","nvram","python","router","routing","routing-rules","routing-tables","vpn","vpn-client"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loglux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-12-13T20:48:51.000Z","updated_at":"2025-05-26T13:36:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"f80ba124-8250-40ad-97f4-484d9959cd4b","html_url":"https://github.com/loglux/merlin-vpn-routing","commit_stats":null,"previous_names":["loglux/vpnpolicy","loglux/merlin-vpn-routing"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/loglux/merlin-vpn-routing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglux%2Fmerlin-vpn-routing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglux%2Fmerlin-vpn-routing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglux%2Fmerlin-vpn-routing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglux%2Fmerlin-vpn-routing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loglux","download_url":"https://codeload.github.com/loglux/merlin-vpn-routing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglux%2Fmerlin-vpn-routing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262476124,"owners_count":23317221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asus","asus-routers","asuswrt-merlin","nvram","python","router","routing","routing-rules","routing-tables","vpn","vpn-client"],"created_at":"2025-06-01T06:12:03.000Z","updated_at":"2025-06-28T18:31:45.098Z","avatar_url":"https://github.com/loglux.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# merlin-vpn-routing\n\nThis script creates **VPN Policy Routing rules** for the **OpenVPN Client** in [AsusWRT Merlin firmware](https://github.com/RMerl/asuswrt-merlin.ng). It helps fetch IP addresses that belong to domain names and saves them into the router’s policy configuration. This allows selective VPN routing based on destination IPs.\n\n\u003e 🚨 **Important**: This version works only with **firmware 386.3+**. For older firmware, use [release 2.07](https://github.com/loglux/merlin-vpn-routing/releases/tag/2.07).\n\n---\n\n## 🔧 What It Does\n\n- Reads domain names from `domains.txt`\n- Resolves them into IP addresses (with optional subnet expansion)\n- Adds static entries from `static.csv`\n- Generates routing rules for the selected OpenVPN client\n- Saves rules to file (not NVRAM)\n- Optionally restarts the VPN client\n\n---\n\n## 📂 Files\n\n- `vpol.py` — core logic\n- `client1.py`, `client2.py`, ... — configurations for each VPN client\n- `domains.txt` — list of domain names (one per line)\n- `static.csv` — static entries in format: `Description,Source IP,Destination IP,Iface`\n\n### Example: `domains.txt`\n```\ndomain1.com\n#example.com       # commented out\ndomain2.com\n@subnetdomain.com  # use @ to resolve subnets (/xx)\n```\n\n### Example: `static.csv`\n```\nADomain,0.0.0.0,194.200.22.87/26,VPN\n```\n\n---\n\n## 🛠️ Requirements (on router)\n\n- Entware\n- Python 3\n- `bind-tools` or `bind-dig`:\n  ```sh\n  opkg install bind-tools\n  ```\n- `whois` utility:\n  ```sh\n  opkg install whois\n  ```\n- `pip`:\n  ```sh\n  opkg install python3-pip\n  ```\n- Python module `pydig`:\n  ```sh\n  pip install pydig\n  ```\n- Optionally: `git` to clone the repository\n\n---\n\n## 🚀 Usage\n\n1. Clone the repo:\n   ```sh\n   git clone https://github.com/loglux/merlin-vpn-routing.git\n   cd merlin-vpn-routing\n   ```\n\n2. Edit your client config (`client1.py`, etc):\n\n   - `local`: local IP or subnet (e.g. `192.168.0.10`, `192.168.0.0/24`, or `0.0.0.0`)\n   - `name_length`: max description length (default: 10)\n   - `client`: OpenVPN client number (1–5)\n   - `conf_path`: optional path to `domains.txt` and `static.csv`\n\n3. Run the script:\n   ```sh\n   python3 client1.py\n   ```\n\n---\n\n## 📅 Auto-start with VPN\n\nTo run the script automatically on VPN (re)start:\n\n1. Create or edit `/jffs/scripts/openvpn-event`:\n   ```sh\n   #!/bin/sh\n   python3 /path_to_script/client1.py\n   ```\n\n2. Make it executable:\n   ```sh\n   chmod a+rx /jffs/scripts/openvpn-event\n   ```\n\n\u003e ⚠️ Important: comment out `rules.client_restart(client)` to prevent restart loops.\n\n---\n\n## 🔙 Compatibility Note (Pre-386.3 Firmware)\n\nOld versions of AsusWRT Merlin used NVRAM for storing rules, with strict space limits. This script no longer supports that mode. To support legacy systems, use [release 2.07](https://github.com/loglux/merlin-vpn-routing/releases/tag/2.07).\n\n---\n\n## 📄 References\n\n- [Policy-based Routing — AsusWRT Wiki](https://github.com/RMerl/asuswrt-merlin.ng/wiki/Policy-based-routing)\n- [User Scripts — AsusWRT Wiki](https://github.com/RMerl/asuswrt-merlin.ng/wiki/User-scripts)\n\n---\n\n## 🙋 Contributing\n\nPull requests are welcome! If you have improvements, ideas, or bug fixes, feel free to fork the repo and submit a PR.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floglux%2Fmerlin-vpn-routing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floglux%2Fmerlin-vpn-routing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floglux%2Fmerlin-vpn-routing/lists"}