What's new
  • 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!

How to make sure my VPN server restarts after a power outage?

BosseSwede

Regular Contributor
(I don't know if this is the right sub-forum, but I could not find anyone better. Please move me to the correct forum if it does not belong here.)

I am in the process of upgrading the hardware for my OpenVPN server on my LAN.
Right now it is an Ubuntu Server 24.04.1 LTS running on a Lenovo IdeaCenter mini-tower.
It is connected to an UPS, which also feeds the Fiber box, the ASUS Router, a Synology NAS and my LAN switches. So as long as the fiber service is OK I have a network that is up even when the incoming power to my house is seeing an outage.
But there is a problem here:
When the outage is longer than about an hour then the UPS battery runs low and it sends an alert command to the NAS and it relays it out on the LAN so other devices can take proper action too. That action is an orderly shutdown and my VPN server is one of the devices following that.
And here is the problem:
When power returns the Lenovo does not start again, someone has to push the power button on the front of the Lenovo....

Other devices on the LAN do start up properly, like the ASUS router and all of the RPi devices etc. Just not the VPN server, which maakes it an impossible situation since home access is through this.

Now when switching to newer hardware I am going to use an ASUS NUC 13 ANH device with Intel i7 CPU and I intend to move the VPN server disk partitions over to the NUC SSD disk so the exact same server will be running software-wise.

In doing so I checked the power settings on the ASUS website for resume after power loss and found that there is a wording passage I do not really fully understand:
With these settings, intentionally shutting down the system will result in the system staying powered down.
Does this mean that if the server receives the UPS message and shuts down because of that it will no longer restart after the power returns?
Id so how can I make it work except by disconnecting from the UPS?
I really want my network to be accessible via VPN 24/7 when power is available.
 
You have discovered the same issue I have with my NVR (Debian 12). When the UPS shuts down the server it stays down. I can send a Wake on LAN packet that restarts the server but sometimes it does not work.
One solution would be to use the Asus router for the OpenVPN server.
Another would be to not use a UPS on the OpenVPN server but set the BIOS power to start the device when the power resumes. Using a SSD minimizes the risk of data loss. I do this with an old Dell Optiplex running Windows 11 and Boinc.
 
In doing so I checked the power settings on the ASUS website for resume after power loss and found that there is a wording passage I do not really fully understand:

Does this mean that if the server receives the UPS message and shuts down because of that it will no longer restart after the power returns?
I don't know about that specific NUC, but that option (Power On) usually means that if there is a power failure - even if the device was cleanly shut down - it will power on once the power is restored. The message is just telling you that option is not applicable in normal day to day use.

However, I have found that the power has to be removed for sufficient time for any residual current in the PSU to have drained away for it to be detected as a power failure. So unplugging the mains for say 20 seconds will not cause it to power back on, whereas unplugging it for 5 minutes would. You'll have to test this for yourself though.
 
Last edited:
However, I have found that the power has to be removed for sufficient time for any residual current in the PSU to have drained away for it to be detected as a power failure. So unplugging the mains for say 20 seconds will not cause it to power back on, whereas unplugging it for 5 minutes would. You'll have to test this for yourself though.
Sigh....

So I have two options:
1) Keep the VPN server on the UPS
In this case the final shutdown will mean that when power resumes it will probably not start because it did an orderly shutdown to the off state...
So this needs a human to enter the home and push the power button...

Or find a way to remotely start it, which then requires me to have a secondary VPN server running on a RaspberryPi (which always starts on power application) so I can connect back home.
Then I could for instance use a Shelly plug on the power outlet feeding the server and do a remote OFF-ON power cycle, but if the NUC still thinks it was properly shut down then maybe it will not start anyway?

I have tried "wake on lan" earlier but I have never gotten it to work on the Lenovo hardware at least...
For the NUC ASUS says this.

Is this applicable for me and how can I make it run?
Is it possible to have another device on my network send the WakeOnLan to the VPN server when it starts up (maybe after failing to ping the server for instance)?

2) Power the VPN server directly from mains
This will then use the BIOS setting "start on resume power" and get the system up.
But then it will not shut down cleanly when the power is removed of course...
And even short power outages means a disruption of the server tasks....

Geography
I have two homes:
- my main home where the VPN server is located (it does lots of other things too, not just VPN)
- my summer home 100 km away.
Both have fiber Internet and the two LAN:s are interconnected via OpenVP.
The ASUS router at the summer home connects to my home LAN via the VPN server I am just discussing here.
Then the devices on both locations have access to each other.

History
In August 2024 there was a power outage at home that lasted for a couple of hours when I was at the summer home and the VPN server did not come on line afterwards.
So I had to phone a neighbor to enter my main home and locate the power button and push it....
This is what I am trying to avoid when I now am replacing the server hardware...

VPN is supposed to always run when there is power available....
 
You say that the router comes back online after the power outage so why not run a "backup" VPN server on that (which I think you did previously). You could then connect to your LAN via that and issue a WoL, either from the router's webUI or from a command line.
 
I have an ASUS RT-AX86U PRO Router at home, but I am not aware of any WebUI on that router which would enable me sending a WoL command. Where can I find that?
Concerning a secondary VPN channel I have not used the home router for that, instead the home router port forwards VPN traffic to my Ubuntu Server which is the VPN server too. And that is where the routing and such of the incoming traffic happens. Except when it is not running....
The ASUS built-in VPN is too limited to be used for what I do...

Or could I have an on-boot cron job on a RaspberryPi powered from the main power line which would do the following when it starts up (RPi devices always start on applying power):
1) Wait a few minutes to let things settle
2) Check if the server can be reached (test a mount from it or simply check pinging or similar)
3) If there is no response to the check then send the WOL packet (how would that WOL be done from a bash script?)
4) Again wait a while for it to start up
5) Make another connectivity test, if that fails post a message to me about that fact.

This would automate the restart and not require me to connect and do stuff manually on a power resume.
 

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!
Back
Top