Coder Social home page Coder Social logo

adshrc / openwrt-cloudflared Goto Github PK

View Code? Open in Web Editor NEW
17.0 1.0 2.0 52 KB

You want to expose a device in your local network to the Internet? Here comes a one-command solution!

License: GNU General Public License v3.0

Shell 100.00%
cloudflare cloudflared ddns expose ngrok ngrok-alternative ngrok-replacement openwrt tunnel

openwrt-cloudflared's Introduction

Single Command Tunnel for OpenWrt

You want to expose a device in your local network to the Internet? Easy.

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

Prerequisites

  • An OpenWrt router with SSH access.
  • Optional (if you need a custom domain): A free Cloudflare account with a connected domain

Usage (without a Cloudflare Account)

  1. SSH into your OpenWrt router as the root user:

    ssh root@<your-openwrt-ip>
  2. 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!

Usage (with a Cloudflare Account and custom Domain)

  1. SSH into your OpenWrt router as the root user:

    ssh root@<your-openwrt-ip>
  2. Copy and execute the following command:

     wget -qO- https://raw.githubusercontent.com/adshrc/openwrt-cloudflared/main/script.sh | ash -s -- -l
  3. 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".

  4. After a few seconds, check your Cloudflare Dashboard. You should see the "HEALTHY" status for the tunnel "openwrt":

    image

  5. 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.

    image

  6. Add a public hostname and enjoy!

  7. 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!

Options

  • -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.

Notes

  • 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.

License

This project is licensed under the GNU General Public License v3.0 License - see the LICENSE file for details.

openwrt-cloudflared's People

Contributors

adshrc avatar stokito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

timmyvo bpilon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.