Yes
Think thatās done it - excellent! Should I be concerned about the āFailed to start OpenVPN tunnelā messages on boot, even though the vpn is connecting every time? In case logs helpā¦
https://paste.osmc.tv/qolulademe
cheers Tom
Hi,
Have you removed the autoexec.py file?
It doesnāt look like systemd is successfully starting openvpn:
Options error: In [CMD-LINE]:1: Error opening configuration file: Ireland.conf
Whats the VPN conf file called and where is it located?
Thanks Tom.
Hi Tom. Yes, I removed the autoexec.py file. VPN conf file is called Ireland.conf and is located in /etc/openvpn/Ireland.conf. Iāve since done a fresh install and get the same eror messages. logs hereā¦
https://paste.osmc.tv/pumunanufi.
Just for clarityā¦I unzipped PIA files, created Ireland.conf and login.conf files, set āIrelandā to autostart in /etc/default/openvpn and followed your instructions, creating a copy in /etc/systemd/system/openvpn-client@.service, adding
Restart=on-failure
RestartSec=5s
under services in Vi (exiting and saving with escape - :x - enter) and sudo systemctl daemon-reload
. Thatās it. Have I missed something?
Hi,
If you are happy its working, you can probably ignore these errors; but if want to get to the bottom of it; then advise on the following:
Did you also issue:
sudo systemctl enable openvpn-client@Ireland
Also whatās the output of:
systemctl status openvpn-client@Irleand
If you have issued sudo systemctl enable openvpn-client@Ireland, does it still work if you comment our or revert the entry /etc/default/openvpn? I only suggest this, as the log is reporting issues with Ireland.conf and I donāt think updating the default file is completely necessary anymore.
Its also reporting issues with resolving ireland.privateinternetaccess.com, may wish to use the IP address in the conf file instead.
Thanks Tom.
Hi
Yes, sorry, I did issue sudo systemctl enable openvpn-client@Ireland
. I would prefer to get to the bottom of this to be honest. I will try the IP address in the conf file, revert the entry /etc/default/openvpn and get back to you. Hereās the result from systemctl status openvpn-client@Irleandā¦
osmc@osmc:~$ systemctl status openvpn-client@Ireland
- openvpn-client@Ireland.service - OpenVPN tunnel for Ireland
Loaded: loaded (/etc/systemd/system/openvpn-client@.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2020-07-02 19:23:54 BST; 4s ago
Docs: man:openvpn(8)
https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
https://community.openvpn.net/openvpn/wiki/HOWTO
Process: 2193 ExecStart=/usr/sbin/openvpn --suppress-timestamps --nobind --config Ireland.conf (code=exited, status=1/
Main PID: 2193 (code=exited, status=1/FAILURE)
Jul 02 19:23:54 osmc systemd[1]: openvpn-client@Ireland.service: Unit entered failed state.
Jul 02 19:23:54 osmc systemd[1]: openvpn-client@Ireland.service: Failed with result āexit-codeā.
lines 1-11/11 (END)
Hi,
Openvpn is failing to start via systemd. So either its not connected at all (How are you checking the public IP? to confirm you are connected to the VPN). Or something else is bringing up the connection is the Brian Hornsby Addon still enabled?
Thanks Tom.
Hmm, thatās weird. Iām checking the public ip via dns resolver addon from Kodi repo. I did a fresh install and didnāt reinstall the Brian Hornsby addon.
Hi,
Ok if you could please provide a new log, with entry removed from /etc/default/openvpn
We will take it from there.
Thanks Tom.
Hi,
ended up doing a fresh install - didnāt edit autostart in /etc/deafult/openvpn, and used PIAās ovpn file with ip address. Followed instructions to the letter. Still getting errors on boot (and exit) although vpn seems to be connecting each time I reboot. Thanks for your time Tom, if youāre able to respond Iāll pick this up tomorrow evening.
https://paste.osmc.tv/kohediyowa
osmc@osmc:~$ systemctl status openvpn-client@pia_Ireland
- openvpn-client@pia_Ireland.service - OpenVPN tunnel for pia_Ireland
Loaded: loaded (/etc/systemd/system/openvpn-client@.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2020-07-02 23:28:06 BST; 2s ago
Docs: man:openvpn(8)
https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
https://community.openvpn.net/openvpn/wiki/HOWTO
Process: 1956 ExecStart=/usr/sbin/openvpn --suppress-timestamps --nobind --config pia_Ireland.conf (code=exited, statu
Main PID: 1956 (code=exited, status=1/FAILURE)
Jul 02 23:28:06 osmc systemd[1]: openvpn-client@pia_Ireland.service: Unit entered failed state.
Jul 02 23:28:06 osmc systemd[1]: openvpn-client@pia_Ireland.service: Failed with result āexit-codeā.
lines 1-11/11 (END)
I think you might be running two instances of OpenVPN that are interfering with each other.
- With the introduction of version 2.4, OpenVPN split the systemd services into client and server. Probably for reasons of backward compatibility, Debian kept the old systemd service files (
openvpn.service
andopenvpn@.service
), as well as having the new service files (openvpn-client@.service
andopenvpn-server@.service
). That was/is a recipe for confusion. - If you run
systemctl list-unit-files | grep -i openvpn
you will see what OpenVPN services are enabled on your system. By default,openvpn.service
is enabled on OSMC ā and I suspect you havenāt disabled it. - For the old system, the configuration files were/are in /etc/openvpn. With the v2.4+ system, the client configuration files should move to
/etc/openvpn/client
, and server files to/etc/openvpn/server
. - I can see little sense in configuring
/etc/default/openvpn
to run a specific configuration file if the configuration file is also enabled as a systemd service, egopenvpn-client@pia_Ireland.service
.
Thanks for your input. Looks like youāre rightā¦
osmc@osmc:~$ systemctl list-unit-files | grep -i openvpn
openvpn-client@.service enabled
openvpn-server@.service disabled
openvpn.service enabled
openvpn@.service disabled
Iām not sure how to disable openvpn.service - would the following do it?
sudo systemctl disable openvpn.service
Based on your advice, should my pia_Ireland.conf file in /etc/openvpn be renamed to openvpn-client@pia_Ireland.service? Thanks.
Hi,
Sorry for delay, been long day at work.
Yes
No, the service remains openvpn-client@.service. Please now reboot and please upload some fresh logs.
Thanks Tom.
Ok, done. VPN now doesnāt connect.
osmc@osmc:~$ sudo systemctl disable openvpn.service
Synchronizing state of openvpn.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable openvpn
Hi,
Ok sorry I think I got some files confused here. Please try this:
sudo systemctl disable openvpn-client@Ireland
sudo rm /etc/systemd/system/openvpn-client@.service
sudo cp /lib/systemd/system/openvpn@.service /etc/systemd/system/openvpn@.service
edit /etc/systemd/system/openvpn@.service
so it looks like this:
[Unit]
Description=OpenVPN connection to %i
PartOf=openvpn.service
ReloadPropagatedFrom=openvpn.service
Before=systemd-user-sessions.service
Documentation=man:openvpn(8)
Documentation=https://community.openvpn.net/openvpn/wiki/Openvpn23ManPage
Documentation=https://community.openvpn.net/openvpn/wiki/HOWTO
[Service]
PrivateTmp=true
KillMode=mixed
Type=forking
ExecStart=/usr/sbin/openvpn --daemon ovpn-%i --status /run/openvpn/%i.status 10 --cd /etc/openvpn --config /etc/openvpn/%i.conf --writepid /run/openvpn/%i.pid
PIDFile=/run/openvpn/%i.pid
ExecReload=/bin/kill -HUP $MAINPID
WorkingDirectory=/etc/openvpn
ProtectSystem=yes
CapabilityBoundingSet=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_READ_SEARCH CAP_AUDIT_WRITE
LimitNPROC=10
DeviceAllow=/dev/null rw
DeviceAllow=/dev/net/tun rw
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
issue:
sudo systemctl daemon-reload
Lets make sure the vpn connection comes up, by issuing:
sudo systemctl start openvpn
if it does enable it with:
sudo systemctl enable openvpn
Sorry for the confusion, its been awhile since I setup openvpn on osmc.
Thanks Tom.
Cheers Tom.
VPN connects. Only get one error (rather than repeated errors) on boot nowā¦āFailed to start OpenVPN connection to loginā.
FYI, rather unhelpfully, I decided to change my .conf file to pia_Ireland, so changed your first instruction to sudo systemctl disable openvpn-client@pia_Ireland
Thatās because you seem to have called your password file login.conf. Call it login.txt (or anything that doesnāt end in .conf) and that error should disappear. (Donāt forget to change pia_Ireland.conf to reflect this change.)
The log shows that the job is starting before the network is up but OpenVPN, by design, keeps trying until thereās a network connection.
Thank you! Errors are now gone and vpn connects. Hereās the log if itās of interestā¦
https://paste.osmc.tv/mamoyigife
Iām assuming thatās me done if the vpn is guaranteed to restart on failure. Thanks so much for the support, really appreciate it.
Looks ok. To remove this warning:
WARNING: file 'login.txt' is group or others accessible
you should change the permissions on the file to 600
sudo chmod 600 login.txt
Done, thanks!