OpenWrt と openNDS を駆使して Wi-Fi 接続時に Captive Portal を表示する
今回の環境
TL;DR
1. Raspberry Pi のファームウェア更新
Raspberry Pi OS Lite Boot メディアの作成












接続
ssh pi@raspberrypi.local
The authenticity of host 'raspberrypi.local (xxxx:xxxx:xxxx:x:xxxx:xxxx:xxxx:xxxx)' can't be established.
ED25519 key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxx.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'raspberrypi.local' (ED25519) to the list of known hosts.
Password:
ファームウェア設定
sudo raspi-config

ロケール設定




ファームウェアバージョン設定








2. OpenWrt のインストール
firmware-selector.openwrt.org から最新のファクトリーファームウェアをダウンロードする

OpenWrt Boot メディアの作成







3. OpenWrt の設定
ssh root@raspberrypi.local
The authenticity of host '192.168.1.1 (xxxx:xxxx:xxxx:x:xxxx:xxxx:xxxx:xxxx)' can't be established.
ED25519 key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxx.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.1.1' (ED25519) to the list of known hosts.
Password:
システム設定
uci set system.@system[0].hostname='raspberrypi'
uci set system.@system[0].timezone='Asia/Tokyo'
uci del system.ntp.server
uci add_list system.ntp.server='ntp.nict.jp'
uci commit system
service system reload
service system restart
ワイヤレス設定
uci set wireless.radio0.country='JP'
uci set wireless.radio0.band='5g'
uci set wireless.radio0.channel='36'
uci set wireless.radio0.htmode='VHT20'
uci set wireless.radio0.txpower='20'
uci del wireless.radio0.disabled
uci commit wireless
ネットワーク設定
uci set network.lan.proto='static'
uci set network.lan.ipaddr='192.168.1.1'
uci set network.lan.netmask='255.255.255.0'
uci set network.lan.dns='1.1.1.1 1.0.0.1'
uci del_list network.@device[0].ports='eth0'
uci set network.wan='interface'
uci set network.wan.proto='dhcp'
uci set network.wan.device='eth0'
uci commit network
service network restart
umdns インストール
opkg update
Downloading https://downloads.openwrt.org/releases/24.10.5/targets/bcm27xx/bcm2712/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_core
Downloading https://downloads.openwrt.org/releases/24.10.5/targets/bcm27xx/bcm2712/packages/Packages.sig
...
Signature check passed.
opkg install umdns
Installing umdns (2025.02.10~c5ca22a7-r1) to root...
Downloading https://downloads.openwrt.org/releases/24.10.5/packages/aarch64_cortex-a76/base/umdns_2025.02.10~c5ca22a7-r1_aarch64_cortex-a76.ipk
Configuring umdns.
再起動
reboot
4. openNDS の設定
接続
ssh pi@raspberrypi.local
The authenticity of host 'raspberrypi.local (xxxx:xxxx:xxxx:x:xxxx:xxxx:xxxx:xxxx)' can't be established.
ED25519 key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxx.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'raspberrypi.local' (ED25519) to the list of known hosts.
Password:
opennds インストール
opkg update
Downloading https://downloads.openwrt.org/releases/24.10.5/targets/bcm27xx/bcm2712/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_core
Downloading https://downloads.openwrt.org/releases/24.10.5/targets/bcm27xx/bcm2712/packages/Packages.sig
...
Signature check passed.
opkg install opennds
Installing opennds (10.3.1-r1) to root...
Downloading https://downloads.openwrt.org/releases/24.10.5/packages/aarch64_cortex-a76/routing/opennds_10.3.1-r1_aarch64_cortex-a76.ipk
Installing libmicrohttpd-no-ssl (1.0.1-r1) to root...
Downloading https://downloads.openwrt.org/releases/24.10.5/packages/aarch64_cortex-a76/packages/libmicrohttpd-no-ssl_1.0.1-r1_aarch64_cortex-a76.ipk
Configuring libmicrohttpd-no-ssl.
Configuring opennds.
uci: Invalid argument
This is openNDS version 10.3.1
The Legacy splash.html Static Web Page
cd /usr/lib/opennds
wget https://raw.githubusercontent.com/openNDS/openNDS/master/community/themespec/theme_legacy/theme_click-to-continue-legacy.sh
Downloading 'https://raw.githubusercontent.com/openNDS/openNDS/master/community/themespec/theme_legacy/theme_click-to-continue-legacy.sh'
Connecting to 185.199.111.133:443
Writing to 'theme_click-to-continue-legacy.sh'
theme_click-to-conti 100% |*******************************| 5143 0:00:00 ETA
Download completed (5143 bytes)
cd /etc/opennds/htdocs
wget https://raw.githubusercontent.com/openNDS/openNDS/master/community/themespec/theme_legacy/splash.html
Downloading 'https://raw.githubusercontent.com/openNDS/openNDS/master/community/themespec/theme_legacy/splash.html'
Connecting to 185.199.111.133:443
Writing to 'splash.html'
splash.html 100% |*******************************| 2213 0:00:00 ETA
Download completed (2213 bytes)
chmod 744 /usr/lib/opennds/theme_click-to-continue-legacy.sh
uci set opennds.@opennds[0].login_option_enabled='3'
uci set opennds.@opennds[0].themespec_path='/usr/lib/opennds/theme_click-to-continue-legacy.sh'
uci commit opennds
service opennds restart
uci: Invalid argument
This is openNDS version 10.3.1
再起動
reboot
4. Wi-Fi に接続する
SSID: OpenWrt
