Eth0 not connected- vpn setup issue?

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.

  1. 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 and openvpn@.service), as well as having the new service files (openvpn-client@.service and openvpn-server@.service). That was/is a recipe for confusion.
  2. If you run systemctl list-unit-files | grep -i openvpnyou 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.
  3. 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.
  4. 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, eg openvpn-client@pia_Ireland.service.
1 Like

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

https://paste.osmc.tv/ifeyufefek

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

https://paste.osmc.tv/ovozusulav

1 Like

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.

1 Like

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.

1 Like

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!