選擇用tinc的原因是因為官網的這句話.
Automatic full mesh routingRegardless of how you set up the tinc daemons to connect to each other, VPN traffic is always (if possible) sent directly to the destination, without going through intermediate hops.
不過到我架設起來為止並沒有成功的建立起P2P的連線. 反而是ZeroTier 成功了, 而且ZeroTier不用自己架Server, 滿方便的.
Install
Debian Linux: sudo apt install tinc
Windows: 官網載點
tinc架設方式, 把sun-moon兩台windows 作VPN連線, moon 可以遠端桌面到sun這台PC上.
Server & Client所需的設定檔基本上是一樣的, key 在3台設備都要有
server | client1 | client2 |
tinc.conf | tinc.conf | tinc.conf |
tinc-down | rsa_key.priv | rsa_key.priv |
tinc-up | hosts/main | hosts/main |
rsa_key.priv | hosts/client1 | hosts/client1 |
hosts/main | hosts/client2 | hosts/client2 |
hosts/client1 | ||
hosts/client2 |
設定
linux可參考 使用 Tinc VPN 实现远程办公
Windows可參考 官方教學windows-install
測試
client1(192.168.100.100) ping Server (192.168.100.1), latency 194ms
client2(192.168.100.101) ping server (192.168.100.1), latency 198ms
client2(192.168.100.101) ping client1 (192.168.100.100) , latency 394 ms
基本上就是透過server relay 封包的時間( client1 to server + server to client2).
雖然client1 可以看到 client2 外部ip 地址 (而非server), 但P2P似乎沒有生效.
References