⬆️ ⬇️

Remotely turn on the computer for free, without SMS and without clouds, using Mikrotik

... and also without port forwarding, SSH / telnet and installation of third-party applications. From any computer connected to the Internet and even from the phone!



Periodically, I sometimes need to turn on my home computer when I'm not at home. Usually I didn’t bother and called or sent a message with such a request to my wife, who is sitting at home on maternity leave. Very handy remote control with voice interface. However, this method has a number of drawbacks - went for a walk, puts the child, or else is busy. I wanted a simple solution from what is at hand.



First of all, we enable Wake on LAN in the BIOS of the motherboard, for everyone it is done differently, for many it is turned on by default. On one of my PCs, even this option is not present - always on.



Next, go to WinBox and connect to your router (if you want, you can through SSH or via HTTP (S), I do everything in WinBox). If you open the text console of RouterOS and fumble around in the / tool section (or in wiki manuals), you can find the wol utility with the following syntax:

')

/tool wol mac=XX:XX:XX:XX:XX:XX interface=ifname 


Where ifname is the name of the interface from which the magic packet will be sent, XX: XX: XX: XX: XX: XX is the mac address of your computer.



It seems everything is simple, but Winbox from the phone doesn’t really start up and you’re trying to enter the mac address from memory. You can run SSH and send one single command to it, but this is also long and tedious. Use the firewall!



Directly from the filter rules, it is impossible to start the execution of commands, of all the actions we are most suited to adding the address to the address-list, since It allows you to create a new object in the operating system of the router, accessible from scripts.



Add a new rule for the input chain and position it among the other permitting rules of this chain. We specify the protocol tcp and dst-port - any of the upper ports.





Action select add src (you can and dst) to address list, specify the name of the sheet.





To track the occurrence of records, use the scheduler. We go System -> Sheduler, we create the task of the scheduler, we set a name. We specify Start time: startup, and the desired interval, for example, every 15 seconds.



In the on event field we will write a simple script:



 :local WAKEPC [/ip firewall address-list find where list="WAKEPC"] :if ($WAKEPC!="") do={ /tool wol mac=00:11:22:33:44:55 interface=bridge_lan /ip firewall address-list remove [find where list="WAKEPC"] } 


Do not forget to specify the correct mac, interface name and address list. This script, when detecting elements in the address list, executes a command that sends magic packets to your computer, and then deletes the entry from the address list.



To turn on your computer, just open the browser and go to your microtic's IP, specifying the port that we set in the firewall rule: http://your.router.net:port , after which the firewall creates an entry in the address list, the task scheduler will detect this entry, executes the wol utility, and deletes the entry from the address list. Simply steamy turnips, we can add the address to your favorites so that you do not enter it every time.



Just do not forget about security, this method is not protected by anything and anyone can turn on your computer, knowing or picking up the correct port. For protection, you can use VPN, port knocking, whitelist, or the Elusive Joe method - you decide. If you need to include several computers separately in this way, create an appropriate number of rules on different ports, each of which will throw addresses into its address list, also in the task scheduler we also propagate the script via Ctrl + C, Ctrl + V, or create separate tasks for everyone - as you wish.

Source: https://habr.com/ru/post/313794/



All Articles