参考:/2220.html
/meyerd/n2n/wiki
1. 下载源码 git clone /meyerd/n2n.git
2. 安装工具
brew cask install tuntapbrew install opensslbrew install cmake
3. 编译n2n
~/n2n/n2n_v2$ mkdir build~/n2n/n2n_v2$ cd build~/n2n/n2n_v2/build$ cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl ../-- The C compiler identification is AppleClang 8.1.0.802-- The CXX compiler identification is AppleClang 8.1.0.802-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works-- Detecting C compiler ABI info-- Detecting C compiler ABI info - done-- Detecting C compile features-- Detecting C compile features - done-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works-- Detecting CXX compiler ABI info-- Detecting CXX compiler ABI info - done-- Detecting CXX compile features-- Detecting CXX compile features - done-- Found OpenSSL: /usr/local/opt/openssl/lib/libcrypto.dylib (found version "1.0.2l")-- Configuring done-- Generating done-- Build files have been written to: ~/n2n/n2n_v2/build~/n2n/n2n_v2/build$ sudo make installsudo chmod -R 777 /usr/local/sbinexport PATH=$PATH:/usr/local/sbin
4. 创建n2n连接
sudo edge -d n2n0 -c mynetwork -k encryptme -u 99 -g 99 -m 3C:A0:12:34:56:78 -a 1.2.3.4 -l a.b.c.d:xyw -v -f
5. 如果出现错误提示ERROR: Unable to open tap device,可以通过下面方式安装虚拟网卡
brew cask install tuntap查看是否有如下两个内核扩展ls /Library/Extensions/tap.kextls /Library/Extensions/tun.kext校验内核扩展的参数find /Library/Extensions/{tap,tun}.kext/ -type f | xargs shasum加载内核扩展sudo /sbin/kextload /Library/Extensions/tap.kextsudo /sbin/kextload /Library/Extensions/tun.kext
6. edge帮助
edge-d<tundevice>-a<tunIPaddress>-c<community>-k<encryptkey>-s<netmask>[-u<uid>-g<gid>][-f][-m<MACaddress>]-l<supernodehost:port>[-p<localport>][-M<mtu>][-t][-r][-v][-b][-h]-d<tundevice>|tundevicename-a<tunIPaddress>|n2nIPaddress-c<community>|n2ncommunityname-k<encryptkey>|Encryptionkey(ASCII)-alsoN2N_KEY=<encryptkey>-s<netmask>|Edgeinterfacenetmaskindotteddecimalnotation(255.255.255.0)-l<supernodehost:port>|SupernodeIP:port-b|PeriodicallyresolvesupernodeIP|(whensupernodesarerunningondynamicIPs)-p<localport>|Localportusedforconnectingtosupernode-u<UID>|UserID(numeric)tousewhenprivilegesaredropped-g<GID>|GroupID(numeric)tousewhenprivilegesaredropped-f|Forkandrunasadaemon.Usesyslog.-m<MACaddress>|ChooseaMACaddressfortheTAPinterface|eg.-m01:02:03:04:05:06-M<mtu>|Specifyn2nMTU(default1400)-t|Usehttptunneling(experimental)-r|Enablepacketforwardingthroughn2ncommunity-v|Verbose