Remote access is so simple, through ZeroTier and Tailscale, it is easy to set up a virtual local area network to achieve intranet penetration.

Because I used Plex recently, I studied remote access. After some tossing, I basically figured it out. I would like to share some of my own experience here for novices like me. Please correct me if I am wrong.

The remote access here refers to accessing the LAN through the network outside the LAN to realize screen sharing , file sharing , remote desktop , remote online and other operations. For example, telecommuting, you can access your computer at work or at home from anywhere, not only for file transfer, but also for remote control and screen sharing of the computer; for example, if you set up a home NAS server, you can remotely access it from anywhere Access the content on the NAS; for example, if you have built a private audio-visual media library in the LAN, you can watch the audio and video stored on the local device at any place through remote access; for example, you can play online games with friends in different places, etc.

There are two situations to realize remote access, with public network IP and without public network IP .

If there is a public network IP remote access is very simple, you can directly access through the public network IP , and you only need to add the specified port to access the specified content.

However, due to the exhaustion of global IPv4 resources, my country’s home broadband is generally assigned a private network IP. If you need a public network IP, you can apply to the operator. It may be relatively easy to apply in the past, but it is relatively difficult now. Take Sichuan Telecom as an example. Since 2022, free public IP is no longer provided. If you need a public IP, you must meet certain conditions and pay a monthly service fee of 100 yuan to enjoy the dynamic public IP service. Of course, there are differences in the services of operators in different places. You can try to apply for a free public network IP from your own operator first . If the application is successful, please change your optical modem to bridge mode, turn off the DHCP service and wireless network of the optical modem, Use the router to dial up to access the Internet, so that you can directly perform remote access through the public network IP.

If your network supports and enables IPv6, and your router also supports IPv6, then you can enable the IPv6 function of the router, and the IP address obtained by using IPv6 is the public network IP, but there is a problem here that most routers are self-configured The firewall automatically blocks IPv6 remote access, that is to say, if you cannot close the router's restriction on IPv6, the IPv6 public IP is useless. To solve the problem of the router firewall, you may need to flash the firmware, not all routers support it , so this method is actually more troublesome, or you can directly choose a router that supports turning off the IPv6 firewall . However, IPv6 is not popular now, and many routers and devices do not support IPv6, so the use will be subject to some restrictions.

Let's talk about the situation without public network IP, which is quite common. There are many ways to achieve remote access without public network IP. Today, I mainly share two completely free and unlimited intranet penetration solutions.

Intranet penetration is possible through ZeroTier or Tailscale , and a virtual LAN/network can be easily established , that is, multiple devices from any location and any network can be added to a virtual LAN/network, under this virtual LAN/network , these devices can realize all the functions of the LAN intranet, because the physical location of the device is not limited, so remote access is realized, and devices on different networks can communicate directly through this virtual LAN/network, and the transmission speed is determined by the device's own network Bandwidth limitation, when the communication is limited, it can also be transferred through ZeroTier's server or self-built cloud server.

Next, we will talk about the operation steps of ZeroTier and Tailscale respectively.

ZeroTier

01. Register an account on the ZeroTier official website .

02. Go to the registered mailbox to check the verification email and verify it .

03. After verification, refresh the previous webpage to enter the ZeroTier Central management center .

04. Click "Create A Network" to create a virtual network .

05. After the creation is complete, the following interface will be displayed. The red box is the NETWORK ID, which is your virtual network ID. Other devices need this ID to join the virtual network. Click anywhere in the red box to enter the network settings .

06. Modify the name of the virtual network in the red box , you can customize it, or you don’t need to change it. The default is Private private network, authorization is required to join the network, just keep the default. The following IPv4 Auto-Assign can select your virtual local area network IP address network segment, and each device that joins the virtual local area network will be assigned a virtual IP address in this network segment, and each device will use this virtual IP address to communicate with each other. You can keep this network segment as the default, or you can choose one yourself.

At this point, your virtual local area network has been set up, and then you can add devices.

07. Right-click " the downloads page " to open a new tab to download the client for your device, select the client to download and install according to your operating system . (iOS users can search, download and install directly in the App Store, which requires an account in the US region, and Android users can search for the installation package to download and install by themselves, and the App on the device is called ZeroTier One)

08. There is no need to log in to the device, the App is also very simple, and the operations of each system are basically the same. Taking MacOS as an example, after running ZeroTier , the icon will be displayed in the menu bar. Copy and paste the network ID in , click " Join ", and it will be connected. If you want to disconnect, click "Disconnect" or just exit the program directly.

以 iOS 为例,打开 ZeroTier One 后点击右上角的加号,点击「Accept」,将 Network ID 粘贴过来,点击打开「Enable Default Route」后面的开关,点击「Add Network」,虚拟网络就添加成功了,点击该网络后面的开关即可开启或关闭虚拟局域网,开启后顶部状态栏上会显示「VPN」图标。(过程中可能会请求系统授权,同意即可)

