零基础学会双无公网直接访问服务器资源(上)【无需注册无需域名无需动脑】

今天无意间发现一个很牛的开源项目,即使自己在没有公网的条件下也能零门槛直接访问没有公网的服务器,最重要的是可以生成TUN。

以debian为例,理论上linux都适用。
感谢 fmnx 大佬的项目 https://github.com/fmnx/cftun

服务器配置
1.下载二进制文件 更多请访问 https://github.com/fmnx/cftun/releases

wget https://github.com/fmnx/cftun/releases/download/v2.0.6/cftun-linux-amd64 -O cftun

2.赋于可执行权限

chmod +x ./cftun

3.运行

./cftun --token quick

THE TEMPORARY DOMAIN YOU HAVE APPLIED FOR IS: ********.trycloudflare.com
在返回的信息里复制 ********.trycloudflare.com 这部分信息

客户端部分
1.2.前两步和服务器部分一致
3.客户端配置文件cftun.json
感谢 @amd64 大佬的优选域名 https://linux.do/t/topic/435684

{
  "client": {
    "cdn-ip": "fast-fast.asuscomm.com",
    "cdn-port": 443,
    "scheme": "wss",
    "global-url": "********.trycloudflare.com",
    "tun": {
      "enable": true,
      "name": "tun443",
      "ipv4": "10.20.30.40",
      "ipv6": "2001::10:20:30:40",
      "mtu": 1500,
      "routes2": [
        "0.0.0.0/0",
        "::/1"
      ]
    }
  }
}

4.运行

./cftun -c cftun.json

运行后会在客户端自动创建tun443的TUN设备,(ip rule、ip route、iptables大家自行发挥),如果相对比较懒的话可以把routes2改成routes,客户端则会自动修改路由配置。

其实在写这个教程的时候版本还是 2.0.5 (不支持TUN设备自定义参数),写一半的时候直接变成 2.0.6,完美支持TUN设备自定义IP、MTU等信息,再次感谢大佬 fmnx

这个项目还有第二部分的功能,抽时间尽快补充上来。

下半部分请移步 https://linux.do/t/topic/441650

Good luck to all

79 个赞

感谢大佬!

1 个赞

佬太强了

1 个赞

大佬太猛了,这项目咋找的,真心给力

1 个赞

感谢分享

2 个赞

那是不是就是家里的nas也可以这样从外面连接了

2 个赞

为了社区越来越好,大家积极分享自己的经验,社区加油

1 个赞

最喜欢这句 Good luck to all

1 个赞

nb,太强了

大佬墙哦

mark

这个可以的,赞

感谢分享

猛啊,一直在琢磨怎么访问内网资源

可以 学到了

感谢大佬分享

感谢大佬分享,已经在测试了,上下合在一起了

不错 不错

感谢大佬分享

谢谢分享