'kodi with split tunnel VPN

I have searched the forum and beyond but have not found an answer to my problem, So....

I have installed kodi on top of Ubuntu 16.04.6 LTS which is all running on an Intel NUC.

I have installed a split tunnel system where all traffic goes through the usual internet connection with the exception of user2 who's traffic goes through the VPN I have set up. I have tested this by running

$ curl ipinfo.io

and

$ sudo -u user2 -i -- curl ipinfo.io

The first command shows my ISP's IP address and the second command shows my VPN's IP address as expected.

I have done this to allow me to run kodi under user2 while being logged into Ubuntu under user1. This allows me to SSH into my Ubuntu system under user1 which would not be possible if everything went through the VPN.

From the log in screen I can run kodi or Ubuntu for a number of users that I have set up. However I want to log into Ubuntu as user1 and then within the Ubuntu session run kodi under user2. So I thought I could do the following:

Log into Ubuntu as user1, open a terminal and run

$ su - user2

Then run kodi by typing

$ sudo kodi

I have to type 'sudo kodi' instead of 'kodi' otherwise kodi does not run and gives a GUI error. However, when doing this the kodi user is user2 (user setup for VPN) but running the speed test app for kodi shows that the connection is not running through the VPN as expected. I know kodi is through user2 as the add-ons I have installed are the ones for kodi under user2.

So, why is kodi using the user2 settings but not using the VPN? Is this to do with me running 'sudo kodi' in the terminal or could it be something else?

Come to think of it, is what I'm trying to do even possible?

Any help much appreciated.



Solution 1:[1]

OK, well, I finally found a solution thanks to help from the kodi forum. In the end the solution is very simple. I can log into Ubuntu as user1 as usual. Then I simply switch users to user2 and then run kodi under user2.

Solution 2:[2]

Install kodi-standalone and run it with systemd then apply vpn split iptable rules for kodi user.

https://kodi.wiki/view/HOW-TO:HOW-TO:Autostart_Kodi_for_Linux

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chazg76
Solution 2 Goodarzi