Wednesday, October 14, 2009

令人发指.com 的宕机

这个 Blog 最近经常宕机,请不必太担忧。不是被墙了,我也还没有机会去喝茶。只是我爹妈家的猫很喜欢我放那儿的路由器,经常在上面爬来爬去;俺娘又怕电着了猫(解释电压之类是没用的),经常把电源断了。我整天天涯海角的乱跑,也实在鞭长莫及。几个月不 update 的 blog 还老宕机,实在不好意思,撰文以纪念。

--
Best Regards
Yale Huang <mailto: calvino.huang@gmail.com>

Labels:

Friday, November 14, 2008

OpenWRT NAS Watchdog

I set up a WDS network with two OpenWRT powered Wifi routers in my apartment. It was found soon that the client router, which has less memory and less services, breaks several time every day. Today, I found that the nas process crashed. Without check the patches I found at OpenWRT dev web (https://dev.openwrt.org/ticket/164, https://dev.openwrt.org/browser/trunk/package/madwifi/patches/111-wds_fix_PR_914.patch?rev=5903), which are quite old (I'm using the last version WhiteRussian), I just implemented a cron job watchdog with shell:


#!/bin/sh

# /usr/local/bin/nas_watchdog

pid="$(cat /var/run/nas.lan.pid 2>&-)"
[ -n "$pid" -a -d "/proc/$pid" ] && exit 0

echo "Restarting WPA ..."
/etc/init.d/S41wpa
exit 1


And my crontab:

*/2 * * * * /usr/local/bin/nas_watchdog

Labels:

Sunday, October 12, 2008

Connect Subnets with OpenWRT & OpenVPN

See 3. Certificate creation of http://wiki.openwrt.org/OpenVPNTunHowTo for key and cert generating.

At server side, the new init script mentioned in the previous wiki page is required. I placed it at /etc/init.d/openvpn.new, and symbol link it to /etc/init.d/S50openvpn . My init.d script:


#!/bin/sh
case "$1" in
start)
openvpn --daemon --config /etc/openvpn/openvpn_peer.conf
;;
restart)
$0 stop
sleep 3
$0 start
;;
reload)
killall -SIGHUP openvpn
;;
stop)
killall openvpn
;;


For route to server subnet, it's pretty simple, just follow OpenWRT wiki for it. But for route to the client subnet, some changes in OpenVPN server configuration file are required. My /etc/openvpn/openvpn_peer.conf .


### network options
port 1194
#proto udp
proto tcp
dev tun
### certificate and key files
ca /etc/openvpn/ca.crt
cert /etc/openvpn/server.crt
key /etc/openvpn/server.key
dh /etc/openvpn/dh1024.pem
### (optional) use a shared key to initialize TLS negotiation
#tls-auth /etc/openvpn/shared.key
### VPN subnet
server 10.8.0.0 255.255.255.0
### (optional) make local network behind the VPN server accessible for the VPN clients
push "route 192.168.1.0 255.255.255.0"
### (optional) make the VPN server a gateway for the internet for the VPN clients
#push "redirect-gateway"
### (optional) compression (might make your WRT sluggish or not, depending on the model and what you have running...)
comp-lzo
keepalive 10 120
status /tmp/openvpn.status

# route to peer subnets
client-config-dir /etc/openvpn/ccd
route 192.168.3.0 255.255.255.0


Notice:
  • I used TCP instead of UDP, since some firewalls blocks UDP.
  • client-config-dir is important for route to client subnet, see following ccd file description.
  • route is also important, which must match the iroute settings in ccd file.
I have a ccd file named /etc/openvpn/ccd/client , while client is the common name of the client certificate. It reads:


iroute 192.168.3.0 255.255.255.0


Then, when the peers were connected, routes were added.

Labels:

Tuesday, August 19, 2008

OpenWRT Upgrade Failure with IPKG

Yesterday, I tried to upgrade one of by OpenWRT box with /ipkg upgrade/.
I canceled the upgrade process when I saw the first package, base-files,
was upgraded. But it's too late, /etc/passwd was overwritten. Since I
was executing /ipkg/ with /sudo/, current user was missed in
//etc/passwd/. I used to think that I have to rescue the USB fs with an
original backup. Fortunately, I found the password of root was reseted
to blank and can be accessed with telnet. So, I logged in can copy some
files from another box. Now the box was back.

I'm not sure that whether any other customized files will be affected by
upgrading. But chances are that there's no protection for them during
upgrading. And unfortunately, there's no version check for package
dependency. So, upgrading will be a complex manual task.

Labels:

Tuesday, June 17, 2008

Perl Module IPK Packaging Building for OpenWRT/OptWare

After building several perl module packages for OpenWRT/optware, I found it's necessary to simplify the makefile. So, I rewrite the makefile as a template, which can be downloaded here. And now, the makefile for each module looks like this:

###########################################################
#
# perl-error
#
###########################################################

PERL-MODULE_BASENAME=perl-error
PERL-MODULE_ORG_BASENAME=Error
PERL-MODULE_SITE=http://search.cpan.org/CPAN/authors/id/S/SH/SHLOMIF
PERL-MODULE_VERSION=0.17014

PERL-MODULE_MAINTAINER?=Yale Huang

