The debian server is configured like this:

enp0s8 = WAN
enp0s10 = LAN (Internet via tun0)
enp0s12 = LAN access only, no internet available
tun0 = Main VPN Connection
tun1 = Secondary VPN Connection

I'm trying to forward the traffic originating from to the secondary VPN Connection, while all other devices gets internet via tun0.

My iptables configuration currently is:

iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
iptables -A FORWARD -i enp0s10 -o tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -o enp0s10 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -P FORWARD DROP
iptables -P INPUT DROP

First I tried using this to enable forwarding to the secondary VPN interface and route to it:

iptables -t nat -A POSTROUTING -o tun1 -j MASQUERADE
iptables -A FORWARD -i enp0s10 -o tun1 -j ACCEPT
iptables -A FORWARD -i tun1 -o enp0s10 -m state --state ESTABLISHED,RELATED -j ACCEPT
ip route add dev tun1

Doing this just blocked internet for I also tried using PREROUTING and POSTROUTING (DNAT and SNAT) but that makes the same effect as:

ip route add dev tun1

Is there any way I can make it work?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.