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] wake up a Pc when you connect to OpenVPN Server on your Router

enrysan0

Occasional Visitor
what we want to obtain is:
IF a client connect to openVPN server on the router (AC68U)
THEN the router automatically send a WOL (wake on lan) command to a PC

In this guide I assume you have the JFFS partition already active and writable and that you already configured WOL to work inside your LAN.

So SSH to your router and give this command:
Code:
vi /jffs/scripts/wakeonvpn.sh

now hit i and paste this (CHANGE THE DATA FOR YOUR CONFIGURATION and delete " "):

Code:
#!/bin/sh

logger -t "($(basename $0))" $$ "Wake On VPN"

/usr/bin/ether-wake -i br0 "MAC ADDRESS OF THE PC YOU WANT TO WAKE UP"

exit 0

press "ESC" then ":wq"

change permission of the file just created:

Code:
chmod 777 /jffs/scripts/wakeonvpn.sh

Next thing we have to add a perm arp entry linked to the pc to wake up

Code:
vi /jffs/scripts/services-start

now hit i and paste this (CHANGE THE DATA FOR YOUR CONFIGURATION and delete " "):

Code:
#!/bin/sh

arp -i br0 -s "IP ADDRESS OF THE PC YOU WANT TO WAKE UP" "MAC ADDRESS OF THE PC YOU WANT TO WAKE UP"

press "ESC" then ":wq"

change permission of the file just created:

Code:
chmod 777 /jffs/scripts/services-start

Now go to your router web interface. Go to "Advanced Settings/VPN/VPN Server" and disable OpenVPN Server.

Go to "Advanced Settings/VPN/VPN Details" and in "Custom configuration" add these two lines:
Code:
script-security 2
client-connect  /jffs/scripts/wakeonvpn.sh

Now enable the OpenVPN Server and reboot the router.


Time to test: put the pc you want to wakeup in standby and use another device to connect to OpenVPN Server. If all is working the pc have to wake up from standby (or from power off if your Pc support it)
 
...nice.

Hmmm...you know that you can actually make dnsmasq to run a script, when it hands out an IP to a client, do you?
I wonder if dnsmasq is handling the IPs from OpenVPN Sever/tun/tap interface.
 
...nice.

Hmmm...you know that you can actually make dnsmasq to run a script, when it hands out an IP to a client, do you?
I wonder if dnsmasq is handling the IPs from OpenVPN Sever/tun/tap interface.

Only if you use a TAP, where the DHCP server handles it. For TUN (and most OpenVPN setups), the OpenVPN server allocates IPs from the small pool you specify.
 
...so, isn't there a possible way to make dnsmasq responsible for the tun interface, instead of OpenVPN-Server?
 
Only if you use a TAP, where the DHCP server handles it. For TUN (and most OpenVPN setups), the OpenVPN server allocates IPs from the small pool you specify.

...so, isn't there a possible way to make dnsmasq responsible for the tun interface, instead of OpenVPN-Server?

Hmm...a quick scan of the capabilities in openvpn-server.conf makes me think, that this is not possible.
The only was I could think of is making dnsmasq listen on the openvpn-server IP, once the interface is up....but this is probably not a good idea.

..maybe triggering the script with the "learn-address" directive in the openvpn-server.conf is an option?
Is it possible to "open" this to user-scripts in Merlin-FW, like with "openvpn-event"?
 
...so, isn't there a possible way to make dnsmasq responsible for the tun interface, instead of OpenVPN-Server?

In a TUN, broadcasts aren't sent to your router, so it can't handle DHCP requests - it never sees them.
 

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