I have a RPi3 running an openvpn client via the Rpi3 ethernet(eth0) port and notice Tun0 being created in interface as connections are established. I was successful in routing vpn traffic to a Wifi hotspot i created.
However now I would like to know how to route the VPN traffic to a external Ethernet(eth1) I attached. So,
Internet Gateway --> RPi3's eth0 iface -->OpenVPN (tun0) --> Rpi3's externel ethernet adapter eth1.
Gateway is 192.168.1.1
eth0 (static) 192.168.1.27
I am trying to re-purpose a few old devices for streaming and monitor and if I directly run OpenVPN there, I experience performance issues. Previously I used the RPi3 as VPN gateway and that worked. Now i would like to learn more to see if I could use the RPI3 to encrypt and route the encrypted traffic to eth1. I have read topics on Bridge-utils, iptables, route and later a little on layers tun and eth are of different layer and cannot be bridged.
I felt it was something to do with IPtables and I tried the following.
But still unsuccessful. Any advice will be much appreciated. Thank you
Code: Select all
sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE sudo iptables -A FORWARD -i tun0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i eth1 -o tun0 -j ACCEPT