Japanese notation
はじめに
初心者対応構成
- スクリプトでの自動設定
-
UCI (ttyd)、Webコンソール (LuCi)、ファイラー (SFTP)にて比較作業がおススメ
デバイス
OpenWrt
インストール
ファームウェア
デバイス用のOpenWrtカスタムファームウェアをダウンロード
イメージのダウンロード > FACTORY をダウンロード
インストールされたパッケージ、初回起動時のスクリプトのカスタマイズ
インストールされたパッケージ
リリースビルド
base-files ca-bundle dnsmasq dropbear firewall4 fstools kmod-gpio-button-hotplug kmod-leds-gpio kmod-nft-offload kmod-rt2800-soc libc libgcc libustream-mbedtls logd mtd netifd nftables odhcp6c odhcpd-ipv6only opkg ppp ppp-mod-pppoe procd-ujail swconfig uci uclient-fetch urandom-seed urngd wpad-basic-mbedtls kmod-usb2 kmod-usb-ohci luci
"snapshot" ビルド
apk-mbedtls base-files ca-bundle dnsmasq dropbear firewall4 fstools kmod-gpio-button-hotplug kmod-leds-gpio kmod-nft-offload kmod-rt2800-soc libc libgcc libustream-mbedtls logd mtd netifd nftables odhcp6c odhcpd-ipv6only ppp ppp-mod-pppoe procd-ujail swconfig uci uclient-fetch urandom-seed urngd wpad-basic-mbedtls kmod-usb2 kmod-usb-ohci luci
初回起動時に実行されるスクリプト (uci-defaults)
管理画面
RNDIS
パッケージ
#!/bin/sh
PKGS="kmod-usb-net-rndis kmod-usb-net-cdc"
command -v opkg && opkg update && opkg install $PKGS
command -v apk && apk update && apk add $PKGS
modprobe rndis_host
modprobe cdc_ether
uci add_list network.@device[0].ports='usb0'
uci commit network
ifdown usb0 2>/dev/null
ifup usb0
これで、デバイスをDUMBでDHCP化させても、デバイスが迷子にならない。
フラッシュ&インストールシステム
ランディングページ
キッティングツール
デバイス用のOpenWrtカスタムファームウェアをダウンロード
サンプル
#!/bin/sh
cat > "/tmp/openwrt-network-auto-config.sh" << 'SCRIPT_END'
#!/bin/sh
set -eu
API_RESPONSE="$(wget -qO- https://auto-config.site-u.workers.dev/)"
echo "NOTICE=$(echo "$API_RESPONSE" | jsonfilter -e '@.notice')"
echo "IPV4=$(echo "$API_RESPONSE" | jsonfilter -e '@.ipv4')"
echo "IPV6=$(echo "$API_RESPONSE" | jsonfilter -e '@.ipv6')"
echo "COUNTRY=$(echo "$API_RESPONSE" | jsonfilter -e '@.country')"
echo "TIMEZONE=$(echo "$API_RESPONSE" | jsonfilter -e '@.timezone')"
echo "ZONENAME=$(echo "$API_RESPONSE" | jsonfilter -e '@.zonename')"
echo "ISP=$(echo "$API_RESPONSE" | jsonfilter -e '@.isp')"
echo "AS=$(echo "$API_RESPONSE" | jsonfilter -e '@.as')"
echo "REGION_NAME=$(echo "$API_RESPONSE" | jsonfilter -e '@.regionName')"
echo "REGION_CODE=$(echo "$API_RESPONSE" | jsonfilter -e '@.region')"
echo "AFTR_TYPE=$(echo "$API_RESPONSE" | jsonfilter -e '@.aftr.aftrType')"
echo "AFTR_JURISDICTION=$(echo "$API_RESPONSE" | jsonfilter -e '@.aftr.jurisdiction')"
echo "AFTR_IPV6=$(echo "$API_RESPONSE" | jsonfilter -e '@.aftr.aftrIpv6Address')"
echo "MAPE_BR_IPV6=$(echo "$API_RESPONSE" | jsonfilter -e '@.mape.brIpv6Address')"
echo "MAPE_EA_BITS=$(echo "$API_RESPONSE" | jsonfilter -e '@.mape.eaBitLength')"
echo "MAPE_IPV4_PREFIX=$(echo "$API_RESPONSE" | jsonfilter -e '@.mape.ipv4Prefix')"
echo "MAPE_IPV4_PLEN=$(echo "$API_RESPONSE" | jsonfilter -e '@.mape.ipv4PrefixLength')"
echo "MAPE_IPV6_PREFIX=$(echo "$API_RESPONSE" | jsonfilter -e '@.mape.ipv6Prefix')"
echo "MAPE_IPV6_PLEN=$(echo "$API_RESPONSE" | jsonfilter -e '@.mape.ipv6PrefixLength')"
echo "MAPE_PSID_OFFSET=$(echo "$API_RESPONSE" | jsonfilter -e '@.mape.psIdOffset')"
echo "MAPE_PSIDLEN=$(echo "$API_RESPONSE" | jsonfilter -e '@.mape.psidlen')"
SCRIPT_END
sh "/tmp/openwrt-network-auto-config.sh"
コンソールツール
デバイスアクセス
デバイスアクセス(UCI)
パワーシェルでアクセス
PowerShellの開始
- キー入力:
Win+x>a>はい
UCI(SSH)アクセス
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隠しファイル
Clear-Content .ssh\known_hosts -Force
OpenSSHのインストールが無い場合
- 機能の確認
※Windows 10 Fall Creators Update(1709)以降標準搭載
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
- 機能のインストール
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:
任意のパスワード
Retype password:
再入力
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>はい - 最新版ソフトウェアのインストール
- キー入力:
$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秒(LEDが点滅するまで)押し続ける
http://10.10.10.254 でブラウザを開く
- factory をアップロード
- 数分待つ
あとがき
個人的にとても気に入りました!
長さはラズパイZEROと同等です
小さくて、Wi-FiとRJ45 があり、しかもUSBとSDカードスロットまである
フラッシュ8MB、メモリー64MBあるから、24.10が入る👍
リセットボタンがあるのが何気に助かる




