LoginSignup
0
0

OpenWrt & OpenMPTCProuter x86/64 Windows11 Home Hyper-V から導入

Last updated at Posted at 2024-02-11

:warning:Japanese notation

はじめに

初心者対応構成

  • スクリプトでの自動設定
  • 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


前提条件

  • 対応OS: Windows11 Home
  • 対応仮想化用クライアントPC: x86

ファームウェアについて

デバイスについて

  • 仮想化ハードウェア仕様 (参考)
    Windows11 Home
    • CPU : Intel i5-1235U
    • RAM : 32 GB
    • SSD : 512 GB
    • BIOS : Virtualization Technology [Enabled]

OpenWrt x86/64

Hyper-VをWindows11 Homeにインストール

  • スクリプト: hyperv.bat
  • ディレクトリ: C:\openwrt

powershell > Win+x > a > はい
警告 > 強制的に貼り付け

powershell
Set-ExecutionPolicy Unrestricted
New-Item C:\openwrt -ItemType Directory -Force 
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/site-u2023/windows/main/hyperv.bat" -OutFile "C:\openwrt\hyperv.bat"
Start-Process C:\openwrt\hyperv.bat
Set-ExecutionPolicy Restricted

今すぐコンピューターを再起動しますか? (Y/N)
y

imgをvhdxに変換

powershell > Win+x > a > はい
警告 > 強制的に貼り付け

powershell
Move-Item C:\Users\*\Downloads\openwrt-*.img.gz c:\openwrt\ -force

  • UbuntuをWindows11にインストール
PowerShell
wsl --install

powershell
wsl.exe --list --online

powershell
Ubuntu

アカウント名 及び パスワード 入力

SSH
sudo apt-get update
sudo apt-get install gzip
sudo apt-get install qemu-img
cd /mnt/c/openwrt/
gunzip -k openwrt-*.img.gz
qemu-img resize -f raw openwrt-*.img 1G
qemu-img convert openwrt-*.img -O vhdx openwrt.vhdx
exit
exit

[sudo] password for openwrt: パスワード入力

パーテーション拡張

フリーパーティション管理ソフト
EaseUS Partition Master Free

  • 仮想ディスク
    • VHDxのマウント
      C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\openwrt.vhdx

ease.png

  • 未割当
    • 作成
    • サイズと位置を決定する: 最大
    • ドライブレター: 無し
    • ファイルシステム: EXT4
  • 一個のタスクを実行
  • アンマウント

仮想スイッチ作成

  • Hyper-Vマネージャー
    %windir%\System32\mmc.exe "%windir%\System32\virtmgmt.msc"
    • 仮想スイッチマネージャー
      • 新しい仮想ネットワークスイッチ
        • 内部
          • 仮想スイッチの作成
            • 仮想スイッチのプロパティ
              • 名前: 任意
              • メモ: LAN (eth0)
              • 内部ネットワーク
        • 外部
          • 仮想スイッチの作成
            • 仮想スイッチのプロパティ
              • 名前: 任意
              • メモ: WAN (eth1)
              • 外部ネットワーク
                • 管理オペレーティングシステムにこのネットワークアダプターの共有を許可

OpenWrtイメージマウント

  • hyper-V クイック作成
    C:\Program Files\Hyper-V\VMCreate.exe

  • ローカルインストール元

    • インストール元の変更
    • C:\openwrt\openwrt.vhdxをHyper-Vにマウント
      • セキュアブート無効
  • 接続の編集

    • ハードウェアの追加
      • ネットワークアダプター
        • 追加
          • 作成したWAN
  • 接続

  • 仮想マシンの起動が完了したらコンソールをクリック
     バナーが表示され、入力可能となる

固定IPアドレス設定

SSH
vi /etc/config/network

  • キー配列を置き換えて入力 (Hyper-Vは英文字キーボード)
     : = shift+;
     _ = -
     * = '

option ipaddr '192.168.1.1'をメインルーターと被らないように変更
例: 192.168.11.1

  • クライアントPCの設定
    • アダプターの設定の変更
      • ネットワーク接続
        任意内部

ip.png

  • o仮想マシンopenwrt
    • 設定
      • ハードウェアの追加
        • ネットワークアダプター
          • 追加
            • 仮想スイッチ: 作成したWANとLANスイッチを追加
  • 仮想マシンopenwrtを停止し、再度起動
  • option ipaddrに設定したアドレスでLuCiログイン
    ※WANが無い場合、eth1でwanインターフェースを作成

新規設定用 オールインワンスクリプト 初心者対応

スクリプトセレクター

config.png

動作確認

OK:

  • AdGuard HOME

NG:

  • luci-app-cpu-perf
  • luci-app-temp-status

OpenMPTCProuter x86/64

OpenMPTCProuter

検証中
OpenMPTCProuter.png

ダウンロード

ログイン

覚え書き:
初期設定自体は、OpenWrtとさほど変わらない
基本OpenWrtだが、WireGuard、VPN機能などが最初から組み込まれている
それらを使い込む人には、OpenMPTCProuterは向いていると思われ

高速回線の冗長化をしたく、x86/64のmini-pcを検討中
banana-pi3、raspberry-pi5のファームウェアは今のところ無い

あとがき

OpenWrt初心者の方は、まずHyper-Vで検証されてみるのも良いかと思う
インストールするクライアントPCの性能はたとえ低くても動く
なにより、全て無料

ConfigSoftwareをVMに対応

参考資料(感謝:relaxed:

Windows 11 Home に Hyper-V をインストールする

Hyper-VでOpenWRTのVMを作る

[Hyper-V + Ubuntu 22.04] IPアドレスを固定する方法

Windows11 Hyper-V OpenWrt 構成ガイド

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