WHR-1166DHP に OpenWrt をインストール

はじめに

OpenVPNサーバーとして長らく(約6年)DD-WRTを使用しているのですが、最近はリリースが行われていません。 一方で、最近、私の自宅のネットワーク環境を使用していろいろと学習を行っており、今後ルーターを活用するケースが増えそうになってきた為、最新のOpenWrtを導入することにしました。

最終的には現在DD-WRTを使用している BUFFALO WZR-1750DHP を置き換えたいですが、OpenVPNのサービスをできるだけ止めたくないので、まずは別のルーターを使用して構築を行い、そちらで代替ができるようにしたいと思います。

未使用の WHR-1166DHPがあるので、こちらを利用します。

要約

下記の手順でファームウェアを書き換えることができました。

参考

詳細手順

Raspberry Pi にtftpサーバーをセットアップ

tftpサーバーのセットアップ方法については Raspberry Pi 3B で tftpサーバー を参照。

tftpサーバーのIPアドレスは192.168.11.168 を設定します。

RAM上からOpenWrtを起動

PCからtftpサーバーにinitramfsを転送

https://downloads.openwrt.org/snapshots/targets/ramips/mt7620/openwrt-ramips-mt7620-buffalo_whr-1166d-initramfs-kernel.binFirmware を作業用PCにダウンロードし、ラズパイにscp。/srv/tftp に firmware_WHR-1166DHP.ram という名前で格納する。

AOSSボタンを押しながらルーターを起動することで、tftpを使用してRAM上からOpenWrtを起動(initramfs)

ラズパイとルーターをネットワークケーブルで接続し、AOSSボタンを押しながらルーターを起動します。 tftpによりinitramfsイメージがダウンロードされ、RAM上からOpenWrtが起動します。 LED点滅が終了し点灯した状態で、作業用PCとルーターをネットワークケーブルで接続します。 sshでログインします。

ssh root@192.168.1.1


BusyBox v1.36.1 (2024-02-22 08:17:25 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r25279-62acd9a2f9
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~#

一旦ログアウトします。

squashfsの書き込み、起動

PCからscpでOpenWrtに下記ファイル(squashfs)をコピー

OpenWrt snapshot https://downloads.openwrt.org/snapshots/targets/ramips/mt7620/openwrt-ramips-mt7620-buffalo_whr-1166d-squashfs-sysupgrade.bin をダウンロードし、ルーターにscpします。

$ scp openwrt-ramips-mt7620-buffalo_whr-1166d-squashfs-sysupgrade.bin root@192.168.1.1:/root/
openwrt-ramips-mt7620-buffalo_whr-1166d-squashfs-sysupgrade.bin                                          100% 5696KB   3.6MB/s   00:01

sshでOpenWrtにログイン

再度ログインします。

$ ssh root@192.168.1.1


BusyBox v1.36.1 (2024-02-22 08:17:25 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r25279-62acd9a2f9
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------

ファイルがコピーされていることを確認します。

root@OpenWrt:~# ls -la
drwxr-x---    2 root     root            60 Feb 22 08:41 .
drwxrwxrwt   16 root     root           360 Jan  1  1970 ..
-rw-r--r--    1 root     root       5833026 Feb 22 08:41 openwrt-ramips-mt7620-buffalo_whr-1166d-squashfs-sysupgrade.bin

手順にしたがい、メモリーの空き容量を確認します。

root@OpenWrt:~# free
              total        used        free      shared  buff/cache   available
Mem:         121612       13948       86576       19988       21088       62552
Swap:             0           0           0

/tmp/ にコピーします。

root@OpenWrt:~# mv openwrt-ramips-mt7620-buffalo_whr-1166d-squashfs-sysupgrade.bin /tmp/

OpenWrtからsysupgradeで上記を書き込み

sysupgrade コマンドで書き込みを行います。 書き込みが開始されると即座に切断されます。

root@OpenWrt:~# sysupgrade -v /tmp/openwrt-ramips-mt7620-buffalo_whr-1166d-squashfs-sysupgrade.bin
Cannot save config while running from ramdisk.
Thu Feb 22 08:42:50 UTC 2024 upgrade: Commencing upgrade. Closing all shell sessions.
Command failed: Connection failed
root@OpenWrt:~# Connection to 192.168.1.1 closed by remote host.
Connection to 192.168.1.1 closed.

書き込まれたファームウェアからOpenWrtが起動

LEDの点滅が終了し、しばらく点灯状態が継続する状態になったことを確認します。

最新ファームウェアの書き込み、起動

PCからscpでOpenWrtに下記ファイル(最新のOpenWrtファームウェア)をコピー

Firmware OpenWrt Upgrade https://downloads.openwrt.org/releases/23.05.0/targets/ramips/mt7620/openwrt-23.05.0-ramips-mt7620-buffalo_whr-1166d-squashfs-sysupgrade.binFirmware をダウンロードします。

ルーター側にコピーします。

$ scp openwrt-23.05.0-ramips-mt7620-buffalo_whr-1166d-squashfs-sysupgrade.bin  root@192.168.1.1:/root/
openwrt-23.05.0-ramips-mt7620-buffalo_whr-1166d-squashfs-sysupgrade.bin                                          100% 5824KB 133.5KB/s   00:43

OpenWrtからsysupgradeで上記を書き込み

sshで接続します。

$ ssh root@192.168.1.1


BusyBox v1.36.1 (2024-02-22 08:17:25 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r25279-62acd9a2f9
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------

ファイルを確認します。

root@OpenWrt:~# ls -la
drwxr-x---    1 root     root             0 Feb 22 08:27 .
drwxr-xr-x    1 root     root             0 Jan  1  1970 ..
-rw-r--r--    1 root     root       5964097 Feb 22 08:28 openwrt-23.05.0-ramips-mt7620-buffalo_whr-1166d-squashfs-sysupgrade.bin

sysupgradeコマンドで書き込みます。( tmp にコピーするのを端折りましたが、その場合自動でやってくれるようです。)

root@OpenWrt:~# sysupgrade -v openwrt-23.05.0-ramips-mt7620-buffalo_whr-1166d-squashfs-sysupgrade.bin
Thu Feb 22 08:29:30 UTC 2024 upgrade: Image not in /tmp, copying...
Thu Feb 22 08:29:34 UTC 2024 upgrade: Saving config files...
etc/config/dhcp
etc/config/dropbear
etc/config/firewall
etc/config/network
etc/config/system
etc/config/wireless
etc/dropbear/dropbear_ed25519_host_key
etc/dropbear/dropbear_rsa_host_key
etc/group
etc/hosts
etc/inittab
etc/nftables.d/10-custom-filter-chains.nft
etc/nftables.d/README
etc/opkg/keys/b5043e70f9a75cde
etc/passwd
etc/profile
etc/rc.local
etc/shadow
etc/shells
etc/shinit
etc/sysctl.conf
etc/uci-defaults/10_disable_services
Thu Feb 22 08:29:35 UTC 2024 upgrade: Commencing upgrade. Closing all shell sessions.
Command failed: Connection failed
root@OpenWrt:~# Connection to 192.168.1.1 closed by remote host.
Connection to 192.168.1.1

書き込みが開始されると即座に切断されます。

書き込まれたファームウェアからOpenWrtが起動(完了)

$ ssh root@192.168.1.1


BusyBox v1.36.1 (2023-10-09 21:45:35 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 23.05.0, r23497-6637af95aa
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------

WebUI

192.168.1.1 にブラウザでアクセスするとWebUIを確認できます。

1172_01.jpg

おわりに

以上です。

Copied title and URL