OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Archive »
  • 17.7 Legacy Series »
  • Cron Script for ping and restart of the opvn client every minute?
« previous next »
  • Print
Pages: [1]

Author Topic: Cron Script for ping and restart of the opvn client every minute?  (Read 4011 times)

ckishappy

  • Newbie
  • *
  • Posts: 34
  • Karma: 2
    • View Profile
Cron Script for ping and restart of the opvn client every minute?
« on: September 11, 2017, 01:35:32 pm »
I just loaded opnsense on my old hp microserver Gen8 and opnsense is exactly what I was looking for. I get around 100Mbs with the OVPN client so will then buy some 1U decisio appliance soon to get some more speed with ovpn. I like the approach of the company.

Two questions:

1) I would like to run a cron script to ping an address every minute or so. If 6 pings fail, I would like to restart the ovpn client to ensure the client really reconnects to the vpn server. Please advise how I can do this?

2) I would like to run a cron script to see if the WAN is still up. If the WAN is down for more than a minute, I would like to restart the opensense server. Please advise how I can do this?

Logged

phoenix

  • Hero Member
  • *****
  • Posts: 506
  • Karma: 55
    • View Profile
Re: Cron Script for ping and restart of the opvn client every minute?
« Reply #1 on: September 11, 2017, 02:05:23 pm »
There's a couple of posts of mine (and a script) that should give you some ideas in this thread: https://forum.opnsense.org/index.php?topic=5511.0;topicseen
Logged
Regards


Bill

ChrisH

  • Jr. Member
  • **
  • Posts: 67
  • Karma: 6
    • View Profile
Re: Cron Script for ping and restart of the opvn client every minute?
« Reply #2 on: September 11, 2017, 02:56:36 pm »
OpenVPN already has --ping-restart, is that not enough?

And rebooting the whole box every minute because the WAN link is down seems a bit drastic to me...
Logged

ckishappy

  • Newbie
  • *
  • Posts: 34
  • Karma: 2
    • View Profile
Re: Cron Script for ping and restart of the opvn client every minute?
« Reply #3 on: September 11, 2017, 04:13:00 pm »
Thanks you are right that the server reboot is a bit dramatic. I use indeed keepalive. The wan connection is quite stable but still restarting the ovpn connection typically avoids any manual intervention throughout the day, week, month, year.

Is there a script just for the ovpnclient restart? in the log this is called rc.newwanip starting ovpnc1.. Pls advise?
Logged

ckishappy

  • Newbie
  • *
  • Posts: 34
  • Karma: 2
    • View Profile
Re: Cron Script for ping and restart of the opvn client every minute?
« Reply #4 on: September 11, 2017, 04:14:31 pm »
Quote from: phoenix on September 11, 2017, 02:05:23 pm
There's a couple of posts of mine (and a script) that should give you some ideas in this thread: https://forum.opnsense.org/index.php?topic=5511.0;topicseen

Thanks for the sample script, do you know the command for restarting the WAN with a fixed IP?

Logged

phoenix

  • Hero Member
  • *****
  • Posts: 506
  • Karma: 55
    • View Profile
Re: Cron Script for ping and restart of the opvn client every minute?
« Reply #5 on: September 11, 2017, 04:44:33 pm »
Quote from: ckishappy on September 11, 2017, 04:14:31 pm
Thanks for the sample script, do you know the command for restarting the WAN with a fixed IP?
If your ISP provides you with a fixed IP then the restarting the WAN interface will pick it up, I have a fixed IP on my internet connection. :) If you mean it's a specific IP that you have set then ifconfig can be used to set a specific IP in this format:

Code: [Select]
ifconfig vmx0  10.0.0.10/24
Logged
Regards


Bill

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • Archive »
  • 17.7 Legacy Series »
  • Cron Script for ping and restart of the opvn client every minute?
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2023 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2