include make/perl-module.mk.inc

Labels:

Monday, June 16, 2008

ipkg-make-index Patch for TAR Issue

When I'm setting up my ipkg repository, ipkg-make-index generated following error messages:


tar: Pattern matching characters used in file names. Please,
tar: use --wildcards to enable pattern matching, or --no-wildcards to
tar: suppress this warning.
tar: *control.tar.gz: Not found in archive
tar: Error exit delayed from previous errors


It's caused by incompatible tar options. It can be resolved by following patch:


--- ipkg.py.org 2008-06-16 12:01:25.000000000 +0800
+++ ipkg.py 2008-06-16 12:10:23.000000000 +0800
@@ -93,9 +93,9 @@
self.filename = os.path.basename(fn)
## sys.stderr.write(" extracting control.tar.gz from %s\n"% (fn,))
if self.isdeb:
- control = os.popen("ar p "+fn+" control.tar.gz | tar xfzO - '*control'","r")
+ control = os.popen("ar p "+fn+" control.tar.gz | tar xzO --wildcards -f - '*control'","r")
else:
- control = os.popen("tar xfzO "+fn+" '*control.tar.gz' | tar xfzO - '*control'","r")
+ control = os.popen("tar xzO --wildcards -f "+fn+" '*control.tar.gz' | tar xzO --wildcards -f - '*control'","r")
line = control.readline()
while 1:
if not line: break
@@ -122,7 +122,7 @@
if self.isdeb:
data = os.popen("ar p "+fn+" data.tar.gz | tar tfz -","r")
else:
- data = os.popen("tar xfzO "+fn+" '*data.tar.gz' | tar tfz -","r")
+ data = os.popen("tar xz0 --wildcards -f "+fn+" '*data.tar.gz' | tar tfz -","r")
while 1:
line = data.readline()
if not line: break

Labels:

Friday, June 6, 2008

DKIM for OpenWRT

It's still possible to make my OpenWRT boxes work with DKIM. The mail server I have been using for 1 year is powered by XMail, which has no built-in support of DKIM. So, I have two can options: sendmail with a DKIM milter, or a DKIM proxy of perl. My gateway of Asus WL-500G may be not powerful enough for these services, but my Belkin with 64MB RAM should be. So, I'm setting up optware building env for customized ipkgs now. Wish it will work soon.

Labels:

Wednesday, June 4, 2008

Blocked Mails from LRFZ.com

This blog hasn't been updated for a long time. One of the reasons is mails from my mail server, the OpenWRT box, is blocked by various mail servers, including blogger.com. While mail is the most frequently used blog posting approach for me, quite some posts are blocked.So, I spent some hours on this issue, but still filled. I added SPF record for my domain, but the servers requires more than that: GMail requires DKIM, while Yahoo requires DomainKey. To match these requirements, I'll have to recompile sendmail with DKIM milter for my OpenWRT. So, I gave up at this moment and started to write this post with another mail account hosted at Google. Maybe I will build the package later.

Labels:

Friday, November 23, 2007

Installation problem for S60 3.0 SDK - Developer Discussion Boards

Installation problem for S60 3.0 SDK - Developer Discussion Boards

Symbian 的这个 Bug 还真低级. 感谢 E61 和 Opera mini, 我在火车上解决了这个问题.

Labels:

Tuesday, November 13, 2007

Terminal For OpenWrt

So, you have OpenWrt running now. Why do you still waste time on starting desktop/laptop just for an SSH terminal? How about a lightweight terminal for OpenWrt?

Dr. Philip Endecott provides a perfect tutorial about building an interactive terminal fo NSLU2. Of cause, we can do the same thing with OpenWrt. But there are more options.

At first, let's review what devices I have to attach to OpenWrt:

  • LRFZ Box with LCM and IR remote controler: I'm not good at circuit. So, I ordered my LRFZ Box from a friend in Tianjin. The price is reasonable. The first box is still under developing now. I'm not sure what kind of LCM it will be, maybe 2x20 or 4x20. The IR remote controler can also be used for character input. What ever, they are not comfortable for terminal.
  • USB keyboard: My old desktop is still working with a PS/2 keyboard now. But USB keyboard is very cheap now, about 20 RMB for a cheapest one. With about 50 RMB, I can got an IR remote keyboard with a USB based IR receiver. As Philip mentioned, it's not recommended to get a miniature one. It will be funny to move from room to room with keyboard in hand. ;)
  • Palm: Old types of Palm like Palm IIIc are cheap now. They provide higher resolution, and even colorful display, inputing capability, but are almost as cheap as a B/W character LCD. I have an old Palm IIIc. And I found some of no more than 100 RMB in taobao.com. They can be attached to routers with USB cable or USB/RS232 adapter. PalmOrb can be used for LCD simulation. Serial console should also be possible.
  • Mobile phone: It's not a news to use terminal applications for mobile phones. Various applications of telnet and SSH are available for Windows Mobile, Symbian and Motorola Linux now. But, it's still uncomfortable to type with them, even with the QWERT ones like my Nokia E61. So, I'm looking for using mobile phone for display only, and inputing with a larger keyboard. It maybe an IR keyboard attached to the mobile phone, or even attached to the router. Of cause, if you are using Blackberry, it's also a great terminal.
  • PSP: Just like the mobile phone, it's not cheap. But I have one, so do my girl friend. So, why don't use it? The same with mobile phone, PSP has SSH application now, but is hard to type. So, let's find the universal solution of attaching keyboard to them now.

I cannot describe the detail of using USB kayboard and LCM before I got them. To attach an additonal input to a terminal, it's not hard. Screen and socat can help. With screen, I can type with my Windows PuTTY terminal and watch the output with My E61 now.

Labels:

Web Service For OpenWrt

WEB and WAP are the most important interfaces for the routers. Quite some HTTP server applications are available for this purpose, and also more Web programming tools and frameworks.

Following are Web servers available in ipkg:

  • busybox - 1.5.1-1 - A userland replacement for embedded systems.
  • apache - 2.2.6-3 - The most popular web server on the internet
  • appweb - 2.1.0-1 - AppWeb is the leading web server technology for embedding in devices and applications. Supports embedded javascript, CGI, Virtu
  • awhttpd - 1.01-1 - Anti-Web webserver
  • cherokee - 0.5.6-3 - A flexible, very fast, lightweight web server.
  • lighttpd - 1.4.11-1 - A flexible and lightweight web server
  • mini-httpd - 1.19-1 - A small web server
  • nginx - 0.6.11-1 - A high perfomance http and reverse proxy server, and IMAP/POP3 proxy server.
  • php-thttpd - 2.25b-5.2.4-4 - php-thttpd is thttpd webserver with php support
  • thttpd - 2.25b-5 - thttpd is a lightweight http server
  • webif - 0.3-9 - An HTTP administrative console for OpenWrt.

Following are Web programming languages and tools available in ipkg:

  • microperl - 5.8.8-11 - Microperl.
  • php - 5.2.4-1 - The php scripting language
  • php4 - 4.3.11-2 - PHP4 Hypertext preprocessor
  • php5 - 5.0.5-1 - PHP5 Hypertext preprocessor
  • python - 2.4.4-3 - This is a package that sets up the default python.
  • python24 - 2.4.4-5 - Python is an interpreted, interactive, object-oriented programming language.
  • python25 - 2.5.1-1 - Python is an interpreted, interactive, object-oriented programming language.
  • ruby - 1.8.6.36-1 - An interpreted scripting language for quick and easy object-oriented programming.
  • webif - 0.3-9 - An HTTP administrative console for OpenWrt.

Database packages:

  • gdbm - 1.8.3-2 - GNU dbm is a set of database routines that use extensible hashing. It works similar to the standard UNIX dbm routines.
  • mysql - 4.1.20-2 - Popular free SQL database system
  • postgresql - 8.2.5-1 - PostgreSQL is a highly-scalable, SQL compliant, open source object-relational database management system
  • rrdtool - 1.2.23-2 - Round-Robin Database tool. Database collator and plotter
  • sqlite - 3.4.1-1 - SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine.

Following is a typical spec of OpenWrt supported system (my WL-500g):

  • System-On-Chip: Broadcom 4710
  • CPU Speed: 125 Mhz
  • Flash size: 4 MB
  • RAM: 16 MB
  • SWAP: 48 MB (MMC card with USB card reader

After testing various Web and Wiki frameworks, I found the major bottleneck is the memory. Following are memory usage and process list of my box:



root@KubaoGW:/usr/lib/ipkg/lists# free
total used free shared buffers
Mem: 14308 13672 636 0 836
Swap: 31288 2892 28396
Total: 45596 16564 29032
root@KubaoGW:/usr/lib/ipkg/lists# ps -ea
PID Uid VmSize Stat Command
1 root 64 S init
2 root SW [keventd]
3 root RWN [ksoftirqd_CPU0]
4 root SW [kswapd]
5 root SW [bdflush]
6 root SW [kupdated]
9 root SW [mtdblockd]
54 root SWN [jffs2_gcd_mtd4]
78 root 48 S logger -s -p 6 -t
81 root 152 S klogd
106 root 132 S /sbin/syslogd -C16 -m 0
206 root SW [khubd]
241 root SW [usb-storage-0]
242 root SW [scsi_eh_0]
333 root SW [kjournald]
358 root SW [kjournald]
565 root 80 S /bin/sh /sbin/ifup.pppoe wan
666 root 124 S /usr/sbin/dropbear
706 root 84 S httpd -p 80 -h /www -r KubaoGW
716 root 36 S telnetd -l /bin/login
767 root 200 S /usr/sbin/crond
880 nobody 132 S dnsmasq -l /tmp/dhcp.leases -K -F lan,192.168.1.2,192
1047 root 52 S vtund[s]: waiting for connections on port 5050
1140 root 136 S /usr/sbin/ez-ipupdate -d -F /var/run/ez-ipupdate.pid
5763 root 132 S /sbin/wifi
27268 root 76 S /usr/sbin/dropbear
27269 root 112 S -ash
1561 root 116 S /usr/sbin/dropbear
1589 yale 112 S -ash
7336 root 520 S /mnt/disc0_1/var/MailRoot/bin/XMail
7345 root 168 S didiwiki
7346 root 520 S /mnt/disc0_1/var/MailRoot/bin/XMail
7347 root 520 S /mnt/disc0_1/var/MailRoot/bin/XMail
7348 root 520 S /mnt/disc0_1/var/MailRoot/bin/XMail
7349 root 520 S /mnt/disc0_1/var/MailRoot/bin/XMail
7350 root 520 S /mnt/disc0_1/var/MailRoot/bin/XMail
7351 root 520 S /mnt/disc0_1/var/MailRoot/bin/XMail
7352 root 520 S /mnt/disc0_1/var/MailRoot/bin/XMail
7353 root 520 S /mnt/disc0_1/var/MailRoot/bin/XMail
7354 root 520 S /mnt/disc0_1/var/MailRoot/bin/XMail
8648 root 236 S /usr/sbin/pppd nodetach plugin rp-pppoe.so connect /b
8729 root 168 S miniupnpd -i ppp0 -a 192.168.1.1 -p 5000 -U -B 131072
8779 root 432 S

So, only very few free memory are available now. Druing my test, MoinMoin, CakePHP, Django all cost over 4MB memory can cause swap thrash. And even worse, it's found lighttpd has a bug, which hangs it up when reading slow fds. I used to wait for minutes for MoinMoin diaplaying one page. But when I executed the same test with my WL-HDD with most services shutted down, it's about 4 ~ 5 times faster. But I don't want to deploy one box for each searvice. And you know, MySQL and Postgres also require MBs of memory.

So, the fundemantal strategy is, to limite the memory footprint. Comparing Django with CakePHP, I prefer the latter, which may be slower, but releases memory after the request is replied. But Webif + Sqlite is still recommended for most cases, which is almost the lightest solution. And it will be the fundemantal framework of Web service of LRFZ box. Busybox is powerful enough for most general usage. But it's lack of the feature of virtual host. Lighttpd will be great once the above bug is fixed (according to Lighttpd's trac, it should be version 1.5).

