I was trying to set up remote access to the LAN of an OpenVPN client, by configuring the OpenVPN client as a gateway. There are plenty guides online on how to do this, such as this one. In my setup, I was using a Netgear router, with a Raspberry Pi connected to it acting as the OpenVPN client and gateway for the LAN. I followed the setup carefully, but was frustrated to find it didn't work. The VPN worked fine: I could access the Raspberry Pi remotely, both on its VPN IP and its LAN IP addresses. Still, I could not gain access to the LAN it was connected to, even though I had set up a static route in the router to send all VPN traffic to the Raspberry Pi.

After breaking my head over this for a long time and getting very frustrated, I finally figured out what was going on. I needed to enable IP forwarding on the Raspberry Pi! To do this in such a way it is configured correctly at boot, uncomment the following line in /etc/sysctl.conf:

net.ipv4.ip_forward=1

That's it! After that, my setup worked beautifully. Hopefully this will save someone else some time and frustration. :-)

Every now and then, articles pop up about how archaic text based source code is, and how everyone would benefit so much if we'd all switch to graphical code design by dropping little boxes and connecting them with wires. We've heard this story so often before, and yet source code is still the preferred method to write software. Why? There are so many reasons, and they should be obvious.