This script simplifies the process of setting up a Cloudflare Tunnel on an OpenWrt router. It allows you to run Cloudflared Tunnel on your router without needing to permanently install the large Cloudflared package, making it suitable for routers with limited storage. Access your home network, server, or database from anywhere. Fast, easy, and free!
Notice: Consider looking into the official Wiki: https://openwrt.org/docs/guide-user/services/vpn/cloudfare_tunnel
- An OpenWrt router with SSH access.
- Optional (if you need a custom domain): A free Cloudflare account with a connected domain
-
SSH into your OpenWrt router as the root user:
ssh root@<your-openwrt-ip>
-
Copy and execute the following command (adjust the
--url
parameter for your needs)wget -qO- https://raw.githubusercontent.com/adshrc/openwrt-cloudflared/main/script.sh | ash -s -- --url=http://<device-ip>:80
<device-ip>
is your Device's IP Address, that you are builing a Tunnel to. E.g. 192.168.1.10
.
That's it! Just copy the *.trycloudflare.com
sub-domain you get from the script and enjoy!
-
SSH into your OpenWrt router as the root user:
ssh root@<your-openwrt-ip>
-
Copy and execute the following command:
wget -qO- https://raw.githubusercontent.com/adshrc/openwrt-cloudflared/main/script.sh | ash -s -- -l
-
The script will automatically set up a Cloudflare Tunnel. If you are executing it for the first time, you will need to log in to your Cloudflare account when prompted. After successful login, the script will create a Cloudflare Tunnel named "openwrt".
-
After a few seconds, check your Cloudflare Dashboard. You should see the "HEALTHY" status for the tunnel "openwrt":
-
In the Cloudflare Dashboard, click "configure" to "migrate" the tunnel. This allows you to manage various aspects from the Dashboard, eliminating the need to update configuration files manually.
-
Add a public hostname and enjoy!
-
To start the Cloudflare Tunnel after a router restart or to automate the process, run the command provided by the script. It looks like this:
wget -qO- https://raw.githubusercontent.com/adshrc/openwrt-cloudflared/main/script.sh | ash -s -- --import="<base64_config_string>"
You will see a link, where
<base64_config_string>
is already attached to the command above. Just copy and use later again!
-l
: Start the script with Cloudflare login (Domain + Account required).--import=<base64_config_string>
: Import a Cloudflared configuration from a base64-encoded string.--url=<tunnel_url>
: Specify a custom tunnel URL when starting the Quick tunnel.
- This setup is not persistent, and you need to repeat these steps after restarting your router.
- You can automate the setup by adding the provided command to a start script on your router.
This project is licensed under the GNU General Public License v3.0 License - see the LICENSE file for details.