Skip to content

Commit

Permalink
New routing instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuele-f authored May 23, 2020
1 parent 0e48e2f commit 2a28bd1
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,22 @@ Now the supernode service should be up and running on port 1234. On your edge no

## Routing the traffic

On linux, n2n provides a standard TAP interface, so routing works gracefully via the standard system utilities as follows.
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 this example host1 is the edge router (with n2n IP 192.168.100.1), whereas host2 is the client.

Here is how to configure host1:
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. Possibly configure iptables to `ACCEPT` the packets on the `FORWARD` chain.

On host2, run the `edge` program as normal to join the host1 community.

In order to forward all the internet traffic via host2:
3. Enable IP masquerading: `sudo iptables -t nat -A POSTROUTING -j MASQUERADE`

```sh
# Determine the current gateway (e.g. 192.168.1.1)
$ ip route show default

# Add a route to reach the supernode via such gateway
$ sudo ip route add supernode.ntop.org via 192.168.1.1
On the client side, the easiest way to configure routing is via the `-n` option. For example:

# Forward all the internet traffic via host1
$ sudo ip route del default
$ sudo ip route add default via 192.168.100.1
```
- 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`

This process can be greatly simplified by using the [n2n_gateway.sh](doc/n2n_gateway.sh) script.
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.

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

## Manual Compilation

Expand Down

0 comments on commit 2a28bd1

Please sign in to comment.