Alternatively, it's also possible to engage the physical memroy size. Fortunately, I found a retailer which provides routers with 64MB memory. I wish Django and MoinMoin will run smoothly on it.

Labels:

Monday, November 12, 2007

WL-HDD Crashed

Last night, I found my WL-HDD crashed. I used to think my mother unplugged the power cable. But this morning I called my mother and asked her to check both the power cable and ethernet cable. They are both ok. I checked the Wifi signal and found the Cell of WL-HDD. But there's no packet from it, neither from cable or wireless. So, it seems that the box was down.

So, which part is wrong? The hard disk? I searched for document about hard disk life, and found some read laptop disk cannot work continuously for days. Actually, I just kept it running for over one week. :(

Whatever, I won't be able to check it by hand until this weekend. So, what a robust system my WL-500G is, which has run for months already.

Update: I was wrong. I updated the gateway WL-500G tonight and found WL-HDD. So, maybe the issue was caused by WL-500G? Something wrong with the bridge module? Not sure, just wait for reproducing.

Labels:

Sunday, November 11, 2007

OpenWrt Throughput Over WDS

Last weekend, I set up WDS with my WL-500G and WL-HDD. Following are my tips for setting up WDS with WPA:

  • Assign the same SSID and channel number for devices. These parameters are used by WPA.
  • Set a positive value for WDS watchdog(wl0_wdstimeout). Or the network will be broken soon.

Then I enabled 802.11g for both devices(OpenWrt uses 802.11b by defaule), and start Samba at WL-HDD. The Windows client was connected to WL-500G via 802.11g. When coping files from and to WL-HDD, the througput were both about 1MBps. Not exciting, but acceptable for playing most RMVB.

Labels:

Ghostscript Benchmark For OpenWrt

I tested Ghostscript with my WL-500G and WL-HDD. It's for the coming integration of lbp660 + gs + cups. The test shows great speed gap between the two machines. But it's not caused by the hardware specs, actually they have the same CPU, but by the memory usage.

WL-500G, my gateway server, runs network services including lighttpd, xmail, didiwiki, vtund, dnsmasq, and dropbear:

root@OpenWrt:/mnt/disc0_1/home/yale# time gs -dNOPAUSE -dPARANOIDSAFER -dBATCH -r600x600 -sDEVICE=pbmraw -sOutputFile=output.pbm output.ps
AFPL Ghostscript 8.50 (2004-12-10)
Copyright (C) 2004 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
real 2m 32.57s
user 0m 9.87s
sys 0m 23.93s
root@OpenWrt:/mnt/disc0_1/home/yale# free
total used free shared buffers
Mem: 14308 12312 1996 0 684
Swap: 31288 3652 27636
Total: 45596 15964 29632
root@OpenWrt:/mnt/disc0_1/home/yale# cat /proc/cpuinfo
system type : Broadcom BCM947XX
processor : 0
cpu model : BCM4710 V0.0
BogoMIPS : 82.94
wait instruction : no
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : no
hardware watchpoint : no
VCED exceptions : not available
VCEI exceptions : not available

WL-HDD, runs services nfsd, smbd and dropbear:

root@KubaoHDD:/home/root$ time gs -dNOPAUSE -dPARANOIDSAFER -dBATCH -r600x600 -sDEVICE=pbmraw -sOutputFile=output.pbm output.ps
AFPL Ghostscript 8.50 (2004-12-10)
Copyright (C) 2004 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
real 0m 32.50s
user 0m 9.84s
sys 0m 21.00s
root@KubaoHDD:/home/root$ free
total used free shared buffers
Mem: 14308 9172 5136 0 228
Swap: 72284 1572 70712
Total: 86592 10744 75848
root@KubaoHDD:/home/root$ cat /proc/cpuinfo
system type : Broadcom BCM947XX
processor : 0
cpu model : BCM4710 V0.0
BogoMIPS : 82.94
wait instruction : no
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : no
hardware watchpoint : no
VCED exceptions : not available
VCEI exceptions : not available

The .ps file is only a 2-page text file. 32.50s costed by WL-HDD is still acceptable, while 2m 32.57s of WL-500G is much longer than expected. The major difference between these two machines is the memory usage. For a wireless router, gs consumes quite some memory(up 5MB during this test), and causes frequent memory switching when the system is short of memory. I'm not sure whether the IDE based swap of WL-HDD helps againt the MMC card based swap for WL-500G.

Unfortunately, the Canon LBP-660 printer I'm going to deploy is LPT based, which can only fit with WL-500G. So, it seems that I have to migrate some services to WL-HDD to save some memory on WL-500G for the print service.

----- End forwarded message -----

Labels:

Thursday, November 8, 2007

家里的无线网络被盗用了

监视网关的流量时发现有奇怪的内部 IP. 先琢磨了一下是不是我某个古怪的设备开在那儿忘了, 没有. 查 ARP, 奇怪的 IP 还挺活跃, 看 dhcp.leases 更是找到了三个有问题的 MAC, 一台是联想的, 一台叫 Freeman! Gateway 的 Wifi 可是 WAP 的啊, 现在技术这么先进 WAP 也靠不住?

冷静了一下, 仔细看看, 有问题的 IP 在以太口上. 以太口? 我的 WL-HDD 啊. 上周走的匆忙, WL-HDD 的 Wifi 没加密. 先把 Wifi 口从网桥摘掉, 等回家设加密吧. 我真是好人啊, 不然继续让这些坏蛋用, dump 下来把密码全找出来. 只是估计盗用的家伙也不是美女, 就没这个兴趣了.

Labels:

Wednesday, November 7, 2007

Ghostscript Benchmark For OpenWrt

I tested Ghostscript with my WL-500G and WL-HDD. It's for the coming integration of lbp660 + gs + cups. The test shows great speed gap between the two machines. But it's not caused by the hardware specs, actually they have the same CPU, but by the memory usage.

WL-500G, my gateway server, runs network services including lighttpd, xmail, didiwiki, vtund, dnsmasq, and dropbear:

root@OpenWrt:/mnt/disc0_1/home/yale# time gs -dNOPAUSE -dPARANOIDSAFER -dBATCH -r600x600 -sDEVICE=pbmraw -sOutputFile=output.pbm output.ps
AFPL Ghostscript 8.50 (2004-12-10)
Copyright (C) 2004 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
real 2m 32.57s
user 0m 9.87s
sys 0m 23.93s
root@OpenWrt:/mnt/disc0_1/home/yale# free
total used free shared buffers
Mem: 14308 12312 1996 0 684
Swap: 31288 3652 27636
Total: 45596 15964 29632
root@OpenWrt:/mnt/disc0_1/home/yale# cat /proc/cpuinfo
system type : Broadcom BCM947XX
processor : 0
cpu model : BCM4710 V0.0
BogoMIPS : 82.94
wait instruction : no
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : no
hardware watchpoint : no
VCED exceptions : not available
VCEI exceptions : not available

WL-HDD, runs services nfsd, smbd and dropbear:

root@KubaoHDD:/home/root$ time gs -dNOPAUSE -dPARANOIDSAFER -dBATCH -r600x600 -sDEVICE=pbmraw -sOutputFile=output.pbm output.ps
AFPL Ghostscript 8.50 (2004-12-10)
Copyright (C) 2004 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
real 0m 32.50s
user 0m 9.84s
sys 0m 21.00s
root@KubaoHDD:/home/root$ free
total used free shared buffers
Mem: 14308 9172 5136 0 228
Swap: 72284 1572 70712
Total: 86592 10744 75848
root@KubaoHDD:/home/root$ cat /proc/cpuinfo
system type : Broadcom BCM947XX
processor : 0
cpu model : BCM4710 V0.0
BogoMIPS : 82.94
wait instruction : no
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : no
hardware watchpoint : no
VCED exceptions : not available
VCEI exceptions : not available

The .ps file is only a 2-page text file. 32.50s costed by WL-HDD is still acceptable, while 2m 32.57s of WL-500G is much longer than expected. The major difference between these two machines is the memory usage. For a wireless router, gs consumes quite some memory(up 5MB during this test), and causes frequent memory switching when the system is short of memory. I'm not sure whether the IDE based swap of WL-HDD helps againt the MMC card based swap for WL-500G.

Unfortunately, the Canon LBP-660 printer I'm going to deploy is LPT based, which can only fit with WL-500G. So, it seems that I have to migrate some services to WL-HDD to save some memory on WL-500G for the print service.

Labels:

Monday, November 5, 2007

Slugs, Solar Powered

Slugs

如果说 SlugTerm 变态的话, SolarSlug 就是太变态了. 俺去淘宝看看太阳能电池板多少钱.

看见另一个变态的哥们搞了一套 Solar Powered Modem + Wireless Router, 花了好几百美刀,最后算了个笔帐,貌似有生之年这笔投资都不能从电费上赚回来了。咔咔,真是符合俺们绿色环保加 LRFZ 的风格啊。

Labels:

Walk Around HTTP Requests Hijacked by China Telecom

It's well known that China Telecom hijacks DNS requests. Even more, Shanghai Telecom hijacks HTTP requests after any ADSL connection is established. So, my dynamic DNS registion always fails. Even with option "retrys" set in ez-ipupdate.conf, it still fails.

So, I implemented a script to walk around the hijacked requests:

#!/bin/ash

#
# fuck_china_telecom.sh
# Walk around HTTP requests hijacked by China Telecom.
#

TEST_FILE=`mktemp /tmp/fuck_china_telecom.XXXXXX`
TEST_PATTERN='dyndns'
TEST_URL='http://members.3322.org'
RETRIES=30

C=0
while [ $C -lt $RETRIES ]; do
wget -O $TEST_FILE $TEST_URL
grep $TEST_PATTERN $TEST_FILE && rm $TEST_FILE && return 0
rm $TEST_FILE
let C=$C+1
sleep 1
done

return 1

And call it in my ez-ipupdate script for iface hotplug (/etc/hotplug.d/iface/10-ez-ipupdate):

. /etc/functions.sh
NAME=ez-ipupdate
CONFIG=/etc/$NAME.conf
COMMAND=/usr/sbin/$NAME
[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
[ -x $COMMAND ] && [ -r $CONFIG ] && {
IFNAME=$(nvram get ${INTERFACE}_ifname)
/usr/local/bin/fuck_china_telecom.sh 2>&1 | logger -t $NAME
$COMMAND -c $CONFIG -i $IFNAME 2>&1 | logger -t $NAME
} &
}

Labels:

Native Development with OpenWrt

For years, I haven't compiled code with a CPU of 125MHz. Even more, a MIPS chip. Actually, it's quite slow, especially when the system is short of memory. But, it's interesting

It's so glad to find some other interesting guys working with NSLU2, who set up their development env with native compilers and distcc. A compiler farm in house, how LRFZ it is!

Labels:

WIKI.LRFZ.COM

WIKI.LRFZ.COM works now. I got Didiwiki at my gateway. It's small and fast, implemented with C. Please access it at http://wiki.lrfz.com .

Labels: , ,

Unreliable UDP via China Telecom

Everybody knows that UDP is unreliable. But you cannot how unreliable it is via China Telecom. It's known that Shanghai Telecom limits the concurrent connection number per user. But now, it's found that they also filter UDP packets for unknown reasons.

I have a VPN between my machines in Nanjing and Shanghai. It was based on UDP. For months, I suffer the ill-behaved VPN, especially when transfer files from Shanghai to Nanjing. Last night, I tuned the MTU of VPN device to a smaller number and found scp worked better.

But today, when I was trying to write a file via NFS from Shanghai to Nanjing, it always failed. So, I dumped packets at the client, the server and also the gateway at Nanjing. I found a UDP packet was always lost after sending from SH PPPoE interface!


08:45:19.253691 IP (tos 0x0, ttl  64, id 11499, offset 0, flags [DF], proto: UDP (17), length: 942) 218.79.145.142.2051 > 58.217.165.43.5050: UDP, length 914

It's the raw PPPoE interface, nothing to do with VPN. So, the only possible reason is that the packet was dropped somewhere after it was sent from my SH box, and before it reached at
my NJ box. China Telecom.

So, the only thing I can do is to switch the VPN to TCP based. But I don't like this mode. You know, it requires extra handshake on error.

Labels:

Sunday, November 4, 2007

USB/IDE/NFS Storage Based OpenWRT Distribution

During the last few days, I got my WL-HDD work with root fs on IDE. For the coming LRFZ boxes, I will deploy root fs on USB/IDE/NFS for all of them. Even the multi dest ipkg and ipkg-link work for my WL-500G, but it's really troublesome to take care of the links and mounts. And the ROM size of 4MB is so small comparing to the current USB/IDE disks. So, just boot with ROM and forget it.

There's no doubt that root fs on USB & IDE will work. But NFS still needs testing. Even more, I found a doc for NSLU2 about swap over NFS. I think it will work. So, NFS will be a good solution for the LIGHTEST box in OpenWRT clusters.

Another pending issue is kernel image. While the whole root fs is in the USB/IDE/NFS storage, kernel image, basic kernel modules and utils are still in ROM. ROM refreshing is still required for kernel upgrading.

Labels:

Esmtp & Mutt Configuration for OpenWRT

The final configurations are quite simple. But these light-weight applications did cost me minutes to google the documents.

My .esmtprc:

hostname=www.lrfz.com:25
username="xxx@lrfz.com"
password="xxx"
mda="/mnt/disc0_1/usr/bin/procmail -d %T"

I'm not sure whether the mda option is must-have.

My .muttrc:

set sendmail = "/mnt/disc0_1/opt/bin/esmtp -v -X ~/.esmtplog"
set pop_host = "pop://www.lrfz.com"
set pop_user = xxx
set spoolfile = "pop://www.lrfz.com"
#set folder = "pop://www.lrfz.com"

It's recommanded to do these with a normal user instead of root. You should be able to set it up for your mailboxes like Gmail in minutes.

Labels:

WL-HDD: Root FS on Hard Disk

Well, I got my WL-HDD work with root fs on hard disk, without crash it. ;)

