Network namespaces – part 2

How to run OpenVPN tunnel inside a network namespace

Linux network namespaces can be used to control which processes should be tunneled by OpenVPN.

First create an –up and –down script for OpenVPN. This script will create the VPN tunnel interface inside a network namespace called vpn, instead of the default namespace.

Then start OpenVPN and tell it to use our –up script instead of executing ifconfig and route.

Now you can start programs to be tunneled like this:

Or start a separate shell

 

Leave a Reply

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