Wake on lan openwrt установка
I'm stuck on OpenWRT 18.06, and these info may soon be obsoleted by newer versions, and/or the more detailed ACL scheme in LuCI2.
Base Functionality in luci-app-wol
opkg install luci-app-wol brings us a WoL menu that is already very close to what we want. To find out how this is made, we change directory to the luci basedir, in this case /usr/lib/lua/luci
Let's have a look how luci-app-wol installs it's routes (/admin/services/wol)
The existing entries place themselves under a parent node that will enforce authentication (/admin, /mini, . )
If we add our page directly at the root, we get anonymous access to the WoL Interface:
When trying to submit a WoL request as an unauthenticated web user, we get an error related to a missing token. This is the Cross-Site Request Forgery migitation, and we can't get around it in the form("wol") , without doing a proper login.
Also the unauthenticated form leaks some internal network info that isn't necessary for the job, like ames and MAC addresses of other hosts. Nonetheless we shall explore some options to realize a password-based authentication for a lesser user:
Use of JsonRpc API
An authentification token can be acquired like this:
Unfortunately i couldn't figure out how to do something useful from there, and if i could call the existing WoL code.
Adding a route with different authentication to LuCI
To protect the page properly, we can so we better add proper authentication. Also that seems to be a condition to get a CSRF Token and be authorized to send POST requests. To inform LuCI that we desire authentication, we configure the accepted users on the page:
This will present us with a login form that accepts other usernames than root, unlike the normal login screen. The "htmlauth" authenticators role is to actually show us the login form, and give a web browser user the chance to login. Maybe it can be left out, since we're looking for a way to call this in a automated way.
Adding a user to the system
The htmlauth authenticator authenticates against system users. Creating a user is not so straightforward in OpenWRT, because it doesn't ship tools like adduser / useradd . Those are hidden in the package shadow-useradd :
Login through API
The documentation to the previous login method mentions that we can use a cookie store, instead of the explicit token authentication. Unfortunately the RPC API seems to be unrelated to what is going on with LuCI otherwise, so we can't use that.
So just using the Web API, we do it in 2 calls with curl , and a ./cookiejar to store the auth cookie:
The -F field of curl comes really handy to auto-format form-queries, but unfortunately, the token= field must be filled with a magic value scraped from the previous HTML response. Unfortunately, this behaviour is an important migitation against Cross Site Request Forgery.
Implementing an unauthenticated, limited Endpoint
Searching for the "wol" implementation behind the form, we find model/cbi/wol.lua.
The idea is to find the routine to call directly with the right parameters from the controller. The main logic happens in host.write() , which wraps the WoL operation in a write access to a virtual host variable, as represented by the CBI Form, which transports various parameters like the MAC address.
The function has some logic to select between available binaries, but i just went with etherwake , which i manually installed on the system. In the end, it's a simple system call through io.popen() . So we can get rid of the whole dependency on the luci-app-wol:
Wrapping things up in a new controller
The new controller/hq.lua now implements this independently, with space for other HQ APIs to be added in the future. I also created a different API endpoint group /hq , which can wake the guardian by POST to /hq/wake .
Can i now hack you and turn on your PC at night?
So, if you're in the friendly zone and have IPv6, you might be able to annoy me at night with:
This can be executed on my webserver, and start building a remote home control panel :D A satisfying result.
Please see /etc/crontabs/root to configure crond .
Example
Example entry to wake a host with the MAC address 00:06:29:4f:e4:b6 in the 192.168.0.0/24 subnet:
2. Auto WoL script
Saving the script.
Pro Tip: Don't copy the code above as it causes a bunch of errors due to a stray CRLF character at the end of each line. Instead just download a copy of the file here, and save yourself a day of troubleshooting!
Wake target
- Last modified: 2021/08/15 16:00
- by vgaetera
Self-registration in the wiki has been disabled.
If you want to contribute to the OpenWrt wiki, please post HERE in the forum or ask on IRC for access.
Except where otherwise noted, content on this wiki is licensed under the following license:
CC Attribution-Share Alike 4.0 International
Доброе время суток.
Подскажите, плиз, рабочее решение для Wake on Wan (WOL over Internet) - Archer C7 v2 и OpenWRT 18.06.2.
Перепробовал все рекомендации - и ip neigh на целевой компьютер и на броадкаст MAC. Пробросы делал, порты отрывал, с бубном танцевал.
Внутри сети пакеты бегают, извне - никак.
Какие порт ? WoL работает на L2.
этот скрипт можно дергать из xinetd при обращении к определенному порту.
А интернет у тебя посредством чего? На твой арчер запрос на wake вообще дойдёт? Хотя бы принципиально должен доходить?
А интернет у тебя посредством чего? На твой арчер запрос на wake вообще дойдёт? Хотя бы принципиально должен доходить?
Оптика через конвертер. На штатной прошивке все работает как часы.
Порты пробовал разные и всякие (7,9 и все другие)
этот скрипт можно дергать из xinetd при обращении к определенному порту.
А вот тут моих знаний уже не хватает. Буду очень благодарен за подробный мануал.
И еще - бужу 3 разных девайса - комп, нас и медиаплеер. Я как бы интуитивно понимаю что в опенврт все немного изменено в сторону обеспеченитя безопасности, но вот надо, блин.
WoL работает на уровне ethernet-кадров и про порты (tcp udp) он понятия не имеет.
«разбудить» можно только то устройство, которое находится в непосредственно подключенной сети
На openwrt (18.х) нужно поставить пакет etherwake
Попробовать можно просто запустив etherwake с нужными параметрами
Я это понимаю. Порт нужен был для отправки пакета из Internet с пробросом на широковещательный адрес. Штатаная прошивка tp-link это делать умеет. Openwrt нет. Etherwake работает только с локальной сетью. Мне нужно будить именно из WAN.
Порт нужен был для отправки пакета из Internet с пробросом на широковещательный адрес. Штатаная прошивка tp-link это делать умеет. Openwrt нет.
Да. Есть такая фича - что если редиректить на широковещательный адрес, то оно его тут же в input отправляет и больше никуда не шлет.
А как настроен WoL на машине, которую нужно будить ? Она на любой/броадкаст/магик пакет реагирует?
А как настроен WoL на машине, которую нужно будить ? Она на любой/броадкаст/магик пакет реагирует?
Вот тут не понятно. А какие есть варианты? Настроен стандартный WOL - будит через маджик пакет с маком сетевухи.
WoL можно настроть в разных вариантах. man ethtool на предмет wol.
magic-пакет поддерживают все, но его нельзя передать через портфорвардинг - он не udp/ip.
WoL можно настроть в разных вариантах. man ethtool на предмет wol.
Спасибо за инфо!
Теперь собственно возвращаемся к проблеме))) Какое есть реально рабочее решение для wake-on-lan через wan?
Sections
There is only one section type wol-target defined for the configuration. Multiple wake on lan targets may exist in the file.
1. Preparation
Install the required packages.
Example
Wake on LAN targets
A wol-target section defines the parameters the wol utility is started with. The init script will start one instance of wol for each section of this type.
Below is a listing of the parameters defined for this section.
Name | Type | Required | Default | Description |
---|---|---|---|---|
mac | MAC address | yes | (none) | Specifies the MAC address of the host to wake |
broadcast | IPv4 address or hostname | no | 255.255.255.255 | Specifies the target address magic packets are broadcasted to |
port | integer | no | 40000 | Specifies the UDP destination port for magic packets |
password | string | no | (none) | Send given SecureON password when waking the host |
enabled | boolean | no | 1 | Don't start wol for this section if set to 0 |
Troubleshooting
Enable debug output:
Go to Network → Firewall → Custom Rules and add this rule:
- Last modified: 2021/09/26 23:06
- by vgaetera
Self-registration in the wiki has been disabled.
If you want to contribute to the OpenWrt wiki, please post HERE in the forum or ask on IRC for access.
Except where otherwise noted, content on this wiki is licensed under the following license:
CC Attribution-Share Alike 4.0 International
The configuration file /etc/config/etherwake is provided by the etherwake package and defines hosts to wake when starting the /etc/init.d/etherwake init script. Install the package luci-app-wol to provide the web interface.
Script settings
Required to change | Variables | Default value | Description |
---|---|---|---|
optional | INTERVAL | 5 | repeat the script every N second |
not required | OLD | empty | should be empty |
optional | PORT | 80 | it the port who looks the script |
optional | NUMP | 3 | the retries, before the script gave up |
yes | TARGET | 192.168.1.1 | the wake up device |
yes | INTERFACE | br-lan | here you can type in a broadcast address or a interface, i like more interface |
yes | MAC | 00:00:00:00:00:00 | the target mac adress |
not required | WOL | /usr/bin/etherwake | the program and path for wol |
optional | LOGFILE | “/www/wol/index.html” | the log output folder, in this case for the url /wol/index.html |
optional | LOGPROG | “logread” | i will read the logs from LOGREAD, but you can also read from “dmesg” or something else |
Sections
There are two sections setup and target defined for the configuration. Multiple wake on lan targets may exist in the file.
Setup
Below is a listing of the parameters defined for this section.
Name | Type | Required | Default | Description |
---|---|---|---|---|
pathes | path | . | (none) | path to etherwake binary (typo is normal) |
sudo | boolean | no | off | Etherwake usually requires sudo |
interface | string | yes | (none) | On which interface to send the WOL packages |
broadcast | boolean | no | off | . |
Instructions
Target
Below is a listing of the parameters defined for this section.
Name | Type | Required | Default | Description |
---|---|---|---|---|
name | string | no | (none) | name of the target |
mac | MAC address | yes | (none) | Specifies the MAC address of the host to wake |
password | string | no | (none) | Send given SecureON password when waking the host |
wakeonboot | boolean | no | off | Don't send WOL packet when booting OpenWrt |
3. Autostart
First autostart, if the script is ok.
Go to System → Startup → Local Startup and type in:
Notes
If wol does not work, the etherwake package can be used instead. To wake a host on boot, and put the following command into /etc/rc.local :
This would wake the host with the MAC address 00:0f:3d:ce:ef:ee .
- Last modified: 2019/08/26 04:38
- by vgaetera
Self-registration in the wiki has been disabled.
If you want to contribute to the OpenWrt wiki, please post HERE in the forum or ask on IRC for access.
Except where otherwise noted, content on this wiki is licensed under the following license:
CC Attribution-Share Alike 4.0 International
At the very least, users should consider putting the LOGFILE on /tmp/ rather than on flash. OpenWrt also does not serve HTML pages in the same way as DD-WRT.
Читайте также:
- Serial to ethernet connector настройка
- В каких комплексах используется для регистрации поездной информации модуль памяти мпмэ 128
- Поддерживает ли материнская плата raid
- Не удается продолжить выполнение кода поскольку система не обнаружила xlive dll
- Компьютера фактический набор компонентов эвм которые составляют компьютер