Japanese notation
はじめに
記事について
x86/64 OpenWrt初期設定・運用ガイドです
インストールから各種設定、チューニングなどをまとめています
初心者対応構成
- スクリプトでの自動設定
-
UCI (ttyd)、Webコンソール (LuCi)、ファイラー (SFTP)にて比較作業がおススメ
OpenWrt
デバイス
パーツ
SDカードリーダー
ファームウェア
ダウンロード
公式ファームウェア
デバイス用のOpenWrtカスタムファームウェアをダウンロード
※ビルダーは非公式
USBメモリー利用の場合:
- イメージのダウンロード >> COMBINED-EFI (EXT4) をダウンロード
USBメモリ
初期化
- コマンドプロンプト
※管理者として実行
diskpart
list disk
select disk
clean
create partition primary
select partition 1
format fs=fat32 quick
assign
exit
USB拡張
二回自動でリブート
必要パッケージ:parted losetup resize2fs blkid
PKGS="parted losetup resize2fs blkid"
command -v opkg && opkg update && opkg install $PKGS
command -v apk && apk update && apk add $PKGS
wget -U "" -O expand-root.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/expand_root?codeblock=0"
. ./expand-root.sh
sh /etc/uci-defaults/70-rootpt-resize
再実行する場合
rm /etc/rootpt-resize
rm /etc/rootfs-resize
sed -i '/70-rootpt-resize/d;/80-rootfs-resize/d' /etc/sysupgrade.conf
フラッシュ&インストールシステム
デバイスアクセス
SSH(UCI)
コンソールでアクセス
- パワーシェル起動:キー入力:
Win+x>a>はい - コンソールログイン
if(!$ip){$ip="192.168.1.1"}; ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=NUL -o GlobalKnownHostsFile=NUL -o HostKeyAlgorithms=+ssh-rsa -tt root@$ip
LuCi (GUI)
初期設定
パスワード
初期値から変更
passwd
Changing password for root
New password:
任意のパスワード
Retype password:
再入力
passwd: password for root changed by root
exit
ホストネーム
ホストネーム(openwrt)を変更
#!/bin/sh
HOSTNAME="openwrt" # デバイス名
uci set system.@system[0].hostname=${HOSTNAME}
uci commit system
/etc/init.d/system reload
NTP
NTPサーバーを変更
#!/bin/sh
NTP="jp.pool.ntp.org"
uci delete system.ntp.server
uci -q batch <<EOF
add_list system.ntp.server="0.${NTP}"
add_list system.ntp.server="1.${NTP}"
add_list system.ntp.server="2.${NTP}"
add_list system.ntp.server="3.${NTP}"
set system.ntp.enable_server='1'
set system.ntp.use_dhcp='0'
set system.ntp.interface='lan'
commit system
EOF
/etc/init.d/sysntpd restart
SSH
WANからのアクセスを遮断
uci set dropbear.@dropbear[0].Interface='lan'
uci commit dropbear
LED
動かない
パッケージ
Wi-Fi
インストール
必要パッケージ:
kmod-usb-net-rtl8152 kmod-rtw88-8821cu kmod-cfg80211 kmod-mac80211 wireless-tools iw hostapd wpa-supplicant
#! /bin/sh
PKGS="kmod-usb-net-rtl8152 kmod-rtw88-8821cu kmod-cfg80211 kmod-mac80211 wireless-tools iw hostapd wpa-supplicant"
UPDATE="${UPDATE:-$(command -v opkg && opkg update >&2; command -v apk && apk update >&2; echo 1)}"
command -v opkg && opkg install $PKGS
command -v apk && apk add $PKGS
母国語サポート
LuCiの言語パッケージをインストール
- 対応言語検索
#! /bin/sh
PATTERN="luci-i18n-base*"
UPDATE="${UPDATE:-$(command -v opkg && opkg update >&2; command -v apk && apk update >&2; echo 1)}"
command -v opkg && opkg list $PATTERN
command -v apk && apk search $PATTERN
- 設定
#! /bin/sh
I18N="ja"
PKGS="luci-i18n-base-${I18N} luci-i18n-opkg-${I18N} luci-i18n-firewall-${I18N} luci-i18n-package-manager-${I18N} luci-i18n-attendedsysupgrade-${I18N}"
UPDATE="${UPDATE:-$(command -v opkg && opkg update >&2; command -v apk && apk update >&2; echo 1)}"
command -v opkg && opkg install $PKGS
command -v apk && apk add $PKGS
UCI(TTYD)
ブラウザーでUCIにアクセス
#! /bin/sh
I18N="ja"
PKGS="luci-i18n-ttyd-${I18N}"
UPDATE="${UPDATE:-$(command -v opkg && opkg update >&2; command -v apk && apk update >&2; echo 1)}"
command -v opkg && opkg install $PKGS
command -v apk && apk add $PKGS
uci set ttyd.@ttyd[0].ipv6='1'
uci set ttyd.@ttyd[0].command='/bin/login -f root' #自動ログイン
uci commit ttyd
/etc/init.d/rpcd restart
ファイラー
ブラウザでファイルにアクセス
mkdir -p /tmp/aios && wget -q -O /tmp/aios/install-filebrowser.sh https://raw.githubusercontent.com/site-u2023/aios/main/install-filebrowser.sh && sh /tmp/aios/install-filebrowser.sh
-
管理画面
192.168.1.1:8080 -
設定
# ポート変更
uci set filebrowser.config.port=9090
# ルートディレクトリ変更
uci set filebrowser.config.root=/mnt/storage
# ユーザーネーム及びパスワード変更
uci set filebrowser.config.username='root'
uci set filebrowser.config.password='password'
uci commit filebrowser
# 設定確認
uci show filebrowser
# サービス再起動
service filebrowser restart
# 既存DBをリセットしてUCI値で上書きしたいとき
rm /etc/filebrowser/filebrowser.db
service filebrowser restart
- 使用方法
filebrowser_main.sh: 自動判定 (インストールまたはリムーブ)
filebrowser_main.sh install: インストール
filebrowser_main.sh remove: リムーブ
filebrowser_main.sh status: 状態確認
WinSCPでファイルにアクセス
#! /bin/sh
PKGS="openssh-sftp-server"
UPDATE="${UPDATE:-$(command -v opkg && opkg update >&2; command -v apk && apk update >&2; echo 1)}"
command -v opkg && opkg install $PKGS
command -v apk && apk add $PKGS
クライアント設定(Windows)
- 手動インストール
- ダウンロード:WinSCP
- 自動インストール
- キー入力:
Win+x>a>はい - 最新版ソフトウェアのインストール
- キー入力:
$psVersion = $PSVersionTable.PSVersion.Major
$LINKS = Invoke-WebRequest "https://winscp.net/eng/download.php"
$LINKS_VERSION = $LINKS.Links | Where-Object {$_.href -like "*WinSCP-*-Setup.exe*"} | Select-Object -ExpandProperty href
$VERSION = ($LINKS_VERSION -split '/')[-2] -replace "WinSCP-([0-9]+\.[0-9]+\.[0-9]+).*", '$1'
Write-Host "Version to install: $VERSION"
$downloadUrl = "https://jaist.dl.sourceforge.net/project/winscp/WinSCP/$VERSION/WinSCP-$VERSION-Setup.exe?viasf=1"
Write-Host "Downloading from: $downloadUrl"
$ONAMAE = (whoami).Split('\')[1]
$destinationPath = "C:\Users\$ONAMAE\Downloads\WinSCP-$VERSION-Setup.exe"
Invoke-WebRequest -Uri $downloadUrl -OutFile $destinationPath
Write-Host "Installing WinSCP..."
Start-Process -FilePath $destinationPath -ArgumentList "/VERYSILENT /NORESTART" -Wait
Invoke-Expression "C:\Users\$ONAMAE\AppData\Local\Programs\WinSCP\WinSCP.exe"
-
警告>強制的に貼り付け -
WinSCP設定
- セッション
- ホスト名:
192.168.1.1 - ユーザー名:
root - パスワード:
設定したパスワード -
ログインをクリック
- ホスト名:
- セッション
CPU負荷分散
インストール
#! /bin/sh
PKGS="irqbalance"
UPDATE="${UPDATE:-$(command -v opkg && opkg update >&2; command -v apk && apk update >&2; echo 1)}"
command -v opkg && opkg install $PKGS
command -v apk && apk add $PKGS
uci set irqbalance.irqbalance=irqbalance
uci set irqbalance.irqbalance.enabled='1'
uci commit irqbalance
/etc/init.d/irqbalance start
ネットワーク統計インターフェイス
インストール
#! /bin/sh
I18N="ja"
PKGS="luci-i18n-statistics-${I18N}"
UPDATE="${UPDATE:-$(command -v opkg && opkg update >&2; command -v apk && apk update >&2; echo 1)}"
command -v opkg && opkg install $PKGS
command -v apk && apk add $PKGS
/etc/init.d/collectd enable
/etc/init.d/rpcd restart
- プラグイン検索
#! /bin/sh
PATTERN="collectd-mod\*"
UPDATE="${UPDATE:-$(command -v opkg && opkg update >&2; command -v apk && apk update >&2; echo 1)}"
command -v opkg && opkg list $PATTERN
command -v apk && apk search $PATTERN
追加テーマ
インストール
#! /bin/sh
PKGS="luci-theme-openwrt luci-theme-material"
UPDATE="${UPDATE:-$(command -v opkg && opkg update >&2; command -v apk && apk update >&2; echo 1)}"
command -v opkg && opkg install $PKGS
command -v apk && apk add $PKGS
AdGuard Home
インストール
- インストール及びリムーブ
mkdir -p /tmp && wget --no-check-certificate -O /tmp/adguardhome.sh "https://site-u.pages.dev/www/custom-scripts/adguardhome.sh" && chmod +x /tmp/adguardhome.sh && sh /tmp/adguardhome.sh
- 管理画面ログイン
http://192.168.1.1:8000/
既知の問題
トラブル
自称[さくらインターネット](https://www.sakura.ad.jp/)の中の人の記事の検証
OpenWRT mapcalc Issues on 64-bit Architecture / OpenWRTの64bitアーキテクチャで、mapcalcが適切に動かない話 [MAP-E]の検証
OpenWRTでのMAP-E運用は、残念ながら現時点では64bit x86環境で実用的ではありません。開発コミュニティでは「修正予定なし」とされており、今後の改善も期待薄です。と言ってる件を検証した
当該記事の考察
症状: MAP-Eインタフェース経由で送信はできるが、受信(RX)が完全にゼロと報告されているが、network.wan6mape.psid='0' などと存在しない設定を入れているためではないだろうか
PSIDはmap.shで自動計算するので、バグ以前に関係ないと思われる
結論
root@T6P1:~# uname -m && cat /etc/openwrt_release | grep -E "DISTRIB_RELEASE|DISTRIB_REVISION" && ip -6 route show && ping -c3 8.8.8.8
x86_64
DISTRIB_RELEASE='25.12.0-rc4'
DISTRIB_REVISION='r32534-12374d88b9'
default from 2400:xxxx:xxxx:xxxx::/64 via fe80::xxxx:xxxx:xxxx:xxxx dev eth1 proto static metric 512 pref medium
2400:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx dev eth1 proto kernel metric 256 pref medium
2400:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx dev br-lan proto static metric 1024 pref medium
2400:xxxx:xxxx:xxxx::/64 dev eth1 proto static metric 256 pref medium
2400:xxxx:xxxx:xxxx::/64 dev br-lan proto static metric 1024 pref medium
unreachable 2400:xxxx:xxxx:xxxx::/64 dev lo proto static metric 2147483647 pref medium
fdxx:xxxx:xxxx:0:xxxx:xxxx:xxxx:xxxx dev br-lan proto static metric 1024 pref medium
fdxx:xxxx:xxxx::/64 dev br-lan proto static metric 1024 pref medium
unreachable fdxx:xxxx:xxxx::/48 dev lo proto static metric 2147483647 pref medium
fe80::/64 dev br-lan proto kernel metric 256 pref medium
fe80::/64 dev eth1 proto kernel metric 256 pref medium
fe80::/64 dev map-mape proto kernel metric 256 pref medium
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=120 time=30.384 ms
64 bytes from 8.8.8.8: seq=1 ttl=120 time=79.155 ms
64 bytes from 8.8.8.8: seq=2 ttl=120 time=88.587 ms
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 30.384/66.042/88.587 ms
root@T6P1:~#
map-e接続は正常
参考
root@T6P1:~# uci set network.wan6mape.psid='0'
uci: Invalid argument
初期化
ファクトリーリセット(初期化)
リセット
# 要注意
firstboot && reboot now
This will erase all settings and remove any installed packages. Are you sure? [N/y]
y
あとがき
- 2026年2月20日
OSバージョンなどの検証用にラズパイZERO2WをUSBガジェット接続出来る仕様で用意したが、いかんせんUSBガジェットがよくトラブルので、デバイスにRJ45が埋め込まれているT6P1を用意した
用途によってはBPI-R4などより速いかもしれない