A post at OpenWRT forum did help. But my /sbin/init script is still different from it. Following is my script:


#!/bin/sh

HDD_MNT_POINT=/mnt/hda1
ORG_ROOT=/mnt/hda1/mnt/jffs
DEV_HDA=/dev/hda
DEV_HDA1=/dev/hda1

mount_hdd() {
# [ -z "$boot_dev" ] && return 1

# install modules needed for ide and the ext3 filesystem
for module in ide-core pdc202xx_old ide-detect ide-disk ext2 jbd ext3; do {
insmod $module || return 1
}; done

# this may need to be higher if your disk is slow to initialize
sleep 4

mknod $DEV_HDA b 3 0 || return 1
mknod $DEV_HDA1 b 3 1 || return 1

mount $DEV_HDA1 $HDD_MNT_POINT -t ext3 || return 1
# [ -x "$HDD_MNT_POINT/sbin/init" ] || return 1
# pivot_root "$HDD_MNT_POINT" "$ORG_ROOT" || return 1

return 0
}

switch_root() {
if [ -x "$HDD_MNT_POINT/sbin/init" ]; then
mount -o move /proc "$HDD_MNT_POINT/proc" || return 1
pivot_root "$HDD_MNT_POINT" "$ORG_ROOT" || return 1

mount -o move "/mnt/jffs/dev" /dev
mount -o move "/mnt/jffs/tmp" /tmp
mount -o move "/mnt/jffs/jffs" /jffs 2>&-
#mount -o move "/mnt/jffs/sys" /sys 2>&-
else
return 1
fi

return 0
}

