Tuesday, July 28, 2015

Openwrt Synchronized Wifi Hotspot

There are three wireless routers at my home. All run Openwrt. One acts as gateway. The other two are APs. Sometimes, my mother wants to turn off WiFi before sleep. She would power off the gateway router. As a result, all clients will connect to the other two APs, and cannot access the Internet.

I want to make things more elegant. When the two APs detect that the gateway is down, they will turn off their wifi as well, and turn it on when the gateway is online again. Fortunately, the two APs have enough ROM for python. So I need not mess around with shell scripts.

Friday, July 24, 2015

Netgear WNR2000 v4 刷 OpenWrt 和 Gargoyle

最近淘了一个二手的WNR2000,硬件版本v4,使用AR9341单芯片方案,4MB闪存,32MB内存。发现自带固件功能太弱,可玩性不高,故刷Openwrt.

WNR2000是Openwrt支持的硬件,可以参考http://wiki.openwrt.org/toh/netgear/wnr2000,但是这个网页里的信息过时了。telnetenable已经不适用于这台WNR2000。可喜的是电路板上留有TTL焊盘,焊上排针就可以使用。离网络口隔离变压器最远的是GND,然后是RX,TX,波特率是115200。

连接上TTL即可看到终端,官方固件是基于Openwrt改造的,进入终端还有Openwrt的字符画。不过可用的指令很少。

Monday, July 6, 2015

用netcat传送文件

一些特殊情况下,比如ssh挂掉了,可以用netcat传输文件。当然,是明文传输。

首先在接收端listen,输入
nc -l 6000 > filename
然后在发送端输入
nc IP 6000 < file_to_send

IP是接收端IP地址,filename是文件保存的名字。

也可以改成在发送端Listen,适用于BusyBox里不支持-l的netcat

发送端:
cat file_to_send | pv -b | nc -l -p 3333
接收端:
nc IP 3333 > filename


还有一个办法,用Python的SimpleHTTPServer和wget

服务端:
python -m SimpleHTTPServer
会在当前目录下运行一个HTTP服务器,端口号为8000

客户端:
wget http://IP:8000/filename