1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

TL-WR902ACを、macOS標準のtftpは使わずに、OpenWrt化

Last updated at Posted at 2023-02-26

https://openwrt.org/toh/tp-link/tl-wr902ac_v3 に手順はあるが macOS Venturaでちょっと苦労したのでメモ。

デバイスとmacOSとの接続方法

macOS <--USBのLAN--> TL-WR902AC

のように直結。TL-WR902AC本体のスイッチは真ん中(Share Hotspot)にしておく。

アドレス固定

マニュアルにあるように、192.168.0.66にせよ、と。それに従う。

image.png

tftpサーバー

macOS標準のやつだと、ログが出ないので動いてるかどうか非常にわかりづらい。

に記載のある。dnsmasqを使う。

% brew install dnsmasq
% sudo $(brew --prefix dnsmasq)/sbin/dnsmasq --log-debug --log-facility=/tmp/tftp.log  --keep-in-foreground -i en6 -p 0 -z --enable-tftp --tftp-root /tmp
Password:

en6 ってのは個々人によって異なるはず。USB LANのデバイスをifconfigで探して、192.168.0.66のものを指定する。

別ターミナルでログを監視する。

% sudo tail -f /tmp/tftp.log
Feb 27 03:30:26 dnsmasq[39535]: started, version 2.89 DNS disabled
Feb 27 03:30:26 dnsmasq[39535]: compile time options: IPv6 GNU-getopt no-DBus no-UBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack no-ipset no-nftset auth no-cryptohash no-DNSSEC loop-detect no-inotify dumpfile
Feb 27 03:30:26 dnsmasq-tftp[39535]: TFTP root is /tmp  

ファームウェアを配置

のファームウェアをリネームしてTFTPサーバーのルートに配置する。

wget https://downloads.openwrt.org/releases/22.03.3/targets/ramips/mt76x8/openwrt-22.03.3-ramips-mt76x8-tplink_tl-wr902ac-v3-squashfs-tftp-recovery.bin -O tp_recovery.bin
sudo mv tp_recovery.bin /tmp/tp_recovery.bin

接続テスト

% tftp 127.0.0.1
tftp> get tp_recovery.bin
Received 8149903 bytes in 0.5 seconds
tftp> quit

サーバーログに

Feb 27 03:30:37 dnsmasq-tftp[39535]: sent /tmp/tp_recovery.bin to 127.0.0.1

こんなのが出ればOK。

いざ

リセットボタンを爪楊枝で押しながら、USBをさす。

Feb 27 03:46:28 dnsmasq-tftp[41825]: sent /tmp/tp_recovery.bin to 192.168.0.2

こんなアクセスログが来たら成功。

しばらくしたら 192.168.1.1 でルーターが起動する。

生まれ変わったルーターへアクセス

USB LANを通常のDHCPでIPアドレス取得に戻す

image.png

(もしもIPが自動で取れなかったら、手動でIP192.168.1.2, サブネットマスク255.255.255.0, ルーター192.168.1.1を指定する)

あとは、ブラウザで 192.168.1.1 。OpenWrtこんにちは!

初期パスワードは空なので、すぐにパスワードは設定する!

image.png

WAN側からSSHできるようにする

マンゴールーターなどとは異なり、TP-WR902ACはLAN端子が1個でWANとLANを兼ねた作りになっている。
これが若干やっかいで、

  • USB-LANでPCと直接つないでルーター起動すると、APモードっぽい感じになる
  • 家の基幹ルーターのLANとTP-WR902ACのLANを接続すると、勝手にブリッジモードで起動する

のような動作をする。上位ルータがDHCPサーバー機能を持っている場合には、ブリッジとして振る舞うのは賢いなーと思う反面、ひとたびLAN側を上位ルーターにつないでしまうとOpenWrtの管理画面にアクセスできなくなってしまうので結構困る。なので、DHCP設定とファイアウォールの設定だけすぐにやる。

Wireless画面で

  • すべてのWiFiをとりあえずenabledにし、何かしら電波を吹く状態にする

Interfaces画面で

  • 既存のLANをDHCP Clientに変更
    • DHCP機能をオフ
    • ファイアーウォールのエリアをwanに指定

FirewallのTraffic Rulesタブ。

image.png

ここで外からの22番ポートへのアクセスを許可する。

image.png

再起動すれば、上位ルーターの方から

ssh root@192.168.xxx.yy -L 8080:127.0.0.1:80

のようにSSHで接続できるし、ポートフォワードすれば、 localhost:8080 にアクセスするとWeb UIが開ける。

(参考)special thanks

容量が足りない?

ちなみにこのルーターはストレージが8MBしかない(ギガじゃないよ。メガ)うえに、LANポートも一個だけだ。

WPA2 Enterprise (EAP-TLS)を試そうとおもったのだけど、容量が足りずfreeradius3を入れられなかった。

つまりこのルーター、OpenWrt化したところで、ほとんど単機能のルーターとして使うことしかできない…。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?