鑫汇论坛││阿里资源│天翼资源│夸克资源│资料分享│书籍视频│

搜索
查看: 1701|回复: 0

无公网IP通过ZeroTier方便实现内网穿透(详细)

[复制链接]

303

主题

325

帖子

1761

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1761
发表于 2021-7-15 11:17:47 | 显示全部楼层 |阅读模式
需求:想要在公司访问家里内网NAS,或是在家里访问公司服务
有固定的公网IP或动态的公网IP:常见的方案动态域名解析做端口转发方式等
无公网IP:常见的实现方案向日葵、teamviewer、ngrok、frp
有公网地址的情况下,我这里还是推荐端口转发方式,速度最理想!!!另外条件允许还是优先考虑frp做内网穿透,速度根据自己情况可控,最理想的方案!!!
本文主要讲解一个无公网IP的情况,通过ZeroTier实现内网穿透,而且配置起来非常容易
ZeroTier设备支持:
免费用户可以支持100个设备,支持Windows、macOS、Linux、IOS、Android、Synology、QNAP、Western Digital MyCloud NAS等等。
ZeroTier原理:
ZeroTier虚拟了一个网段,网段为192.147.17.0/24,公司和家里分别安装ZeroTier客户端,客户端会虚拟出一个网络并加入192.147.17.0/24这个网段,在家即可访问192.147.17.22地址,反之同理。
ZeroTier部署流程:
1、注册账号并创建一个网段
2、下载客户端并加入这个网段
开始部署:
1、创建账号
2、创建网络
进入https://my.zerotier.com/network点击Create创建网络
3、点击进入已创建的网络
此时可以看到Network ID,后续添加设备都会需要这个ID。
我这里说下Access Control,默认是Certificate (Private Network),选择此模式表示每次在添加新的主机时,需要手动勾选是否允许连接,如果选择None (Public Network)模式,表示加入网络后自动分配IP并允许连接,从安全性来说建议使用默认选项Certificate (Private Network),方便性来看None (Public Network)更方便,不用每次加入网络后手动勾选。
另外根据个人情况你也可以自由设置网段,此处不做过多说明
好了,一个中转的ZeroTier就配置完成了,接下来只需要在其他设备安装所对应的客户端,然后加入到这个网络中就可以了。
Windows客户端安装
下载zerotier windos客户端
https://download.zerotier.com/dist/ZeroTier%20One.msi
安装后点击Log In登陆,登陆成功后会看到当前创建的网络,点击Join加入
或者右键点击zerotier图标,点击Join Network加入
然后在https://my.zerotier.com/network页面所创建的网络中刷新即可看到,刚刚加入的主机,如果使用的是Certificate (Private Network)模式,需要在页面中手动勾选一下允许加入网络。
Centos7客户端安装
1、编辑添加yum源

1


vi[color=rgb(0, 111, 224) !important] /etc/yum[color=rgb(51, 51, 51) !important].repos[color=rgb(51, 51, 51) !important].d/zerotier[color=rgb(51, 51, 51) !important].repo





1

[color=rgb(49, 124, 197) !important]2

3

[color=rgb(49, 124, 197) !important]4

5


[color=rgb(51, 51, 51) !important][zerotier[color=rgb(51, 51, 51) !important]
name=ZeroTier[color=rgb(51, 51, 51) !important],[color=rgb(0, 111, 224) !important] Inc[color=rgb(51, 51, 51) !important].[color=rgb(0, 111, 224) !important] [color=rgb(0, 78, 208) !important]RPM [color=rgb(0, 78, 208) !important]Release [color=rgb(0, 78, 208) !important]Repository
baseurl=https[color=rgb(51, 51, 51) !important]:[color=rgb(255, 128, 0) !important]//download.zerotier.com/redhat/el/$releasever
enabled=[color=rgb(206, 0, 0) !important]1
gpgcheck=[color=rgb(206, 0, 0) !important]0



2、安装zerotier

1

[color=rgb(49, 124, 197) !important]2


[color=rgb(0, 78, 208) !important]yum [color=rgb(0, 78, 208) !important]clean [color=rgb(0, 78, 208) !important]all
[color=rgb(0, 78, 208) !important]yum [color=rgb(0, 78, 208) !important]install zerotier-one



3、启动服务

1


zerotier-one[color=rgb(0, 111, 224) !important] -d



4、查看服务状态

1


zerotier-[color=rgb(0, 78, 208) !important]cli status



看到200 info 596811110b 1.2.12 ONLINE表示服务正常
可以使用netstat命令看到所启动的服务端口(这里192.168.1.162是centos本机的IP)
5、加入网络(后面是你自己的ID号)

1


zerotier-[color=rgb(0, 78, 208) !important]cli [color=rgb(0, 78, 208) !important]join [color=rgb(0, 78, 208) !important]Network ID



加入后会提示200 join OK
刷新几次页面即可看到新加入的主机,然后在前面勾选即可,勾选后Version会变成版本号,并且会分配出一个IP地址
6、主机验证
回到centos7主机上通过ifconfig命令即可看到,此处又多了一个内网IP,此内网IP和zerotier一致,表示配置完成
附:加入、离开、列出网络状态

1

[color=rgb(49, 124, 197) !important]2

3


zerotier-[color=rgb(0, 78, 208) !important]cli [color=rgb(0, 78, 208) !important]join [color=rgb(0, 78, 208) !important]Network [color=rgb(0, 78, 208) !important]ID
zerotier-[color=rgb(0, 78, 208) !important]cli [color=rgb(0, 78, 208) !important]leave [color=rgb(0, 78, 208) !important]Network [color=rgb(0, 78, 208) !important]ID
zerotier-[color=rgb(0, 78, 208) !important]cli listnetworks



文章来自互联网


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

鑫汇社区910g.com
快速回复 返回顶部 返回列表