Restart service on internet connectivity loss

New to Debian (Or Linux in general)? Ask your questions here!

Restart service on internet connectivity loss

Postby Sharpey » 2018-03-17 20:46

Hi, this is my first post so please go easy. By profession I'm an Azure engineer, but Linux really isn't my strong point - just started off.

My question is as per subject, but the reason is that I've turned my raspberry pi into a VPN router. This had gone well as a first project. Connects on startup, routes all Ethernet traffic though the VPN interface nicely. Only issue is, if I get a dropout on my main internet router, openvpn by default, doesn't reconnect. Is there a way to enforce this, or do I need to have a background service running that will say ping 8.8.8.8 and on packet loss, restart the openvpn service?

Thanks in advance for any help given.
Sharpey
 
Posts: 1
Joined: 2018-03-16 15:00

Re: Restart service on internet connectivity loss

Postby debiman » 2018-03-18 07:06

we are talking about systemd services?
first of all, you should look at the existing service:
Code: Select all
journalctl -b -u openvpn
systemctl status openvpn
nano /path/to/openvpn.service
etc.
(assuming it is called openvpn)

systemd uses targets, one of them is called network.target.
i'm not sure if it will enter a failed state that you can query with another systemd setting...

suggested reading:
https://wiki.debian.org/systemd
https://wiki.archlinux.org/index.php/Systemd
User avatar
debiman
 
Posts: 2127
Joined: 2013-03-12 07:18


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable