Installing Cloudflared on OpenWrt can be a bit tricky if you rely on the opkg package manager, as the Cloudflared version available there might be outdated. This is particularly true for devices with specialized hardware, and most openwrt are installed on some wired chips. To ensure you have the latest version of Cloudflared compatible with your device, follow these steps:
-
Download the Latest Version: Visit the Cloudflared releases page and download the appropriate version for your device. For example, if you're using a Raspberry Pi with OpenWrt, you might need
cloudflared-linux-aarch64.rpm. -
Identify Your CPU Architecture: Use the
uname -mcommand on your OpenWrt device to determine your CPU architecture. For instance:root@OpenWrt:~# uname -m aarch64
-
Extract the Cloudflared Binary: Unpack the
.rpmfile into a.cpiofile, and then extract the contents of the.cpiofile to obtain the Cloudflared binary executable. This process transforms:cloudflared-linux-aarch64.rpmโcloudflared-2.cpioโcloudflared -
Prepare the Binary for Transfer: As OpenWrt devices may have limited storage and lack certain unpacking tools, it's best to package the Cloudflared binary into a
.zipfile on your desktop. -
Transfer the Binary to Your Device: You can use tools like
scpto copy the Cloudflared binary to your OpenWrt device. Alternatively, you can host the binary on your desktop and have your device download it. For instance:python3 -m http.server 8000
This command hosts the content on port 8000.
-
Copy the Binary to
/usr/bin/cloudflared: Once the binary is on your device, move it to the appropriate location. -
Create a Service File: Use a text editor to create a service file for Cloudflared, e.g.,
vi /usr/bin/cloudflared, and populate it with the necessary configuration. You can use a template for this purpose. -
Set Up Your Tunnel: Replace the placeholder token value in the service file with your actual token. You can obtain a token by setting up a tunnel on the Cloudflare website.
-
Make the Script Executable: Ensure the service file is executable by running:
chmod +x /usr/bin/cloudflared
-
Enable the Service: Enable the Cloudflared service:
/usr/bin/cloudflared enable -
Start the Cloudflared Tunnel: Initiate the Cloudflared tunnel:
/usr/bin/cloudflared start
-
Reboot and Test: Reboot your device to test the Cloudflared setup. You can then return to the Cloudflared website to configure your public host.
By following these steps, you should have Cloudflared up and running on your OpenWrt device, allowing you to enjoy its features and benefits. Happy browsing! ๐