1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-27 02:09:06 +02:00
dockerfiles/n2n/README.md

64 lines
1.5 KiB
Markdown
Raw Normal View History

2019-05-30 13:39:48 +02:00
n2n
===
[n2n][1] is a layer-two peer-to-peer virtual private network (VPN) which allows
users to exploit features typical of P2P applications at network instead of
application level.
2019-07-09 19:20:00 +02:00
```
.............VPN................
+------LAN-+-----+ +- Edge.
| . | / .
| Client ->.Edge +-> Supernode <-+- Edge .
2019-07-13 12:04:30 +02:00
| . | (Edge) \ .
2019-07-09 19:20:00 +02:00
+----------+-----+ +- Edge.
................................
```
2019-07-13 12:04:30 +02:00
## Supernode/Edge (eth0:1.2.3.4, n2n0:192.168.100.1/24)
2019-07-09 19:20:00 +02:00
```bash
2019-07-13 12:04:30 +02:00
# start supernode & edge
$ docker-compose up -d
2019-07-13 12:37:21 +02:00
$ ifconfig
eth0: 1.2.3.4
br-2e0238bf6b9d: 172.20.0.1
2019-07-13 12:04:30 +02:00
# config edge routing
$ docker-compose exec edge bash
>>> ifconfig
2019-07-13 12:37:21 +02:00
eth0: 172.20.0.2
n2n0: 192.168.100.1
>>> iptables -t nat -A POSTROUTING -j MASQUERADE
2019-07-13 12:04:30 +02:00
>>> exit
2019-07-13 12:37:21 +02:00
2019-10-01 09:55:54 +02:00
# get bridge ip
$ ip route get 192.168.200.1
192.168.200.1 via 172.20.0.2 dev br-2e0238bf6b9d src 172.20.0.1
2019-07-13 12:37:21 +02:00
# add vpn route (via edge's n2n0)
$ ip route add 192.168.200.0/24 via 172.20.0.2
$ ping 192.168.200.1
2019-07-09 19:20:00 +02:00
```
2019-07-09 19:59:59 +02:00
## Edge (eth0:192.168.1.23/24, n2n0:192.168.100.x/24)
2019-07-09 08:09:16 +02:00
```bash
2019-07-09 19:20:00 +02:00
$ docker-compose up -d edge
$ sysctl -w net.ipv4.ip_forward=1
2019-07-14 08:55:27 +02:00
$ iptables -t filter -A FORWARD -j ACCEPT
2019-07-09 19:20:00 +02:00
$ iptables -t nat -A POSTROUTING -o n2n0 -j MASQUERADE
```
2019-07-09 08:09:16 +02:00
2019-07-09 19:59:59 +02:00
## Client (eth0:192.168.1.45/24)
2019-07-09 19:20:00 +02:00
```bash
$ ip route add 192.168.100.0/24 via 192.168.1.23
2019-07-13 12:04:30 +02:00
$ ping 192.168.100.1
2019-07-09 19:59:59 +02:00
$ nmap -sP 192.168.100.0/24
2019-07-09 08:09:16 +02:00
```
2019-07-14 08:55:27 +02:00
> Static routes can be added on your home router.
2019-05-30 13:39:48 +02:00
[1]: https://www.ntop.org/products/n2n/