# change nvram variable 'boot_dev' to your root filesystem
#boot_dev=`nvram get boot_dev`

mount_hdd && switch_root
# switch_root

# finally, run the real init
exec /bin/busybox init


Of cause, before booting with this init script, I created the folders in both jffs and hd:

* Mount point in jffs for hd:

mkdir /mnt/hda1

* Mount hd and create the mount point for jffs:

mount -t ext3 /dev/ide/host0/bus0/target0/lun0/part1 /mnt/hda1
mkdir -p /mnt/hda1/mnt/jffs

* Umount hd:

umount /mnt/hda1


Of cause, fdisk, mkfs and file copying have been done before I executed the above operations.

UPDATE: Actually, I developed a new version of the above script for HDD and NFS soon after the previous one.


#!/bin/sh
#/jffs/sbin/init.disk

DEFAULT=/etc/default/init.disk

#DISK_MNT_POINT=/mnt/hda1
#JFFS_MNT_POINT=/mnt/jffs
#ORG_ROOT=$DISK_MNT_POINT/$JFFS_MNT_POINT
#DEV_DISK=/dev/hda
#DEV_PARTITION=/dev/hda1
#DEV_MAJOR=3
#DEF_MINOR=1
#FS_TYPE=ext3
#MODULES='ide-core pdc202xx_old ide-detect ide-disk ext2 jbd ext3'
#MODULE_LOAD_WAIT=4

