My raspberry pi is connected to a OpenVPN server on interface tun0. The internet connection is setup over a 3G/UMTS mobile stick(eth1).

How can I forward all traffic coming from tun0 to a device with a static ip-adress behind eth0(ethernet port) with iptables?

I added this rule to allow forwarding:

iptables -A FORWARD -i tun0 -o eth0 -j ACCEPT

But how can I route all traffic on a specific ip behind eth0?

  • 1
    Hi, I know it's been a while since you have posted this question, but I am trying to do exactly the same thing as you have described here. I am not really good at all this networking shenanigans. Would you be able to post your /etc/network/interfaces or point me into some tutorials you have used to configure your Pi? I would greatly appreciate this. Thanks :) Mar 21, 2017 at 9:20

1 Answer 1


You want to use "DNAT" for this. You do DNAT in the PREROUTING nat table.

Probablly something along the lines of

iptables -t nat -A PREROUTING -i tun0 -j DNAT --to-destination <destination ip>


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.