Linux OpenVPN and IP Routes

There are certain background tasks that I perform with my iMac that requires VPN services. In the interest of saving some electricity, my goal is to have my iMac goto sleep and idle at a lower power consumption state, than what has been in the past. Let’s just say that our main iMac is on at all times, because it served as our media server for our collection of viewable devices such as iPads, Apple TV’s, etc.

This blog post is just a self account of my activities and is not a detail tutorial containing command line examples of how to accomplish this. Sorry you’ll have to go else where for that.

I managed to move all these services to my Linux box running Ubuntu Server 16.04.1 LTS. The Linux server was acting as my Network Attached Storage (NAS) server, while my iMac was running all the application services that I use around the house, which includes:

  • Plex Media Server
  • Minecraft Server for the Kids
  • Apache Server for certain web applications that the kids use
  • Other services that require VPN connectivity back to the office and else where

I needed to move all of the above services from my iMac to my Linux server so that my iMac can effectively goto sleep and save me some power. I managed to move all the non-VPN services first and saved the VPN services for later.

To my surprise, it was really easy installing OpenVPN. When I connect to the office, I found out that I could not get to the other services, because the return traffic was rerouted through the VPN tunnel. I needed a way to configure the Linux Server to route certain IP traffic from services originating from my Linux Server to bypass the VPN tunnel interface. This is when I learned everything about iproute2, and iptables. As it turned out, I did not have to use iptables.

However I did spend a good portion of my Sunday afternoon to read up on these utilities, and after several iterations I finally got the configurations working. It was a combination of creating a new ip routing table with default routes targeting the physical interface instead of the tunnelling interface, and an ip rule to configure certain traffic to use the routing table. Now my iMac can goto sleep when it is not being used by us, saving us electricity!

One thought on “Linux OpenVPN and IP Routes”

Leave a Reply

Your email address will not be published. Required fields are marked *