[ -f $DEFAULT ] && . $DEFAULT

mount_disk() {
# [ -z "$boot_dev" ] && return 1

# install modules needed for ide and the ext3 filesystem
for module in $MODULES; do {
insmod $module || return 1
}; done

# this may need to be higher if your disk is slow to initialize
sleep $MODULE_LOAD_WAIT

# mknod $DEV_DISK b 3 0 || return 1
# mknod $DEV_PARTITION b $DEV_MAJOR $DEV_MINOR || return 1

mount $DEV_PARTITION $DISK_MNT_POINT -t $FS_TYPE || return 1
[ -x "$DISK_MNT_POINT/sbin/init" ] || return 1
pivot_root "$DISK_MNT_POINT" "$ORG_ROOT" || return 1

return 0
}

switch_root() {
if [ -x "$DISK_MNT_POINT/sbin/init" ]; then
mount -o move /proc "$DISK_MNT_POINT/proc" || return 1
pivot_root "$DISK_MNT_POINT" "$ORG_ROOT" || return 1

mount -o move "$JFFS_MNT_POINT/dev" /dev
mount -o move "$JFFS_MNT_POINT/tmp" /tmp
mount -o move "$JFFS_MNT_POINT/jffs" /jffs 2>&-
#mount -o move "$JFFS_MNT_POINT/sys" /sys 2>&-
mount -o move "$JFFS_MNT_POINT/rom" /rom 2>&-
else
return 1
fi

return 0
}

# change nvram variable 'boot_dev' to your root filesystem
#boot_dev=`nvram get boot_dev`

mount_disk && switch_root
# switch_root

