4

n2n一种peer to peer的VPN的使用

 2 years ago
source link: https://zhangrr.github.io/posts/20211105-n2n_vpn/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

N2n一种peer to Peer的VPN的使用

2021-11-05 1 分钟阅读

vpn的搭建一直是一个难解的题目,openvpn、ipsec、tinc 都在用,都不够简洁。

n2n 是一种 peer to peer 端到端的 vpn,搭建起来非常简单方便。必备利器

首先了解一下概念

image-20211105135642166

n2n 的 vpn 分为两种角色,Supernode 超级节点和 Edgenode 边缘节点。

很简单,Supernode 最好是公网地址,需要开放端口供其它节点连接上来;剩余的 Edgenode 可以没有公网地址,各个 Edgenode 边缘节点之间会尝试绕过 Supernode 直接连接。这大大提高了节点之间通讯的效率。通讯是加密的,非常安全。

安装的话完全不用安装,直接一个命令就搞定了。

https://github.com/ntop/n2n

弄出两个可执行文件 supernode 和 edge 就好了

超级节点:

/usr/local/bin/supernode -p 11111 -v

边缘节点:

/usr/local/bin/edge -d n2n0 -c ThisisaSecret2012 -k Fuck2020 -a 192.168.0.2 -l 41.22.59.112:11111 -f

参数解释:

  • -d 生成的虚拟网卡的命名
  • -c 某组vpn节点的口令。大家看到启动 supernode 的时候没有任何参数,supdernode 只负责转发。supernode 支持多组不同的 vpn。这里就是用来区分不同的 vpn 组的。
  • -k 节点之间通讯是用的 twofish 加密算法,这里指定的是密钥
  • -a 节点的ip
  • -l supernode的ip和端口
  • -f 放到后台 daemon 执行

这样就建立好了,系统中会多出一张 n2n0 的网卡。

image-20211105141808048


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK