Japanese notation
はじめに
初心者対応構成
- スクリプトでの自動設定
-
UCI (ttyd)、Webコンソール (LuCi)、ファイラー (SFTP)にて比較作業がおススメ
デバイス
OpenWrt
インストール
ファームウェア
イメージのダウンロード > FACTORY をダウンロード
インストールされたパッケージ、初回起動時のスクリプトのカスタマイズ
インストールされたパッケージ
リリースビルド
base-files ca-bundle dnsmasq dropbear firewall4 fitblk fstools kmod-gpio-button-hotplug kmod-leds-gpio kmod-mt7622-firmware kmod-nft-offload libc libgcc libustream-mbedtls logd mtd netifd nftables odhcp6c odhcpd-ipv6only opkg ppp ppp-mod-pppoe procd-ujail uboot-envtools uci uclient-fetch urandom-seed urngd wpad-basic-mbedtls kmod-mt7915-firmware luci luci-i18n-base-ja ttyd luci-app-ttyd luci-i18n-ttyd-ja sftp-server
"snapshot" ビルド
apk-mbedtls base-files ca-bundle dnsmasq dropbear firewall4 fitblk fstools kmod-gpio-button-hotplug kmod-leds-gpio kmod-mt7622-firmware kmod-nft-offload libc libgcc libustream-mbedtls logd mtd netifd nftables odhcp6c odhcpd-ipv6only ppp ppp-mod-pppoe procd-ujail uboot-envtools uci uclient-fetch urandom-seed urngd wpad-basic-mbedtls kmod-mt7915-firmware luci luci-i18n-base-ja ttyd luci-app-ttyd luci-i18n-ttyd-ja sftp-server
初回起動時に実行されるスクリプト (uci-defaults)
#!/bin/sh
# Based on script from https://pastebin.com/XDja96GT, with appreciation.
MODEL=$(ubus call system board | jsonfilter -e '@.model')
[ "$MODEL" = "Buffalo WSR-3200AX4S" ] || {
echo "99-mount-vacant-space: Unsupported model: $MODEL" > /dev/kmsg
exit 0
}
cat <<'EOF' > /etc/init.d/mount_vacant_space
#!/bin/sh /etc/rc.common
START=10
boot() {
MTD_DEV="/dev/mtd11"
UBI_VOLUME="dpi"
MOUNT_POINT="/mnt/vacant_space"
insmod mtd-rw i_want_a_brick=1
mtd unlock "$MTD_DEV"
ubiattach -m 11
ubi_num=""
for dev in /dev/ubi[0-9]*; do
ubinfo "$dev" -a 2>/dev/null | grep -q "Name: *$UBI_VOLUME" && { ubi_num="${dev#/dev/}"; break; }
done
[ -z "$ubi_num" ] && ubi_num="ubi1"
mkdir -p "$MOUNT_POINT/usr_sbin"
[ -z "$(ls -A $MOUNT_POINT/usr_sbin 2>/dev/null)" ] && cp -a /usr/sbin/* "$MOUNT_POINT/usr_sbin"
mount -t ubifs "$ubi_num:$UBI_VOLUME" "$MOUNT_POINT"
mount --bind "$MOUNT_POINT/usr_sbin" /usr/sbin
}
EOF
chmod 755 /etc/init.d/mount_vacant_space
/etc/init.d/mount_vacant_space enable
echo "99-mount-vacant-space: (short) script installed and enabled" > /dev/kmsg
exit 0
デバイスアクセス
デバイスアクセス(UCI)
パワーシェルでアクセス
PowerShellの開始
- キー入力:
Win
+x
>a
>はい
UCI(SSH)アクセス
powershell:初期設定用
ssh -o StrictHostKeyChecking=no -oHostKeyAlgorithms=+ssh-rsa root@192.168.1.1
- root@192.168.1.1's password:
初期値:パスワード無し
SSHログイン出来ない場合
-
%USERPROFILE%\.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
LuCi
ブラウザーでアクセス
-
openwrt.lan or (192.168.1.1)
- ユーザー名:
root
- パスワード:
パスワード
- ユーザー名:
初期設定
パスワード
初期値から変更
passwd
Changing password for root
New password:
passwd:入力モード
任意のパスワード
Retype password:
passwd:入力モード
再入力
passwd: password for root changed by root
exit
タイムゾーン
タイムゾーンを変更
#!/bin/sh
TIMEZONE='JST-9'
ZONENAME='Asia/Tokyo'
uci set system.@system[0].timezone=${TIMEZONE}
uci set system.@system[0].zonename=${ZONENAME}
uci commit system
/etc/init.d/sysntpd restart
NTP
NTPサーバーを変更
#!/bin/sh
POOL='jp'
uci delete system.ntp.server
uci add_list system.ntp.server=0.${POOL}.pool.ntp.org
uci add_list system.ntp.server=1.${POOL}.ppl.ntp.org
uci add_list system.ntp.server=2.${POOL}.pool.ntp.org
uci add_list system.ntp.server=3.${POOL}.pool.ntp.org
uci commit system
/etc/init.d/sysntpd restart
NTPサーバーを有効
#!/bin/sh
uci set system.ntp.enable_server='1' # NTPサーバー有効
uci set system.ntp.use_dhcp='0'
uci set system.ntp.interface='lan'
uci commit system
/etc/init.d/sysntpd restart
SSH
WANからのアクセスを遮断
uci set dropbear.@dropbear[0].Interface='lan'
uci commit dropbear
新規設定用 オールインワンスクリプト 初心者対応
設定ツール(ベーター版テスト中)
パッケージ
母国語サポート
LuCiの言語パッケージをインストール
- 対応言語検索
#! /bin/sh
opkg update
opkg list luci-i18n-base\*
- 設定
#! /bin/sh
I18N='ja'
opkg update
opkg install luci-i18n-base-${I18N}
opkg install luci-i18n-firewall-${I18N}
UCI(TTYD)
ブラウザーでUCIにアクセス
#! /bin/sh
I18N='ja'
opkg update
opkg install luci-i18n-ttyd-${I18N}
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
ファイラー(SFTP)
WinSCPでファイルにアクセス
#! /bin/sh
opkg update
opkg install openssh-sftp-server
クライアント設定(Windows)
- 手動インストール
- ダウンロード:WinSCP
- 自動インストール
- キー入力:
Win
+x
>a
>はい
- 最新版ソフトウェアのインストール
- キー入力:
powershell:クライアントPC
$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
opkg update
opkg install irqbalance
uci set irqbalance.irqbalance=irqbalance
uci set irqbalance.irqbalance.enabled='1'
uci commit irqbalance
/etc/init.d/irqbalance start
ネットワーク統計インターフェイス
インストール
#! /bin/sh
I18N='ja'
opkg update
opkg install luci-i18n-statistics-${I18N}
/etc/init.d/collectd enable
/etc/init.d/rpcd restart
- プラグイン検索
#! /bin/sh
opkg update
opkg list collectd-mod\*
追加テーマ
インストール
#! /bin/sh
opkg update
opkg install luci-theme-openwrt
opkg install luci-theme-material
トラブル
初期化
ファクトリーリセット(初期化)
リセット
# 要注意
firstboot && reboot now
This will erase all settings and remove any installed packages. Are you sure? [N/y]
初期化:入力モード
y
デバイスリセットボタン
デバイスのリセットボタンを10秒押し続ける
あとがき
ハードオフにふらっと入ると1500円で売っていたので、思わず買ってしまいました。