Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Restart service on internet connectivity loss

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
Sharpey
Posts: 1
Joined: 2018-03-16 15:00

Restart service on internet connectivity loss

#1 Post by Sharpey »

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.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Restart service on internet connectivity loss

#2 Post by debiman »

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

Post Reply