去评论
海欣资源

异地组网ZeroTier内网穿透搭建无公网局域网教程

perll
2022/05/29 11:49:34
鏈夊浐瀹氱殑鍏綉IP鎴栧姩鎬佺殑鍏綉IP锛氬父瑙佺殑鏂规鍔ㄦ佸煙鍚嶈В鏋愬仛绔彛杞彂鏂瑰紡绛
鏃犲叕缃慖P锛氬ぇ澶氬唴缃戠┛閫忛兘鏄槧灏勬垨鍙嶅悜浠g悊锛屽鍚戞棩钁点乼eamviewer銆乶grok銆乫rp绛夛紝鑰孼eroTier鏄湡姝g殑鍐呯綉绌块,鐩稿綋浜庣粍寤鸿櫄鎷熷眬鍩熺綉.浜掔浉璁块棶鏃犻檺鍒.绫讳技VPN缃戠粶.
ZeroTier璁惧鏀寔锛
鍏嶈垂鐢ㄦ埛鍙互鏀寔50涓澶囷紝鏀寔Windows銆乵acOS銆丩inux銆両OS銆丄ndroid銆丼ynology銆丵NAP銆乄estern Digital MyCloud NAS绛夌瓑銆傚綋鐒朵篃鍙互璁剧疆鏃佽矾杞矾鐢卞畨瑁厇eroTier.鐩稿綋浜嶸PN鐐瑰鐐圭粍缃.

ZeroTier鍘熺悊锛
ZeroTier铏氭嫙浜嗕竴涓綉娈碉紝缃戞涓192.XX.XX.0/24锛屽叕鍙稿拰瀹堕噷鍒嗗埆瀹夎ZeroTier瀹㈡埛绔紝瀹㈡埛绔細铏氭嫙鍑轰竴涓綉缁滃苟鍔犲叆192.XX.XX.0/24杩欎釜缃戞锛屽湪瀹跺嵆鍙闂192.XX.XX.X鍦板潃锛屽弽涔嬪悓鐞嗐

ZeroTier閮ㄧ讲娴佺▼锛
1銆佹敞鍐岃处鍙峰苟鍒涘缓涓涓綉娈
2銆佷笅杞藉鎴风骞跺姞鍏ヨ繖涓綉娈

寮濮嬮儴缃诧細
1銆佸垱寤鸿处鍙
https://my.zerotier.com

2銆佸垱寤虹綉缁
杩涘叆https://my.zerotier.com/network鐐瑰嚮Create鍒涘缓缃戠粶

3銆佺偣鍑昏繘鍏ュ凡鍒涘缓鐨勭綉缁
姝ゆ椂鍙互鐪嬪埌Network ID锛屽悗缁坊鍔犺澶囬兘浼氶渶瑕佽繖涓狪D銆
鎴戣繖閲岃涓婣ccess Control锛岄粯璁ゆ槸Certificate (Private Network)锛岄夋嫨姝ゆā寮忚〃绀烘瘡娆″湪娣诲姞鏂扮殑涓绘満鏃讹紝闇瑕佹墜鍔ㄥ嬀閫夋槸鍚﹀厑璁歌繛鎺ワ紝濡傛灉閫夋嫨None (Public Network)妯″紡锛岃〃绀哄姞鍏ョ綉缁滃悗鑷姩鍒嗛厤IP骞跺厑璁歌繛鎺ワ紝浠庡畨鍏ㄦф潵璇村缓璁娇鐢ㄩ粯璁ら夐」Certificate (Private Network)锛屾柟渚挎ф潵鐪婲one (Public Network)鏇存柟渚匡紝涓嶇敤姣忔鍔犲叆缃戠粶鍚庢墜鍔ㄥ嬀閫夈
鍙﹀鏍规嵁涓汉鎯呭喌浣犱篃鍙互鑷敱璁剧疆缃戞锛屾澶勪笉鍋氳繃澶氳鏄.
濂戒簡锛屼竴涓腑杞殑ZeroTier灏遍厤缃畬鎴愪簡锛屾帴涓嬫潵鍙渶瑕佸湪鍏朵粬璁惧瀹夎鎵瀵瑰簲鐨勫鎴风锛岀劧鍚庡姞鍏ュ埌杩欎釜缃戠粶涓氨鍙互浜嗐

Windows瀹㈡埛绔畨瑁
涓嬭浇zerotier windos瀹㈡埛绔
https://download.zerotier.com/dist/ZeroTier%20One.msi
瀹夎鍚庣偣鍑籐og In鐧婚檰锛岀櫥闄嗘垚鍔熷悗浼氱湅鍒板綋鍓嶅垱寤虹殑缃戠粶锛岀偣鍑籎oin鍔犲叆 杈撳叆Network ID.
鎴栬呭彸閿偣鍑粃erotier鍥炬爣锛岀偣鍑籎oin Network鍔犲叆 杈撳叆network ID.
鐒跺悗鍦╤ttps://my.zerotier.com/network椤甸潰鎵鍒涘缓鐨勭綉缁滀腑鍒锋柊鍗冲彲鐪嬪埌锛屽垰鍒氬姞鍏ョ殑涓绘満锛屽鏋滀娇鐢ㄧ殑鏄疌ertificate (Private Network)妯″紡锛岄渶瑕佸湪椤甸潰涓墜鍔ㄥ嬀閫変竴涓嬪厑璁稿姞鍏ョ綉缁溿

Linux 瀹㈡埛绔畨瑁
ssh杩涳紝杈撳叆涓嬮潰鍛戒护瀹夎銆
curl -s https://install.zerotier.com/ | sudo bash
鍔犲叆缃戠粶鐐癸紝鏄剧ず 200 join OK銆傚埆鎶勪笂澶达紝璁板緱鏀规垚浣犵殑network id銆
zerotier-cli join networkid鍙
缁х画鍘荤綉椤垫巿鏉冿紝ok锛岀幇鍦ㄨ繖涓や釜绔彲浠ヤ簰鐩歌闂簡銆

zerotier鎵嬫満绔篃鏈夛紝鏂规硶宸笉澶氾紝鍔犲叆鍒拌繖涓綉缁滅偣锛屽氨鍙互浣跨敤ip浜掔浉璁块棶銆
zerotier榛樿浣跨敤鍏ㄧ悆鐨勬湇鍔¤妭鐐癸紝楂樺嘲鏃跺埢涓嶇ǔ瀹氾紝瀹樻柟涔熸湁璇存槑锛屽彲浠ユ惌寤鸿嚜宸辩殑moon鏈嶅姟鍣ㄤ綔涓鸿烦鏉匡紝鍔犻熺綉缁溿
娌℃湁澶ぇ闇姹備笉闇瑕佷紭鍖栵紝姣曠珶杩樺緱瑕佹湇鍔″櫒锛屾墍浠ュ皬鐧藉埌涓婁竴姝ュ氨鍙互浜嗭紝浼樺寲鍙槸閽堝鏈夎嚜宸辨湇鍔″櫒鐨勩
moon 鏈嶅姟鍣ㄦ惌寤哄緢绠鍗曪紝鍏堟妸鏈嶅姟鍣ㄥ姞鍏ョ綉缁滅偣锛岄噸澶嶄笂涓姝ュ嵆鍙

zerotier鎼缓绉佹湁moon鑺傜偣
杩涘叆 zerotier 閰嶇疆鐩綍,鐢熸垚 moon.json 绛惧悕鏂囦欢.
    cd /var/lib/zerotier-one
    zerotier-idtool initmoon identity.public > moon.json

淇敼moon.json妯℃澘
灏嗕綘鐨勬湇鍔″櫒IP娣诲姞鍒"stableEndpoints": [] 涓紝淇敼鍐呭濡備笅, 9993鏄粯璁ょ鍙
    vim moon.json #鎵惧埌瀵瑰簲琛屼慨鏀瑰唴瀹
    "stableEndpoints": [ "22.22.22.22/9993" ]

娉:22.22.22.22涓轰綘鐨勬湇鍔″櫒鍏綉ip, 涓瀹氳閰嶇疆姝g‘,Zerotier渚濋潬姝ら厤缃幓杩炴帴moon.鍚庨潰鐨勭鍙h嫢娌℃湁鏀瑰彉鍒欓粯璁ら兘鏄9993绔彛, 涓旀槸UDP鍗忚鐨, 姝ゅ鍦ㄩ槻鐏涓婇渶瑕佸紑鏀綰DP,鍚﹀垯鏄繛鎺ヤ笉涓奙oon.

鐢熸垚 .moon 绛惧悕鏂囦欢
zerotier-idtool genmoon moon.json

鎵ц璇ュ懡浠ゅ悗,浼氬湪鍦/var/lib/zerotier-one鐩綍涓嬬敓鎴愪竴涓被浼000000xxxxx.moon鐨勬枃浠.鍦 Zerotier 瀹夎鐩綍涓嬶紙/var/lib/zerotier-one锛夊缓绔嬫枃浠跺す moons.d锛屽皢鐢熸垚鐨 .moon鏂囦欢鎷疯礉杩涘幓銆傞噸鍚 zerotier銆傝嚦姝わ紝VPS 涓婏紙moon 鏈嶅姟鍣級閰嶇疆瀹屾垚銆

    mkdir moons.d
    cp 000000xxxxx.moon moons.d/
    service zerotier-one restart #鏈嶅姟閲嶅惎鍛戒护

ok锛岀幇鍦ㄤ綘鐨刴oon鏈嶅姟鍣ㄦ惌寤烘垚鍔熶簡锛岃缁欏叾浠栫鎺ュ叆杩欎釜moon浜嗭紝鍏堝鍒舵湇鍔″櫒鐨刬d锛岄氳繃 zerotier-cli info 鏌ョ湅銆

鏈鍚庝竴姝ワ紝鏈嶅姟绔厤缃悗锛屾垜浠渶瑕佸湪姣忓彴瀹㈡埛绔厤缃竴涓狹oon鏈嶅姟鍣ㄦ枃浠讹紝閰嶇疆瀹㈡埛绔紝杈撳叆鎸囦护.
zerotier-cli orbit <id> <id>

windows閫氳繃绠$悊鍛樿繍琛宑md锛岃緭鍏 zerotier-cli.bat orbit id01 id01
linux鐩存帴杈撳叆 zerotier-cli orbit id01 id01
閮借寰楁敼鎴愯嚜宸辩殑锛屽埆鐬庢妱銆
鏈鍚庨氳繃 zerotier-cli listpeers 鏈夊嚭鐜颁綘鐨勬湇鍔″櫒ip灏辨垚鍔熶簡銆

涓嶅悓绯荤粺涓嬬殑 ZeroTier 鐩綍浣嶇疆锛
    Windows: C:\ProgramData\ZeroTier\One
    Macintosh: /Library/Application\ Support/ZeroTier/One)
    Linux: /var/lib/zerotier-one
    FreeBSD/OpenBSD: /var/db/zerotier-one锘