务必自设 community 名(-c)和密钥(-k),否则别人可能连进你的机器;公共 supernode.ntop.org 只适合试用,正式用建议自建 supernode 并开放端口;dev 分支不保证与稳定版或旧 dev 状态兼容,建议用最新稳定版
sudo apt install n2n
sudo edge -c mynetwork -k mysecretpass -a 192.168.100.1 -f -l supernode.ntop.org:7777README 未说明
轻量级 P2P VPN,靠 supernode 牵线让边缘节点穿透防火墙组建虚拟网络
轻量级 P2P VPN,用 C 语言实现,让分布在不同网络中的设备像在同一局域网内直接通信,无需中心服务器中转。
核心能力
- 用 supernode 帮边缘节点互相发现并建立 UDP 直连
- 直连失败时由 supernode 中继转发数据包
- 用 community 名和密钥隔离并加密虚拟网络
- 边缘节点默认用 AES 加密载荷,可用 -A 换算法
- 支持单机同时加入多个 community
容易踩的坑
- 3.1.1pre-release2022-03-31 · 2022-03-31 12:49 UTC
这个版本没有写更新说明。
- 3.03.0 Stable Release最新正式版2021-10-27 · 2021-10-27 18:45 UTC
n2n 3.0 (October 2021)
During the last year, long discussed ideas turned into implemented functionalities – adding remarkably to n2n's rich feature set and each of them worthy of note. The level achieved made us think it justified even a major release. Welcome, n2n 3.0!
Starting from this stable platform, future versions of n2n's 3.x series will further promote its versatility while keeping up compatibility. To achieve this, development will mainly focus on areas outside the underlying core hole-punching protocol and will include but probably not be limited to connection handling, management capabilities, build system tuning as well as internal code structure.
For now, we would like to encourage you to have a look at the freshly released 3.0 yourself.
The following changelog intends to cause happy and eager anticipation. Enjoy!
New Features
- Federated supernodes to allow multiple supernodes for load balancing and fail-over (doc/Federation.md)
- Automatic IP address assignment allows edges to draw IP addresses from the supernode (just skip -a)
- Allowed community names can be restricted by regular expressions (community.list file)
- Network filter for rules (-R) allowing and denying specific traffic to tunnel
- Experimental TCP support (-S2) lets edges connect to the supernodes via TCP in case firewalls block UDP (not available on Windows yet)
- All four supported ciphers offer integrated versions rendering OpenSSL dependency non-mandatory (optionally still available)
- MAC and IP address spoofing prevention
- Network interface metric can be set by command-line option -x (Windows only)
- Re-enabled local peer detection by multicast on Windows
- Edge identifier (-I) helps to identify edges more easily in management port output
- Optionally bind edge to one local IP address only (extension to -p)
- A preferred local socket can be advertised to other edges for better local peer-to-peer connections (-e)
- Optional edge user and password authentication (-J, -P, doc/Authentication.md)
- Optional json format at management port allows for machine-driven handling such as .html page generation (scripts/n2n-httpd) or script-based evaluation (scripts/n2n-ctl)
- Completely overhauled build system including GitHub's action runners performing code syntax and formal checks, creating and running test builds, providing binairies and packages as artifacts and running verification tests
Improvements
- Increased edges' resilience to temporary supernode failure
- Fixed a compression-related memory leak
- Ciphers partly come with platform-specific hardware acceleration
- Added a test framework (tools/test-*.c and tests/)
- Clean-up management port output
- Polished benchmark tool output
- Spun-off the name resolution into a separate thread avoiding lags
- Added support for additional environment variables (N2N_COMMUNITY, N2N_PASSWORD, and N2N_FEDERATION)
- Implemented new reload_communities command to make supernode hot-reload the -c provided community.list file, issued through management port
- Reactivated send out of gratuitous ARP packet on establishing connection
- Enhanced documentation (doc/ folder) including the man pages and command-line help text (-h and more detailed --help)
- Self-monitoring time stamp accuracy for use on systems with less accurate clocks
- Fixed man pages' and config files' paths
- Code clean-up
- 2.82.8 Stable Release2020-08-12 · 2020-08-12 10:19 UTC
查看更新说明
n2n 2.8 (August 2020)
This release brings significant new features to n2n's crypto world and offers some compression opportunities. The added support for routing table manipulation might increase comfort. Besides further honing existing features, this release addresses some bugs.
New Features
- Two lightweight stream ciphers: ChaCha20 (optional, through OpenSSL) & SPECK (integrated)
- Full Header Encryption (including packet checksumming as well as replay protection)
- A callback interface to better integrate n2n in third party software (you can still use it stand-alone)
- Enable the integrated LZO1x compression
- Add optional ZSTD compression (through zstdlib)
- Support for changing system routes at program start and end
- User and group id parameter for supernode
- Application of cryptography in n2n is seperately documented
- Add a new pseudo random number generator with higher periodicity seeded with more entropy if available
Improvements
- Have AES and ChaCha20 use OpenSSL's
evp_*interface to make better use of available hardware acceleration - Fix invalid sendto when supernode name resolution fails
- Update to supernode's purge logic
- Extended management supernode's port output
- Fix read tap device failed when OS wakes up from sleep
- Free choice of supernode's management UDP port (for multiple supernodes on one machine)
- Additional trace messages to better indicate established connections and connection type
- Fix edge's register-to-supernode loop
- Remove redundant code
- Restructure the code in directories
- Clean-up platform-dependant code
- Compile fixes for Windows
- Fix build warnings
- …and many more under-the-hood fixes and tunings
- 2.62.6 Stable Release2020-03-24 · 2020-03-24 09:14 UTC
查看更新说明
- Add ability to specify a whitelist of allowed communities on the supernode
- Implement local peers discovery via multicast
- Windows compilation fixes and instructions
- MacOS compilation fixes and instructions
- Add support for multiple edge systemd services
- Implement AES encryption for increased security and throughput
- Add benchmark tool for the encryption throughput
- Improve the connection stability and the chances to enstablish a P2P connection
- Remove keyschedule support to simplify the encryption code
- Integrate the changes made in the meyerd fork of n2n
- Implement packet stats for P2P vs supernode communication
- Replace peers linked list with hash table for faster lookup in big networks
- Automatically drop provileges to user n2n
- n2n version improvements
- Add support for ARM64 build
- Instructions and makefile file to build n2n on OpenWRT
- More options to control MTU, P2P connections, TOS and log verbosity
- Implement a wireshark dissector for the n2n protocol
- Remove calls to system() in tuntap_linux and use netlink instead
- Implement n2n-decode utility to decode and dump traffic to PCAP
- 2.42.4 stable release2018-08-17 · 2018-08-17 12:32 UTC
查看更新说明
This is the first official release after having put n2n on hold. We have primarily focused on cleaning up code, repairing compilation issues, fixed various things including building and packaging for deb/rpm platforms. new features will be included in the next release, this is just a maintenance release that packages can use to refresh n2n in distributions.
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
n2n
n2n is a light VPN software which makes it easy to create virtual networks bypassing intermediate firewalls.
In order to start using n2n, two elements are required:
- A supernode: it allows edge nodes to announce and discover other nodes. It must have a port publicly accessible on internet.
- edge nodes: the nodes which will be a part of the virtual networks
A virtual network shared between multiple edge nodes in n2n is called a community. A single supernode can relay multiple communities and a single computer can be part of multiple communities at the same time. An encryption key can be used by the edge nodes to encrypt the packets within their community.
n2n tries to establish a direct peer-to-peer connection via udp between the edge nodes when possible. When this is not possible (usually due to special NAT devices), the supernode is also used to relay the packets.
Quick Setup
Some Linux distributions already provide n2n as a package so a simple sudo apt install n2n will do the work. Alternatively, up-to-date packages for most distributions are available on ntop repositories.
On host1 run:
$ sudo edge -c mynetwork -k mysecretpass -a 192.168.100.1 -f -l supernode.ntop.org:7777
On host2 run:
$ sudo edge -c mynetwork -k mysecretpass -a 192.168.100.2 -f -l supernode.ntop.org:7777
Now the two hosts can ping each other.
IMPORTANT It is strongly advised to choose a custom community name (-c) and a secret encryption key (-k) in order to prevent other users from connecting to your computer. For the privacy of your data sent and to reduce the server load of supernode.ntop.org, it is also suggested to set up a custom supernode as explained below.
Setting up a Custom Supernode
You can create your own infrastructure by setting up a supernode on a public server (e.g. a VPS). You just need to open a single port (1234 in the example below) on your firewall (usually iptables).
- Install the n2n package
- Edit
/etc/n2n/supernode.confand add the following:-p=1234 - Start the supernode service with
sudo systemctl start supernode - Optionally enable supernode start on boot:
sudo systemctl enable supernode
Now the supernode service should be up and running on port 1234. On your edge nodes you can now specify -l your_supernode_ip:1234 to use it. All the edge nodes must use the same supernode.
Manual Compilation
On Linux, compilation from source is straight forward:
./autogen.sh
./configure
make
# optionally install
make install
For Windows, MacOS, optimizations and general building options, please check out Building documentation for compilation and running.
IMPORTANT It is generally recommended to use the latest stable release. Please note that the current dev branch usually is not guaranteed to be backward compatible neither with the latest stable release nor with previous dev states. On the other hand, if you dare to try bleeding edge features, you are encouraged to compile from dev – just keep track of sometimes rapidly occuring changes. Feedback in the Issues section is appreciated.
Security Considerations
When payload encryption is enabled (provide a key using -k), the supernode will not be able to decrypt
the traffic exchanged between two edge nodes but it will know that edge A is talking with edge B.
The choice of encryption schemes that can be applied to payload has recently been enhanced. Please have
a look at Crypto description for a quick comparison chart to help make a choice. n2n edge nodes use
AES encryption by default. Other ciphers can be chosen using the -A_ option.
A benchmark of the encryption methods is available when compiled from source with tools/n2n-benchmark.
The header which contains some metadata like the virtual MAC address of the edge nodes, their IP address, their real
hostname and the community name optionally can be encrypted applying -H on the edges.
Advanced Configuration
More information about communities, support for multiple supernodes, routing, traffic restrictions and on how to run an edge as a service is available in the more detailed documentation.
Contribution
You can contribute to n2n in various ways:
- Update an open issue or create a new one with detailed information
- Propose new features
- Improve the documentation
- Provide pull requests with enhancements
For details about the internals of n2n check out the Hacking guide.
Further Readings and Related Projects
Answers to frequently asked questions can be found in our FAQ document.
Here is a list of third-party projects connected to this repository:
- Collection of pre-built binaries for Windows: lucktu
- n2n for Android: hin2n
- Docker images: Docker Hub
- Go bindings, management daemons and CLIs for n2n edges and supernodes, Docker, Kubernetes & Helm Charts: pojntfx/gon2n
- Windows GUI (along with a custom version of n2n) but also working with regular n2n: HappyNet
(C) 2007-22 - ntop.org and contributors