09. 如果你想邀请其他人加入你的虚拟局域网,和他人的设备进行文件共享或远程访问,只要请他们在设备上安装 ZeroTier 或者 ZeroTier One 的客户端,然后参考上面的方式直接通过你的虚拟局域网 ID 即可加入你的虚拟局域网,你也可以继续添加自己的其他设备,每个虚拟局域网最多可以添加 25 个设备

10. 注意上方设备加入虚拟局域网后需要经过管理员也就是虚拟网络创建者的授权才可以进行访问,进入 ZeroTier Central 管理中心在 Members 部分可以看到已经加入网络的设备,设备前方显示红色虚线表示未对其授权,该设备无法访问虚拟局域网内的其他设备,点击勾选设备前方的方框可对其进行授权,授权后的设备前方显示绿色实线,扳手后方是设备的虚拟地址,可在「Name/Description」处为设备修改名称,后方的「Managed IPs」是设备在虚拟局域网内的虚拟内网 IP 地址,设备之间互相访问就是使用这个虚拟内网 IP 地址,支持指定 IP,一般使用默认即可,后方是上一次访问的时间,最后是物理 IP 地址。

11. 以上图为例,在我授权 iPhone8 访问虚拟局域网后,假如我在局域网外要通过 iphone8 访问 iMac 的共享文件夹,只要使用 iphone8 在「文件」App 里通过 smb://192.168.195.173 连接服务器即可;如果我想访问 iMac 上的 Plex 服务器只要在浏览器访问 192.168.195.173:32400 即可;如果我想使用远程桌面操控家里的 iMac 只要在 iPhone8 打开 VNC Viewer 使用 192.168.195.173 连接这台 iMac 即可。总之你在局域网里能做的大部分工作通过虚拟局域网都可以实现,我这里用的是 iPhone,当然你也可以使用电脑或其他设备访问虚拟局域网内的设备,前提是设备开启了共享和远程访问。

同时 ZeroTier 也为有更多需求的用户提供了付费服务。

Tailscale

01. Tailscale 仅支持通过谷歌微软GitHub 账号授权登录,建议使用 GitHub 账号登录,若没有请先注册一个 GitHub 账号(微软账号可能需要用手机注册),然后登录 Tailscale。

02. 登录后为如下界面,请根据自己的操作系统下载并安装客户端。(MacOS 及 iOS 需要美区账号,安卓用户可自行搜索安装包下载安装)

03. 安装完成后请运行 Tailscale 客户端,点击「Get Started」,点击「Sign in to your network」,跳转网页登录你的账号,返回客户端点击「Yes, start on log in」,意思是开机启动,如果不需要开机启动请选择「No, I will manually start Tailscale」,在有需要的时候手动开启客户端,现在你的设备就已经成功加入你的虚拟网络了,点击「Close」关闭窗口,你会在菜单栏看到 Tailscale 图标。

04. 此时回到引导设置页,设备已经出现在右侧了,前方是设备名称,后方是虚拟 IP 地址,Tailscale 是无需手动配置的,设备安装客户端并登录后会自动加入虚拟组网,接下来继续在其他需要远程访问的设备上安装客户端并登录即可。

以 iOS 为例,打开客户端点击「Get Started」登录你的账号,使用 GitHub 授权,登录后界面最上方是启用和关闭按钮,就是虚拟组网的开关,跟着是本机的名称和虚拟 IP,下方显示的是你的其他设备,格式也是名字在上,虚拟 IP 在下,接下来就可以通过其他设备的虚拟 IP 进行远程访问了。

05. MacOS 通过菜单栏的图标可进行操作,最上面是虚拟组网的开关,跟着显示的是当前登录的账号,点击Admin Console」可进入网页版管理中心,可以查看连接设备名称、虚拟 IP、操作系统、连接状态等信息,点击设备可以对其详情进行查看和管理。在菜单栏图标点击 Network Devices - My Devices 也可查看虚拟组网接入的设备,点击设备名称可直接复制设备的虚拟 IP。

06. 若要与他人共享自己的设备请将鼠标移至设备最后方的三个小圆点上,会出现「Share…」按钮,点击弹出分享窗口,点击「Generate & copy invite link」可生成邀请链接,将链接发送给你的好友,好友接受邀请后你的这台设备就会出现在他的虚拟组网里,他就可以单向访问你的这台设备了,如果要实现双向访问你还需要通过他的设备的邀请链接将他的设备加入你的虚拟组网。(每个访问虚拟组网的设备都需要安装客户端并登录账号,每个虚拟组网初始最多可接入20个设备,每邀请一个人双方都会增加两个设备位)

07. 上面讲到的都是给每个设备分配一个虚拟 IP,然后互相访问,如果在外面想访问本地局域网的设备还有一个方式,可以使用局域网内的一台设备做虚拟网关,设置一个虚拟路由,将你的本地局域网作为这个虚拟网关的子网,这样就可以通过虚拟网关访问本地局域网的所有设备,直接通过你的本地 IP 访问即可,就不需要为每个设备都安装客户端加入虚拟组网了。

不过这个设置有一点小门槛,如果对网络不太懂,可能设置起来会有些困难,但官方也有相应的指导说明,除此之外 Tailscale 还有很多高级功能和付费功能。对于个人用户来说,一般免费版本就可以满足需求了,如果是机构或者企业也可以选择付费的版本。

文章写的有点长,其实操作是非常简单的,ZeroTier 和 Tailscale 都是非常好的内网穿透解决方案,他们的原理都是搭建一个虚拟网络设备经过授权连接到这个虚拟网络后就可以互相访问就像在同一个局域网内一样。但实际上 ZeroTier 和 Tailscale 使用的技术并不相同,操作方式上也略有差别。

ZeroTier 只有虚拟网络创建者需要用账号登录,要访问虚拟网络的设备都需要安装客户端但不用登录;每个注册用户可以创建的虚拟网络没有上限,但每个虚拟网络最多只可接入 25 个设备;虚拟网络的管理员可以查看所有接入设备的信息,并对其进行管理,而接入网络的其他设备除了网络 ID 是无法获取虚拟网络的其他信息的;访问虚拟网络接入的其他设备需要管理员告知其他设备的虚拟 IP 并对其进行授权;数据传输正常情况下是两个设备直接加密通信,但是如果网络情况不好或者受到其他限制可能会通过 ZeroTier 服务器进行中转,如果不想使用 ZeroTier 的服务器也可以使用其他服务器进行中转。

Tailscale 的每个用户都需要使用账号登录,每个账号登录后会自动创建一个虚拟网络,不支持新建虚拟网络;使用账号登录后会自动加入虚拟网络,每个虚拟网络初始可添加 20 个设备,但是每邀请一个设备加入自己的网络就会新增 2 个设备位;支持一个虚拟子网,可把一个局域网设置为虚拟子网,这个局域网内的所有设备可以访问虚拟网络但不需要安装客户端也不用登录账号;如果是自己的设备可以直接通过虚拟 IP 互相访问,若要访问他人的设备需要通过邀请链接将他人的设备加入自己的虚拟网络,同理要把自己的设备共享给别人也需要通过邀请链接把自己的设备分享出去;数据传输是两个设备直接加密通信,也可以自建中转服务器。

简单说,如果自己个人使用,用 Tailscale 给自己的每个设备安装客户端并登录就可以了,用 ZeroTier 还需要给每个设备添加虚拟网络,但也不算麻烦;如果只是偶然需要与他人进行远程共享,使用 ZeroTier 只要对方安装客户端再添加虚拟网络就可以互相访问了,而 Tailscale 需要对方先注册账号,再通过你的邀请链接加入你的虚拟组网,这样对方才可以访问你的设备,如果你要访问他的设备还需要对方再邀请你加入他的虚拟组网,其实有点麻烦。

专业的术语我不太懂,但就使用体验上来看,ZeroTier 应该是搭建了虚拟局域网,所有设备的虚拟 IP 都在同一个网段,接入虚拟局域网的所有设备都可以使用虚拟 IP 互相访问,因为设备是不需要登录的,所以经过授权设备就直接进入虚拟局域网了。而 Tailscale 搭建的是虚拟组网,每个设备的虚拟 IP 都在不同的网段,但在同一个虚拟组网内的设备可以互相访问,可是 Tailscale 的分享邀请是单向的,因为每个账号都有一个独立的虚拟网络,我把我的设备分享给对方后,我的设备就被添加到了对方的虚拟网络中,但是对方的设备并不会出现在我的虚拟网络里,所以他可以通过他的虚拟网络访问我共享的设备,但是我无法访问他的设备,需要对方邀请后才可以将对方的设备加入我的虚拟网络。

这个差异你也可以说 Tailscale 更安全,你也可以说他更麻烦。因为虽然加入 ZeroTier 的虚拟局域网可以访问网内的所有设备,但是设备的虚拟 IP 只有管理员知道,即使邀请他人加入虚拟局域网,对方也不会知道虚拟局域网内其他设备的虚拟 IP,他甚至都无法查看他自己的虚拟 IP,一切权限都在管理员这里,如果只想让对方访问某个特定的设备只要给其他设备取消授权就万无一失了。加入他人虚拟网络的这一方如果不想对方访问自己的设备或某些内容,只要关闭这些内容的共享功能即可。

相比之下提到安全只能说在传输方式上 Tailscale 更安全,因为你的数据是完全不会经过 Tailscale 服务器的,而 ZeroTier 是有可能的,但是如果你使用其他服务器进行中转,那么这两个也没有太大的区别。关于稳定性方面,因为本人没有测试环境,所以无法提供信息,初步感受没有太大差别。

总而言之,这两个都挺好的,ZeroTier 比较方便与他人共享Tailscale 相对更加安全,也许可以这样理解吧,使用体验差别不算太大,都是不限流、不限速的,即使是用于 4K 视频的串流也完全不卡,而且是免费的,相较一些收费的内网穿透工具,我觉得这两个还是很不错的选择。

Guess you like

Origin blog.csdn.net/u010567698/article/details/128742538