What's new

Cron job to turn off/on Vpn client service state?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Eet_46

Occasional Visitor
Hi everyone!

I'm having a slight issue with my VPN connection failing to connect, due this error: "Jan 1 02:43:58 openvpn[1386]: RESOLVE: Cannot resolve host address: sweden.privateinternetaccess.com: Name or service not known".
I use the feature to block all connection if the VPN fails, the router is setup to reboot every day at 4am, which is where the error comes up all the time..

So almost every day i start with no connection, it's easily fixed though by turning the service state of the client off and then on again. But i'd rather not have to go into the router setup each day to fix my connection.

I was wondering if it's possible to add a turn off/turn on cron job for the service state? Or maybe make script somehow, to check for this error and fix it, maybe?

Or perhaps there are another, better way to handle this?

Thanks.
 
I'm not sure why you are getting the error, perhaps the client is trying to connect before a WAN link is established? In that case this would just a band aid solution; The vpn client can be stopped with "service stop_vpnclient1" and started with "service start_vpnclient1", assuming of course that you are using client 1

The commands could be run via cron.

Alternatively, uncheck the start with WAN on the VPN client gui and put the above start command in a wan-start script after a sleep to ensure the internet connection is established.
 
Great! This works. Can't really figure out why i get the error either, looking at the system log it isn't clear what's happening. As you say, it just seems the WAN isn't completely ready yet, when the VPN client tries to connect
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top