Go to file
2020-06-07 22:16:58 +05:45
android Standardize documentation (#211) 2020-03-28 19:24:34 +00:00
doc Standardize documentation (#211) 2020-03-28 19:24:34 +00:00
legacy Code rework changes 2019-04-27 15:55:07 +02:00
packages rpm-sign fix for centos8 2019-10-21 09:37:28 +02:00
tools Compilation fixes 2020-06-07 13:51:48 +02:00
win32 Windows compilation fixes 2019-07-08 12:06:28 +02:00
wireshark Add dissector port note 2019-08-15 18:13:59 +02:00
.gitignore Remove duplicate definitions 2020-03-16 15:07:11 +01:00
autogen.sh Added comparibility with OpenSSL 1.0 2020-04-24 08:21:12 +02:00
CHANGELOG.md Added changelog file 2018-08-17 14:47:37 +02:00
CMakeLists.txt Windows cmake fix 2020-05-27 10:54:12 +02:00
community.list Added the ability to specify (-c) on the supernode the list of allowed communities 2018-09-28 22:31:45 +02:00
config.guess Added configure and autogen.sh 2018-10-07 11:37:19 +02:00
configure.seed Merge branch 'dev' into zstdCompression 2020-06-07 10:03:22 +02:00
contributors.txt Refreshed copyright and added contributors list 2018-06-06 09:57:31 +02:00
COPYING Initial SVN import of n2n v2 2016-10-23 10:46:15 +02:00
edge_utils.c Compilation fixes 2020-06-07 13:51:48 +02:00
edge.8 Move -L flag doc to manpage 2019-11-13 21:57:18 +01:00
edge.c fixed A/z parameter handling 2020-06-07 22:16:58 +05:45
example_edge_embed_quick_edge_init.c Add more embedding examples and initally decomposed sn_utils 2020-03-16 15:03:03 +01:00
example_edge_embed.c Add more embedding examples and initally decomposed sn_utils 2020-03-16 15:03:03 +01:00
example_sn_embed.c Add more embedding examples and initally decomposed sn_utils 2020-03-16 15:03:03 +01:00
INSTALL Initial SVN import of n2n v2 2016-10-23 10:46:15 +02:00
LICENSE Initial commit 2016-10-23 10:42:16 +02:00
lzoconf.h Initial SVN import of n2n v2 2016-10-23 10:46:15 +02:00
lzodefs.h Initial SVN import of n2n v2 2016-10-23 10:46:15 +02:00
Makefile.in Merge pull request #235 from Logan007/cc20 2020-06-07 09:48:30 +02:00
minilzo.c Initial SVN import of n2n v2 2016-10-23 10:46:15 +02:00
minilzo.h Initial SVN import of n2n v2 2016-10-23 10:46:15 +02:00
n2n_transforms.h added Speck 2020-05-28 03:17:21 +05:45
n2n_wire.h added optional payload compression (lzo) for all transforms 2020-05-03 18:48:59 +02:00
n2n.7 Reworked debian/ubuntu packaging 2018-06-20 20:23:28 +02:00
n2n.c Implemnent n2n-decode utility to decode and dump traffic to PCAP 2019-09-20 02:13:07 +02:00
n2n.h Merge branch 'dev' into speck 2020-06-07 10:10:20 +02:00
README.md Compilation fixes 2020-06-07 10:00:18 +02:00
sn_utils.c Don't use implicit extern keyword and use static 2020-03-16 15:23:02 +01:00
sn.c Windows compilation fix 2020-05-24 11:25:12 +02:00
speck.c Linux compilation fixes 2020-06-07 14:40:49 +02:00
speck.h Compilation fixes 2020-06-07 14:39:57 +02:00
supernode.1 Initial SVN import of n2n v2 2016-10-23 10:46:15 +02:00
transform_aes.c Merge pull request #239 from Logan007/flexIv 2020-05-09 00:24:31 +02:00
transform_cc20.c Compilation fixes 2020-06-07 10:00:18 +02:00
transform_null.c Code rework changes 2019-04-27 15:55:07 +02:00
transform_speck.c Compilation fixes 2020-06-07 10:11:52 +02:00
transform_tf.c Code rework changes 2019-04-27 15:55:07 +02:00
tuntap_freebsd.c Fix a few leftover instances which used the old function name 2018-08-18 11:42:22 +04:30
tuntap_linux.c Add ability to insert linux routes in n2n 2020-05-23 16:21:45 +02:00
tuntap_netbsd.c Refreshed copyright and added contributors list 2018-06-06 09:57:31 +02:00
tuntap_osx.c Standardize documentation (#211) 2020-03-28 19:24:34 +00:00
twofish.c Properly initialize AES IV and hash the AES key 2019-04-16 02:09:13 +02:00
twofish.h Properly initialize AES IV and hash the AES key 2019-04-16 02:09:13 +02:00
uthash.h Update uthash to version 2.1.0 2019-06-10 00:33:11 +02:00
wire.c Implement query peer to try p2p during send 2019-06-08 22:04:10 +02:00

N2N

N2N is a light VPN software which make 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 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 PC 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 P2P connection 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 to connect to your PC. For privacy and to reduce the above server load, 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).

  1. Install the n2n package
  2. Edit /etc/n2n/supernode.conf and add the following:
    -l=1234
    
  3. Start the supernode service with sudo systemctl start supernode
  4. 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.

Routing the traffic

Reaching a remote network or tunneling all the internet traffic via n2n are two common tasks which require a proper routing setup. In this context, the server is the edge node which provides access to the remote network/internet, whereas the client is the connecting edge node.

In order to enable routing, the server must be configured as follows:

  1. Add the -r option to the edge options to enable routing
  2. Enable packet forwarding with sudo sysctl -w net.ipv4.ip_forward=1
  3. Enable IP masquerading: sudo iptables -t nat -A POSTROUTING -j MASQUERADE

On the client side, the easiest way to configure routing is via the -n option. For example:

  • In order to connect to the remote network 192.168.100.0/24, use -n 192.168.100.0/24:10.0.0.1
  • In order to tunnel all the internet traffic, use -n 0.0.0.0/0:10.0.0.1

10.0.0.1 is the IP address of the gateway to use to route the specified network. It should correspond to the IP address of the server within n2n. Multiple -n options can be specified.

As an alternative to the -n option, the ip route linux command can be manually used. See the n2n_gateway.sh script for an example. See also Routing.md for other use cases and in depth explanation.

Manual Compilation

On linux, compilation from source is straight forward:

./autogen.sh
./configure
make

# optionally install
make install

For Windows, check out Windows.md for compilation and run instuctions. For MacOS, check out macOS.md.

Running edge as a service

edge can also be run as a service instead of cli:

  1. Edit /etc/n2n/edge.conf with your custom options. See /etc/n2n/edge.conf.sample.
  2. Start the service: sudo systemctl start edge
  3. Optionally enable edge start on boot: sudo systemctl enable edge

You can run multiple edge service instances by creating /etc/n2n/edge-instance1.conf and starting it with sudo systemctl start edge@instance1.

IPv6 Support

N2N can tunnel IPv6 traffic into the virtual network but does not support IPv6 for edge-to-supernode communication yet.

Check out IPv6.md for more information.

Security considerations

n2n edge nodes use twofish encryption by default for compatibility reasons with existing versions.

IMPORTANT Encryption is only applied to the packet payload. Some metadata like the virtual MAC address of the edge nodes, their IP address and the community are sent in cleartext.

When encryption is enabled, 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.

Recently AES encryption support has been implemented, which increases both security and performance, so it is recommended to enable it on all the edge nodes that must have the -Ax value. When possible (i.e. when n2n is compiled with OpenSSL 1.1) we recommend to use -A4

A benchmark of the encryption methods is available when compiled from source with tools/n2n-benchmark.

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 Hacking guide.

Here is a list of third-party projects connected to this repository.

  • N2N for Android: hin2n
  • N2N v1 and v2 version from meyerd: meyerd n2n
  • Docker images: Docker Hub
  • Go bindings, management daemons and CLIs for n2n edges and supernodes, Docker, Kubernetes & Helm Charts: pojntfx/gon2n

(C) 2007-2019 - ntop.org and contributors