0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OpenWrt Wake on LAN ホスト自動起動

Last updated at Posted at 2023-06-23

はじめに

初心者対応構成

  • スクリプトでの自動設定
  • UCIとLuCi及びWinSCPにて比較しながら作業がおススメ

PowerShellSSHアクセス

ssh root@192.168.1.1
ssh root@192.168.1.1のショートカット作成(デスクトップ)
powershell
$DESKTOP = ([Environment]::GetFolderPath("Desktop") + "\192.168.1.1.lnk")
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$DESKTOP")
$Shortcut.TargetPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$Shortcut.Arguments = '-windowstyle hidden -ExecutionPolicy RemoteSigned "Start-Process ssh root@192.168.1.1"'
$Shortcut.IconLocation = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe,0"
$Shortcut.WorkingDirectory = "."
$Shortcut.Save()

  • 強制的に貼り付け
  • yes

SSHログイン出来ない場合:exclamation:

known_hostsクリア

  • C:\Users\yourusername\.ssh\known_hosts ※Windows隠しファイル
powershell
Clear-Content .ssh\known_hosts -Force


OpenSSHのインストール
※Windows 10 Fall Creators Update(1709)以降標準搭載

  • 機能の確認
powershell
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

  • 機能のインストール
powershell
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0


Wake on LAN

設定

便利!

# package
opkg update
opkg install luci-i18n-wol-ja
/etc/init.d/rpcd restart

opkg update
opkg install etherwake-nfqueue

ホスト自動起動

再起動に失敗する
※再起動しないから検証放棄・・・

初期設定

TARGET_SET=192.168.1.10    # 該当デバイスのIPアドレス
MAC_SET=00:00:00:00:00:00  # 該当デバイスのマックアドレス

設定

opkg update
opkg install etherwake
# auto_wol_script
wget --no-check-certificate -O /bin/autowol.sh https://raw.githubusercontent.com/site-u2023/auto_wol_script/main/autowol.sh
chmod +x /bin/autowol.sh
sed -i -e "s/192.168.1.1/${TARGET_SET}/g" /bin/autowol.sh
sed -i -e "s/00:00:00:00:00:00/${MAC_SET}/g" /bin/autowol.sh
# start up
cp /etc/rc.local /etc/rc.local.bak
sed -i -e "s/exit 0//g" /etc/rc.local
echo "/bin/autowol.sh" > /etc/rc.local 
echo "exit 0" >> /etc/rc.local 

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?