# finally, run the real init
exec /bin/busybox init


The configuration file for USB disk:


#/jffs/etc/default/init.disk.usb
DISK_MNT_POINT=/mnt/disc3_1
JFFS_MNT_POINT=/mnt/jffs
ORG_ROOT="$DISK_MNT_POINT/$JFFS_MNT_POINT"
#DEV_DISK=/dev/hda
DEV_PARTITION=/dev/root_disk
DEV_MAJOR=8
DEF_MINOR=49
FS_TYPE=ext3
MODULES='usbcore usb-ohci scsi_mod sd_mod usb-storage ext2 jbd ext3'
MODULE_LOAD_WAIT=8

Labels:

Wednesday, October 31, 2007

Berggi Voice to Email freeware for Symbian phone, SymbianOS s60, s80, UIQ free downloads.

Berggi Voice to Email freeware for Symbian phone, SymbianOS s60, s80, UIQ free downloads.

连起来, 连起来. 用这个发 mail message, 用 OpenWRT 放, 是多么的 LRFZ 啊.

Labels:

Reuse your old Palm as Serial Console - neophob

Reuse your old Palm as Serial Console - neophob

环素那句话: 变态的人到处都有, 而我不过是其中一个.

Labels:

PalmOrb: Use your PalmOS PDA as a LCD status display via serial, USB, BlueTooth or IR

PalmOrb: Use your PalmOS PDA as a LCD status display via serial, USB, BlueTooth or IR

沉睡多年的 Palm IIIc又能用上了. 加个 USB-Serial 线就能接上 OpenWRT. 价格? 淘宝 Palm IIIc 不到 200, 线也就 20 多. 彩色触摸屏 LCD 单买可能还不止这么多呢.

Labels:

Tuesday, October 30, 2007

You have no idea how LRFZ can OpenWRT be.

那个那个,有了 Unslung 的同仁的帮忙,俺的 OpenWRT 正在变得日益 LRFZ 。Python 2.5 已经装了,qEmacs 也不错,CVS 的任务也给了我的 Asus WL-500G,现在我正在装 MediaWiki,咔咔。刚订了一个 WL-HDD ,真正让我犹豫了一会儿的是两个问题:这玩意只有一个以太口;2.5 寸硬盘的价格(160G)比 WL-HDD 还要贵出近一倍。不过后来还是决心买了,毕竟以后家里少不了一个低功耗存储服务器。

Labels:

Unslung Packages for OpenWRT

Index of /feeds

Including a full build Python 2.5 and CVS! So, I can host my projects with OpenWRT now. And a lot of Python apps will be workable.

Labels:

Monday, October 29, 2007

D2D For Entertainment

Linux software turns NAS devices into media servers

WL-HDD is a good candidate for wireless data storage, even it's a little slow. What else do I want? A/V output and codec. Try set-box like DreamBox? Or PS3? Or just a Xbox?

Labels:

Friday, March 16, 2007

WEB Interface for MPC

I developed a simple WEB interface for MPC on OpenWRT tonight. Now, I can control the music player(MPD) on WL-500G with any WEB browser, including my Nokia E61 cell phone! So, I'm sitting on bed, controling the player with my cell phone. I'll take some pics later and post them here.

Labels:

Tuesday, March 13, 2007

Unsupported USB Audio Device

I was very disappointed to find the USB audio stick I purchased days ago is not supported by the pre-built kernel modules. I don't want to hack the source and rebuild the whole system now. So I stripped strings from the kernel module, listed the supported USB audio devices, and search them at taobao.com. Finally I found a type of second-hand USB audio adapter. It's cheap, so I purchased two.

Labels:

USB Audio & MPD

I just found a workable usb audio kernel package for OpenWRT rc6, I'll try my USB audio card later. MPD is also a great project, and some clients of WEB/WEB/Symbian are already avaliable. So, it won't be too difficult to control it with my Nokia E61.

Labels:

Sunday, March 11, 2007

Router Reinstalled

Yesterday, I spent hours on reinstalling the router. It was almost bricked after I flush it with the snapshot version of OpenWRT of Linux kernel 2.6 . There's no response when setting IP with tftp. But I finally get the original 2.4 firmware uploaded permanentely.

Labels:

Saturday, March 10, 2007

1G MMC Card

I just replaced the original 64MB SD card with an MMC card of 1GB. More applications will be installed and more virtual hosts will be avaliable later.

Labels:

令人发指.com@OpenWRT

呵呵,令人发指.com 开张了。比较有趣的是发布这个 blog 的台服务器只值不到300人民币,加上读卡器和 Mini SD 卡也不到 400 块,主要功能是作我的无线路由器 —— 这是一台运行 OpenWRT 的 Asus WL-500G(还是 WL-500B 改成的)。这样一台服务器深刻的表现了这个 Blog 的主题 —— 令人发指啊。要知道,这个 WL-500G 只有 4MB Flash ROM,16MB RAM,还有 16MB Swap 是在 SD 卡上! 这块 SD 卡呢,也只有 64MB,方便的时候俺再换一块 1GB 的。这玩意除了便宜、功能多之外,还有个很大的好处 —— 低功耗,总共就 10W 。连风扇都没有,一年到头全开着也没问题。

Labels: