this tutorial:


shows how to turn an raspberry pi into a VPN hotspot.

I find the iptable configs at step 7 and 11 confusing, in that:

  1. why was things done in step 7 undone in 11? To reroute the traffic through openVPN?

  2. Can you please tell me what these 3 lines do? my guess:

    sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE

Seems to be telling the OS to do something after traffic came out of tun0, which is the VPN process I suppose.

sudo iptables -A FORWARD -i tun0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT

Tell the OS to accept any traffic coming from tun0 and forward it to wlan 0

sudo iptables -A FORWARD -i wlan0 -o tun0 -j ACCEPT

Tell the OS to accept any traffic coming from wlan0 and forward it to tun0.

  1. Theoretically the traffic should be flowing from wlan0 to tun0 then eth0 (I could be totally, totally wrong), but I saw the part where it addressed wlan0 to tun0 but not tun0 to eth0? Or is it not necessary as eth0 is seen as the default ethernet/internet outlet interface?

Sorry for the imposition brought about by such a complicated and comprehensive question!

  • Sorry, but do you really expect that we follow the whole tutorial to understand it?
    – Ingo
    Nov 18, 2020 at 10:02
  • @Ingo not necessary! Just tell me what those 3 lines mean would be fine.
    – cream_pi
    Nov 19, 2020 at 7:23


Your Answer

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

Browse other questions tagged or ask your own question.