Skip to content

Commit

Permalink
Document iptables possibility
Browse files Browse the repository at this point in the history
  • Loading branch information
JeWe37 committed Sep 9, 2022
1 parent 74b9123 commit b43cdf6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ This package provides a tunnel between the init namesapce and the created VPN
namespace so, e.g., you can control services inside the VPN namespace from
outside. If you don't need or want the tunnel, just set `TUNNEL_ENABLE=0`.

##### iptables rules

To control the services from outside the VPN as though they were running in the
physical namespace, rather than only having the accessible from this host, a
few iptables rules are required. Here I'm assuming that `net.ipv4.ip_forward=1`
and that the `FORWARD` table is allowing forwarding between interfaces.
```
iptables -t nat -A PREROUTING -i [PHYSICAL] -p tcp -m tcp --dport [PORT] -j DNAT --to-destination [TUNNEL_VPN_IP_ADDRESSES]:[PORT]
iptables -t nat -A POSTROUTING -d [TUNNEL_VPN_IP_ADDRESSES] -o [TUNNEL_VPN_NAME] -p tcp -m tcp --dport [PORT] -j MASQUERADE
```
For example with the standard settings to forward port 8000 from `eth0` you may use
```
iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 8080 -j DNAT --to-destination 10.127.0.2:8080
iptables -t nat -A POSTROUTING -d 10.127.0.2/32 -o veth-vpn0 -p tcp -m tcp --dport 8080 -j MASQUERADE
```

#### Namespace Overlay

Most likely, there will be some additional configuration that you will want to
Expand Down

0 comments on commit b43cdf6

Please sign in to comment.