| | 1 | [[PageOutline]] |
| | 2 | |
| | 3 | * 注意: 非純正ファームウェアで無線を使うと(日本では)電波法違反になる可能性がある。 |
| | 4 | * see also [../../Linux/OpenWRT] |
| | 5 | |
| | 6 | = reference = |
| | 7 | * [http://matsuk-xmit.blogspot.jp/2012/03/wzr-hp-ag300hdd-wrt-openwrt.html matsuk_start_xmit: WZR-HP-AG300HにDD-WRT / OpenWrtをインストールする] |
| | 8 | > DD-WRTと比べると運用方法も一気に難易度があがります。自分で全部manageしたいという方にしかおすすめできません。 |
| | 9 | > * T8 トルクスドライバー |
| | 10 | > * マイナスドライバー (筐体ひっぺがし用) |
| | 11 | > * TTLレベルのシリアル接続ができるケーブル (秋月のFT232RLとか) |
| | 12 | > * はんだ、はんだごて、銅線とか。ようははんだづけしなきゃならんです。 |
| | 13 | * 後述するが、純正ファームウェアからWebUI経由で適用出来る |
| | 14 | |
| | 15 | * [http://wiki.openwrt.org/toh/buffalo/wzr-hp-ag300h Buffalo WZR-HP-AG300H - OpenWrt Wiki] |
| | 16 | * [http://wiki.openwrt.org/doc/howto/hardware.button Attach functions to the hardware button - OpenWrt Wiki] |
| | 17 | |
| | 18 | * [http://ameblo.jp/pirorigin/entry-10997073769.html WZR-HP-AG300HをDD-WRT化に|デジタル家電・PC イマコリ!!] |
| | 19 | |
| | 20 | = binary = |
| | 21 | * DD-WRT |
| | 22 | * ftp://dd-wrt.com/others/eko/BrainSlayer-V24-preSP2/2011/12-20-11-r18024/buffalo_wzr-hp-ag300h/ |
| | 23 | * OpenWRT |
| | 24 | * http://downloads.openwrt.org/snapshots/trunk/ar71xx/ |
| | 25 | |
| | 26 | = Official Firm = |
| | 27 | * 純正ファームウェアへの戻し方 |
| | 28 | * [http://buffalo.jp/download/driver/lan/wzr-hp-ag300h_fw-win.html ドライバーダウンロード WZR-HP-AG300Hシリーズ | BUFFALO バッファロー] |
| | 29 | * wzrhpag300h-172.exe > wzrhpag300h-172 |
| | 30 | 1. $ sudo ifconfig eth0:1 192.168.11.2 |
| | 31 | 1. $ sudo arp -s 192.168.11.1 02:aa:bb:cc:dd:20 |
| | 32 | 1. $ tftp 192.168.11.1 |
| | 33 | {{{ |
| | 34 | tftp> binary |
| | 35 | tftp> put wzrhpag300h-172 |
| | 36 | Sent 20467964 bytes in 26.5 seconds |
| | 37 | }}} |
| | 38 | * DIAG LED(赤)が点滅すれば成功 |
| | 39 | |
| | 40 | * [http://www34.atwiki.jp/ddwrt/pages/19.html DD-WRTまとめwiki - Buffaloルータのデバッグモード] |
| | 41 | > http://192.168.11.1/cgi-bin/cgi?req=frm&frm=py-db/55debug.html |
| | 42 | > * ユーザー名:bufpy |
| | 43 | > * パスワード:otdpopy+ルートのパスワード |
| | 44 | * 初期状態でrootにパスワードが設定されていない状態では「otdpopy」 |
| | 45 | * telnetdの起動や、/var/log/messages、その他の設定状況が見られる |
| | 46 | |
| | 47 | * リセットボタン |
| | 48 | * 純正ファームウェアでも、DD-WRTのデフォルト状態でも動作する |
| | 49 | * OpenWRTではsquashfsを使った上で、スクリプトを設置しないと動作しない |
| | 50 | |
| | 51 | = transfer firmware with tftp = |
| | 52 | * see [http://wiki.openwrt.org/jp/toh/buffalo/wzr-hp-ag300h#tftpを使用してインストールする TFTPを使用してインストールする] |
| | 53 | > 訳注) 日本版のAG300Hは標準状態では、OpenWrtファームウェアイメージをtftp経由でアップロードを行っても無視されますので、まずはじめに[http://wiki.openwrt.org/toh/buffalo/wzr-hp-g300h#problem.with.newer.and.japanese.versions.locked.u-boot.too.short.time.tftp.window こちら]を参照してブートローダの設定変更を行ってください。 |
| | 54 | * 純正ファームへの書き戻しは、「setenv accept_open_rt_fmt 1」なしでも可能 |
| | 55 | * それ以外は、setenv無しには無理な模様 |
| | 56 | * mitty@ubuntu64:~/OpenWRT$ tftp 192.168.11.1 |
| | 57 | {{{ |
| | 58 | tftp> binary |
| | 59 | tftp> put openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-tftp.bin |
| | 60 | Sent 2555940 bytes in 17.1 seconds |
| | 61 | tftp> |
| | 62 | }}} |
| | 63 | * 変化しない |
| | 64 | |
| | 65 | * mitty@ubuntu64:~/OpenWRT$ sudo ifconfig eth0:1 192.168.11.2 |
| | 66 | * mitty@ubuntu64:~/OpenWRT$ sudo arp -s 192.168.11.1 02:aa:bb:cc:dd:20 |
| | 67 | |
| | 68 | * mitty@ubuntu64:~$ ifconfig eth0:1 |
| | 69 | {{{ |
| | 70 | eth0:1 Link encap:Ethernet HWaddr 00:0c:29:a3:81:7f |
| | 71 | inet addr:192.168.11.2 Bcast:192.168.11.255 Mask:255.255.255.0 |
| | 72 | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 |
| | 73 | }}} |
| | 74 | * mitty@ubuntu64:~$ arp -n |
| | 75 | {{{ |
| | 76 | Address HWtype HWaddress Flags Mask Iface |
| | 77 | 192.168.11.1 ether 02:aa:bb:cc:dd:20 CM eth0 |
| | 78 | }}} |
| | 79 | |
| | 80 | * mitty@ubuntu64:~/OpenWRT$ tftp 192.168.11.1 -m binary -c put openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-tftp.bin |
| | 81 | {{{ |
| | 82 | usage: tftp host-name [port] |
| | 83 | }}} |
| | 84 | * wikiのコマンドラインではうまくいかなかった |
| | 85 | * mitty@ubuntu64:~/OpenWRT$ tftp 192.168.11.1 |
| | 86 | {{{ |
| | 87 | tftp> put openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-tftp.bin |
| | 88 | Sent 2575462 bytes in 16.6 seconds |
| | 89 | }}} |
| | 90 | * しかし、上でも述べたように適用されない |
| | 91 | |
| | 92 | = deploy with WebUI = |
| | 93 | * official firm (ファームウェアを更新する) -> buffalo_to_ddwrt_webflash-MULTI.bin |
| | 94 | * OK -> DD-WRT化 |
| | 95 | * official firm (ファームウェアを更新する) -> openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-factory.bin |
| | 96 | * OK -> OpenWRT化(squashfs) |
| | 97 | * 基礎的な機能(telnetd, sshd)しか導入されない |
| | 98 | * official firm (ファームウェアを更新する) -> openwrt-ar71xx-generic-wzr-hp-ag300h-jffs2-factory.bin |
| | 99 | * OK -> OpenWRT化(jffs2) |
| | 100 | * 基礎的な機能(telnetd, sshd)しか導入されない |
| | 101 | * jffs2なので、リセット機能(firstboot)がうまく動かない(?) |
| | 102 | * DD-WRT (Admin. > Firm. Upgrade) -> openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-*.bin |
| | 103 | * NG |
| | 104 | |
| | 105 | = OpenWRT = |
| | 106 | * [http://wiki.openwrt.org/doc/howto/log.essentials Basic Log Support - OpenWrt Wiki] |
| | 107 | * logread コマンド |
| | 108 | |
| | 109 | * su コマンドが存在しない |
| | 110 | * sudoはある |
| | 111 | * [http://siriuth.blogspot.jp/2012/04/su.html Siriuth's Diary: suが一般ユーザーで使えない] |
| | 112 | |
| | 113 | == jffs2 == |
| | 114 | * root@OpenWrt:/# df |
| | 115 | {{{ |
| | 116 | Filesystem 1K-blocks Used Available Use% Mounted on |
| | 117 | rootfs 31296 2936 28360 9% / |
| | 118 | /dev/root 31296 2936 28360 9% / |
| | 119 | tmpfs 63320 60 63260 0% /tmp |
| | 120 | tmpfs 512 0 512 0% /dev |
| | 121 | }}} |
| | 122 | |
| | 123 | * root@OpenWrt:/# mount |
| | 124 | {{{ |
| | 125 | rootfs on / type rootfs (rw) |
| | 126 | /dev/root on / type jffs2 (rw,noatime) |
| | 127 | proc on /proc type proc (rw,noatime) |
| | 128 | sysfs on /sys type sysfs (rw,noatime) |
| | 129 | tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime) |
| | 130 | tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755) |
| | 131 | devpts on /dev/pts type devpts (rw,noatime,mode=600) |
| | 132 | debugfs on /sys/kernel/debug type debugfs (rw,relatime) |
| | 133 | none on /proc/bus/usb type usbfs (rw,relatime) |
| | 134 | }}} |
| | 135 | |
| | 136 | === reset function === |
| | 137 | * [http://wiki.openwrt.org/doc/howto/hardware.button Attach functions to the hardware button - OpenWrt Wiki]を参考に設定するがうまく動かない |
| | 138 | |
| | 139 | * root@OpenWrt:~# mkdir -p /etc/hotplug.d/button |
| | 140 | * root@OpenWrt:~# vim /etc/hotplug.d/button/buttons |
| | 141 | {{{#!sh |
| | 142 | #!/bin/sh |
| | 143 | logger $BUTTON |
| | 144 | logger $ACTION |
| | 145 | }}} |
| | 146 | |
| | 147 | * root@OpenWrt:~# opkg update |
| | 148 | * root@OpenWrt:~# opkg install wget |
| | 149 | |
| | 150 | * root@OpenWrt:~# wget -O /etc/hotplug.d/button/00-button http://dev.openwrt.org/export/21216/trunk/target/linux/atheros/base-files/etc/hotplug.d/button/00-button --no-check-certificate |
| | 151 | |
| | 152 | * root@OpenWrt:~# uci add system button |
| | 153 | {{{ |
| | 154 | cfg055d81 |
| | 155 | }}} |
| | 156 | * root@OpenWrt:~# uci set system.@button[-1].button=reset |
| | 157 | * root@OpenWrt:~# uci set system.@button[-1].action=released |
| | 158 | * root@OpenWrt:~# uci set system.@button[-1].handler="firstboot && reboot" |
| | 159 | * root@OpenWrt:~# uci set system.@button[-1].min=5 |
| | 160 | * root@OpenWrt:~# uci set system.@button[-1].max=10 |
| | 161 | * root@OpenWrt:~# uci commit system |
| | 162 | |
| | 163 | * root@OpenWrt:~# uci export system.button |
| | 164 | {{{ |
| | 165 | package system |
| | 166 | |
| | 167 | config system |
| | 168 | option hostname 'OpenWrt' |
| | 169 | option timezone 'UTC' |
| | 170 | |
| | 171 | config timeserver 'ntp' |
| | 172 | list server '0.openwrt.pool.ntp.org' |
| | 173 | list server '1.openwrt.pool.ntp.org' |
| | 174 | list server '2.openwrt.pool.ntp.org' |
| | 175 | list server '3.openwrt.pool.ntp.org' |
| | 176 | option enable_server '0' |
| | 177 | |
| | 178 | config button |
| | 179 | option button 'reset' |
| | 180 | option action 'released' |
| | 181 | option handler 'firstboot && reboot' |
| | 182 | option min '5' |
| | 183 | option max '10' |
| | 184 | }}} |
| | 185 | |
| | 186 | * 以下のようにより簡単なスクリプトも試してみたが、動作しない |
| | 187 | * root@OpenWrt:~# vim /etc/hotplug.d/button/10-button |
| | 188 | {{{#!sh |
| | 189 | #!/bin/sh |
| | 190 | |
| | 191 | [ "$ACTION" = "released" -a "$BUTTON" = "reset" ] && { |
| | 192 | logger -t button-hotplug Button: $BUTTON / Action: $ACTION |
| | 193 | firstboot && reboot |
| | 194 | } |
| | 195 | }}} |
| | 196 | |
| | 197 | * firstbootコマンド自体がうまく動かない模様 |
| | 198 | * root@OpenWrt:~# firstboot |
| | 199 | {{{ |
| | 200 | firstboot has already been run |
| | 201 | jffs2 partition is mounted, only resetting files |
| | 202 | MTD partition not found. |
| | 203 | }}} |
| | 204 | * root@OpenWrt:~# echo $? |
| | 205 | {{{ |
| | 206 | 1 |
| | 207 | }}} |
| | 208 | |
| | 209 | == squashfs == |
| | 210 | * root@OpenWrt:/# df |
| | 211 | {{{ |
| | 212 | Filesystem 1K-blocks Used Available Use% Mounted on |
| | 213 | rootfs 29824 852 28972 3% / |
| | 214 | /dev/root 1536 1536 0 100% /rom |
| | 215 | tmpfs 63320 64 63256 0% /tmp |
| | 216 | tmpfs 512 0 512 0% /dev |
| | 217 | root 63320 32 63288 0% /tmp/root |
| | 218 | overlayfs:/tmp/root 63320 32 63288 0% /tmp/root |
| | 219 | /dev/mtdblock7 29824 852 28972 3% /overlay |
| | 220 | overlayfs:/overlay 29824 852 28972 3% / |
| | 221 | }}} |
| | 222 | |
| | 223 | * root@OpenWrt:/# mount |
| | 224 | {{{ |
| | 225 | rootfs on / type rootfs (rw) |
| | 226 | /dev/root on /rom type squashfs (ro,relatime) |
| | 227 | proc on /proc type proc (rw,noatime) |
| | 228 | sysfs on /sys type sysfs (rw,noatime) |
| | 229 | tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime) |
| | 230 | tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755) |
| | 231 | devpts on /dev/pts type devpts (rw,noatime,mode=600) |
| | 232 | root on /tmp/root type tmpfs (rw,noatime,mode=755) |
| | 233 | overlayfs:/tmp/root on /tmp/root type overlayfs (ro,noatime,lowerdir=/,upperdir= |
| | 234 | /tmp/root) |
| | 235 | debugfs on /sys/kernel/debug type debugfs (rw,relatime) |
| | 236 | none on /proc/bus/usb type usbfs (rw,relatime) |
| | 237 | /dev/mtdblock7 on /overlay type jffs2 (rw,noatime) |
| | 238 | overlayfs:/overlay on / type overlayfs (rw,noatime,lowerdir=/,upperdir=/overlay) |
| | 239 | }}} |
| | 240 | |
| | 241 | === reset function === |
| | 242 | * 正常に動作する |
| | 243 | |
| | 244 | * root@OpenWrt:~# firstboot && reboot |
| | 245 | {{{ |
| | 246 | firstboot has already been run |
| | 247 | jffs2 partition is mounted, only resetting files |
| | 248 | root@OpenWrt:~# Connection to 192.168.1.1 closed by remote host. |
| | 249 | }}} |
| | 250 | |
| | 251 | * root@OpenWrt:~# mkdir -p /etc/hotplug.d/button |
| | 252 | * root@OpenWrt:~# vim /etc/hotplug.d/button/10-button |
| | 253 | {{{#!sh |
| | 254 | #!/bin/sh |
| | 255 | |
| | 256 | [ "$ACTION" = "released" -a "$BUTTON" = "reset" ] && { |
| | 257 | logger -t button-hotplug Button: $BUTTON / Action: $ACTION |
| | 258 | firstboot && reboot |
| | 259 | } |
| | 260 | }}} |
| | 261 | * 期待通り動く…が、完全に初期状態に戻るため、opkgでインストールしたものなども消えてしまう |
| | 262 | * -> reset用スクリプトも消える |
| | 263 | |
| | 264 | == uhttpd == |
| | 265 | * root@OpenWrt:~# opkg update |
| | 266 | * root@OpenWrt:~# opkg install luci |
| | 267 | * root@OpenWrt:~# /etc/init.d/uhttpd enable |
| | 268 | * root@OpenWrt:~# uci export uhttpd |
| | 269 | {{{ |
| | 270 | package uhttpd |
| | 271 | |
| | 272 | config uhttpd 'main' |
| | 273 | list listen_http '0.0.0.0:80' |
| | 274 | list listen_https '0.0.0.0:443' |
| | 275 | option home '/www' |
| | 276 | option rfc1918_filter '1' |
| | 277 | option cert '/etc/uhttpd.crt' |
| | 278 | option key '/etc/uhttpd.key' |
| | 279 | option cgi_prefix '/cgi-bin' |
| | 280 | option script_timeout '60' |
| | 281 | option network_timeout '30' |
| | 282 | option tcp_keepalive '1' |
| | 283 | |
| | 284 | config cert 'px5g' |
| | 285 | option days '730' |
| | 286 | option bits '1024' |
| | 287 | option country 'DE' |
| | 288 | option state 'Berlin' |
| | 289 | option location 'Berlin' |
| | 290 | option commonname 'OpenWrt' |
| | 291 | }}} |
| | 292 | * root@OpenWrt:~# /etc/init.d/uhttpd start |
| | 293 | |
| | 294 | * root@OpenWrt:~# opkg update |
| | 295 | * root@OpenWrt:~# opkg install luci-ssl |
| | 296 | * root@OpenWrt:~# /etc/init.d/uhttpd restart |
| | 297 | {{{ |
| | 298 | Generating RSA private key, 1024 bit long modulus |
| | 299 | Generating selfsigned certificate with subject 'C=DE;ST=Berlin;L=Berlin;CN=OpenWrt;' and validity 2012-05-08 13:30:09-2014-05-08 13:30:09 |
| | 300 | }}} |
| | 301 | * root@OpenWrt:~# opkg install luci-i18n-japanese |
| | 302 | |
| | 303 | == useradd / sudo == |
| | 304 | * install sudo, shadow via webUI |
| | 305 | * opkg install でももちろん可 |
| | 306 | * suコマンドは存在しない模様 |
| | 307 | |
| | 308 | * root@ag300h:~# mkdir /home |
| | 309 | * root@ag300h:~# useradd -m -s /bin/bash mitty |
| | 310 | |
| | 311 | * root@ag300h:~# visudo |
| | 312 | {{{ |
| | 313 | mitty ALL=NOPASSWD: ALL |
| | 314 | }}} |
| | 315 | |
| | 316 | * root@ag300h:~# vim /etc/shadow |
| | 317 | {{{ |
| | 318 | mitty:!:15468:::::: |
| | 319 | }}} |
| | 320 | * パスワードログインを不可能にする |
| | 321 | |
| | 322 | * mitty@ag300h:~$ sudo chmod o-rwx /etc/shadow |
| | 323 | * mitty@ag300h:~$ sudo chmod o-rwx /etc/shadow- |
| | 324 | * mitty@ag300h:~$ sudo chmod o-rwx /etc/uhttpd.* |
| | 325 | * 一般ユーザでも見れる状態になってしまっている |