[HOWTO] OSMC/Rasp Pi as OpenVPN client


That sound you are talking about the openvpn kodi addon, or?
Have you installed and configured openvpn on the OS level?


When run through putty, this is the log:

login as: osmc
osmc@’s password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Nov 30 12:33:40 2015 from
osmc@osmc:~$ sudo openvpn /home/osmc/vpn-config/TCP/USA-FLORIDA-TCP.ovpn
Mon Nov 30 13:02:13 2015 OpenVPN 2.3.4 arm-unknown-linux-gnueabihf [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Dec 1 2014
Mon Nov 30 13:02:13 2015 library versions: OpenSSL 1.0.1k 8 Jan 2015, LZO 2.08
Mon Nov 30 13:02:13 2015 WARNING: file ‘/home/osmc/vpn-config/pass.txt’ is group or others accessible
Mon Nov 30 13:02:13 2015 WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info.
Mon Nov 30 13:02:13 2015 WARNING: file ‘/home/osmc/vpn-config/Wdc.key’ is group or others accessible
Mon Nov 30 13:02:13 2015 Control Channel Authentication: using ‘/home/osmc/vpn-config/Wdc.key’ as a OpenVPN static key file
Mon Nov 30 13:02:13 2015 Attempting to establish TCP connection with [AF_INET] [nonblock]
Mon Nov 30 13:02:14 2015 TCP connection established with [AF_INET]
Mon Nov 30 13:02:14 2015 TCPv4_CLIENT link local: [undef]
Mon Nov 30 13:02:14 2015 TCPv4_CLIENT link remote: [AF_INET]
Mon Nov 30 13:02:14 2015 WARNING: this configuration may cache passwords in memory – use the auth-nocache option to prevent this
Mon Nov 30 13:02:23 2015 [PureVPN] Peer Connection Initiated with [AF_INET]
Mon Nov 30 13:02:25 2015 TUN/TAP device tun2 opened
Mon Nov 30 13:02:25 2015 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Mon Nov 30 13:02:25 2015 /sbin/ip link set dev tun2 up mtu 1500
Mon Nov 30 13:02:25 2015 /sbin/ip addr add dev tun2 broadcast
RTNETLINK answers: File exists
Mon Nov 30 13:02:28 2015 ERROR: Linux route add command failed: external program exited with error status: 2
RTNETLINK answers: File exists
Mon Nov 30 13:02:28 2015 ERROR: Linux route add command failed: external program exited with error status: 2
RTNETLINK answers: File exists
Mon Nov 30 13:02:28 2015 ERROR: Linux route add command failed: external program exited with error status: 2
Mon Nov 30 13:02:28 2015 Initialization Sequence Completed
^CMon Nov 30 13:03:25 2015 event_wait : Interrupted system call (code=4)
Mon Nov 30 13:03:25 2015 /sbin/ip addr del dev tun2
Mon Nov 30 13:03:25 2015 SIGINT[hard,] received, process exiting


I have been trying to follow the Brian Hornsby instructions.


It is really hard to remotely trouble shoot that and I also don’t think that this thread is the right place. I will sent you a PM and we can try from there


Hey, thanks A LOT for this thread. Managed to follow Bryan’s tutorial (followed the raspbmc steps but some things are still outdated for OSMC - be sure you’re on the right paths) and also your tweaks with the sudoers file.

I know just have one question: is there anyway I can auto-start this add-on, or should I just create a normal linux init script? If I go the linux startup script, won’t I loose that once OSMC is updated?

Cheers and, again, big thanks!


I’d like to know this too.
Pedro if you manage to figure out a working script, please share it! I have no idea how to make one of those. Would be nice to have some indication on the main screen that the OpenVPN is running.


I ended up creating a simple startup script which gets the job done…

Just create a script:
sudo vi /etc/init.d/startOpenVPN

#! /bin/sh
# /etc/init.d/startOpenVPN
# Provides:          openVPN
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Simple script to start a program at boot
# Description:       Start / stop OpenVPN at boot / shutdown.

openvpn /{YOUR_PATH}/{yourOwn}.ovpn

(edit the last line and make sure the path to your .ovpn file is correct)

and just make executable:
sudo chmod 755 /etc/init.d/startOpenVPN

and register it to start at startup:

sudo update-rc.d startOpenVPN defaults

reboot the Pi and check if it has started:
ps aux | grep openvpn

For what I need, it gets the job done. Thanks, again, to the OP for his tweaks!



First of all i’m a total noob about ssh, linux and such but i was able to success on connecting to my private vps vpn server via openVPN client on osmc. The problem is i can only connect it via ssh command without any error and working fine but when i try to connect it from OSMC interface after i choose my vpn name it says “An existing OpenVPN instance appears to be running. Disconnect it?” If i say yes it asks me again and upon clicking no nothing happens. Also i tried to add an automated script which Pedro_Diogo mentioned, after i save script via :wq command and try to run sudo chmod 755 startOpenVPN it gives me an error of no such a file or directory.

As i said i’m total noob so please excuse me

edit: i’m using raspberry pi B+ with manual OSMC installation. My private vps vpn server is not local and loaded with openVpn software

edit2: When i connect with ssh command it opens 2 client connections according to OpenVPN management tool which is the maximum concurrent client at the same time.


Hello there,

If you have followed my steps exactly, you might have problems with the chmod 755 as you might not have indicated the full path of the file. Just do chmod 755 /etc/init.d/startOpenVPN instead. I’ve changed my post so others do not do same mistake.

Also, in my script, make sure you provide the full path of yourOwn.ovpn file. I’ve written yourOwn.ovpn only, but you should point it to where you’ve saved it.

If you do it my way, you won’t need the openvpn add-on as the Pi will automatically connect to the VPN server overtime you start it up. Not sure if that’s what you want, though.

Let me know if you made it work.


The problem is the addon won’t connect to the vpn server no matter how long i wait so that’s why i need to use ssh command to connect. Should i delete the addon if i want to automate this process via your method?


Do you need Kodi on the Rasperry Pi to run the OpenVPN software?

I’d like to setup my Raspberry Pi 2 running OSMC and NOT Kodi to establish an openVPN connection then on my FireTV I’d to connect the Kodi part only not the fireTV to go through the Raspberry Pi OpenVPN, is this possible???


If you are running OSMC then YOU ARE running Kodi!!
Read this:

Don’t know where you are gonna find networking support for FireTV… Outside the scope of OSMC…
Try here - http://forum.xda-developers.com/fire-tv/general


Yeah I keep forgetting that OSMC is written for KODI, I keep thinking of it as a dedicated OS with KODI on it :slightly_smiling:
I’ll just leave KODI in the background doing nothing then and run it on of the FireTV :slight_smile:


I’m running into this issue now as well. OpenVPN starts up fine if I omit the line redirect-gateway but that’s the exact feature I’m looking for. When I leave that setting in, I get the same route add error:

Sun Jan 10 15:23:48 2016 us=824936 ERROR: Linux route add command failed: external program exited with error status: 2
Sun Jan 10 15:23:48 2016 us=825161 /sbin/ip route add via
Sun Jan 10 15:23:48 2016 us=830796 Initialization Sequence Completed

Here’s my config file:

management localhost 1337
dev tun
proto udp
remote myvpn.com 8888
resolv-retry infinite
remote-cert-tls server
auth-user-pass /etc/openvpn/pass.txt
link-mtu 1557
verb 4
reneg-sec 0
cipher AES-256-CBC

Have you found a solution to the routing / connman issue many people have reported?



Hey, first of all; thnx to all contributing to this thread: I was able to get it running (almost).

There is one thing missing: if I check my external IP, it still reports my home IP, and not my VPN providers IP. I used wtfismyip.com with a browser in OSMC to check this.

I use the same VPN on my laptop, and then my IP changes, to that of the provider. But not on my OSMC.

In OSMC is says the VPN is connected just fine.

By the way, also when I check with my VPN provider, it shows that indeed the connection was made… but then why is the IP not changing?

I also tried curl ifconfig.me and also got my home IP.


I had this same problem and haven’t been able to devise a solution to determine if all traffic from OSMC/the box is being tunneled over VPN.


I’ve been wrestling with this too. When starting the service I also get the error:

Sun Mar  6 12:49:47 2016 us=612102 /sbin/ip route del
Sun Mar  6 12:49:47 2016 us=622373 /sbin/ip route add via 213.179.213.                                                                                        193
RTNETLINK answers: File exists
Sun Mar  6 12:49:47 2016 us=630310 ERROR: Linux route add command failed: extern                                                                                        al program exited with error status: 2
Sun Mar  6 12:49:47 2016 us=630612 Initialization Sequence Completed

The IP-check also fails (shows my home IP), anyone with a solution for this issue?


FYI, after reading this whole thread and trying a few different approaches, this method ended up being the easiest for me to get OpenVPN working on my OSMC/Raspberry Pi 3. Notably, I couldn’t get the openVPN kodi plug-in working at all.

The only slight variation, since I was modifying the *.opvn file using vi to include the path for the password file, like odin_smash:

auth-user-pass /etc/openvpn/pass.txt

P.S. For some reason, ‘sudo systemctl enable openvpn@vpn.service sudo systemctl start openvpn@vpn.service’ is getting put on one line whereas it should be two seperate commands.



I have tried following the info contained in this thread to get my VPN working. I have a box already running Openelec and the VPN works fine on that following Brian Hornsby’s instructions. Now I have a new Pi3 I thought I’d give OSMC a go and its proving to be a pain. First off I can’t find an openvpn directory under user/sbin/openvpn although there is an openvpn file and this presumably has been installed following sudo apt-get install openvpn.
In the kodi B.Hornsbys settings it also pints to this file so thats what I’ve used as my openvpn . Am I right??
So using the B.Hornsbys kodi app I can see it connects to the vpn but
a: my IP is still showing as my local IP in OSMC
b: After about a minute or so it disconnects from the VPN without warning.
Is this a problem with the OSMC or have I got the setup wrong.


type in the console which openvpn :smiley: in order to see where the executable is. But you should be able to run it from commandline. sudo openvpn client.conf. and then check with ipconfig if a connection is made …

Maybe the connection is timing out?