Saturday, February 28, 2015

Areca + Opensftp 在 Openwrt router 做Backup Server


Openwrt + Setup Openssh-sftp:

Areca 是一個功能頗全面的backup software ,不過要自訂很多選項,而且要建立batch file 同用schedule task。比較麻煩。不過好處是可以有不同類型的backup方式。又支援sftp.






Saturday, February 07, 2015

Openwrt in Buffalo WZR-HP-G300NH2 問題

安裝了Openwrt 大約三個多月,有一天突然上不到網。發現Openwrt 不能於WAN 卡攞ip, 其他內聯網機也取不到ip ,所以上不到網也連不到其他機。

1. 每部機硬入IP 可以連上network, 重裝後wan 卡可攞external IP 但仍未可以 Lan 用dhcp

於TP-Link WDR3600 安裝OpenWRT

TP-Link Webpage

OpenWRT TPLink WDR3600


只要download 左個file, 用網頁內的firmwire upload 上去即可。

比起要用tftp method .. TP-Link這個方法簡直方便到無論


FailSafe Mode in Buffalo WZR-HP-G300NH2


Note: There is a reset button at the bottom of the router. You can use a pen to prick that button.

1. Set your PC ip to Netmask: Gateway:
2. Install telnet in your PC (if you don't have, try putty)
1. Remove the power cable.
2. Wait 30 secs and connect the power again.
3. When the red light in the front panel start to blink, prick the reset button
4. The red light will blink more faster, telnet in your router

root@openwrt:~# mount_root
root@openwrt:~# first_boot
root@openwrt:~# mtd -r erase rootfs_data

Monday, December 29, 2014

OpenWrt 筆記

Important note before installation

Officeal Failsafe:
My Failsafe Note:

1. Secure Your Router

Read This:

Create a non-privileged user in OpenWrt

root@openwrt:~# opkg update
root@openwrt:~# opkg install shadow-useradd
root@openwrt:~# useradd nicolaus
root@openwrt:~# passwd nicolaus
root@openwrt:~# mkdir /home/nicolaus
root@openwrt:~# vi /etc/passwd


root@openwrt:~# opkg install sudo
root@openwrt:~# visudo


Install sftp function - add to dropbear

root@openwrt:~# opkg install openssh-sftp-server

Download Useful tools

root@openwrt:~# opkg install vim fdisk e2fsprogs

買了張32g usb , 要加大router 容量以供proxy 使用

Prepare your USB

雖然插了USB 這時候還未認到. 要加入USB mod

USB 1.x and 2.x

root@openwrt:~# opkg update
root@openwrt:~# opkg install kmod-usb-storage
root@openwrt:~# opkg install kmod-usb-uhci
root@openwrt:~# insmod usbcore
root@openwrt:~# insmod uhci

root@openwrt:~# opkg install kmod-usb2
root@openwrt:~# insmod ehci-hcd

root@openwrt:~# opkg install block-mount
root@openwrt:~# opkg install kmod-fs-ext4
root@openwrt:~# opkg install libext2fs

我試左好耐都認唔到個USB ,原來係未有認到個format, 所以要format左 USB 先認到。

root@openwrt:~# mkfs.ext4 /dev/sda1
root@openwrt:~# mount  /dev/sda1 /mnt[]=rootfs

root@openwrt:~# mkdir -p /tmp/cproot
root@openwrt:~# mount --bind / /tmp/cproot
root@openwrt:~# tar -C /tmp/cproot -cvf - . | tar -C /mnt -x
root@openwrt:~# umount /tmp/cproot

root@openwrt:~# vi /etc/config/fstab
config mount
    option target   /
    option device   /dev/sda1
    option fstype   ext4
    option options  rw,sync
    option enabled  1
    option enabled_fsck     0

root@openwrt:~# reboot
我用的方法是Pivot-root done.

安裝Proxy server

呢個係筆記,當然試完之試,第一次我你用squid + Dansguardian + openDNS 不過反應唔係太好,Squid 功能大之餘,不過因為用usb read write cache file, 速度其慢,故要改做no cache mode 先快一點。因為上網速度的樽頸己去左寫落usb 到。 Dansgardian 有content filter 殺手之稱,不過不用左,可能我setup 唔全面,好多圖比佢去左,變得好怪。 OpenDNS 原理係好,不過太慢,可能我要clone 左佢個dns database 落嚟自己個openwrt 先可行。

Test #1: Squid

Transparent Proxy using Squid
OpenWRT Squid transparent configuration


root@openwrt:~# mkdir /var/squid/cache
root@openwrt:~# mkdir /var/squid/logs
root@openwrt:~# chown -R nobody:nogroup /var/squid

root@openwrt:~# vi /etc/squid/squid.conf

#accesslog problem

setup squid boot script into /etc/init.d

remember the don't set it transparent

root@openwrt:~# /etc/init.d/squid enable
root@openwrt:~# /etc/init.d/squid start


Test #1: Install dansguardian

root@openwrt:~# opkg install dansguardian

setup dansguardian at /var/dansguardian/

setup iprule to redirect to  Web -> Dans -> Squid -> Internet

vi /etc/config/firewall

redirect ip from port 80 to 8080

Improve performance of Dansguardian & Squid

- 發現增加了DansGuardian 的conf performance 不是增加太多,原來是router 本身的Hard ware 同 usb 的read write speed 太慢,故以關掉caching 反而可以提速。

如果用 DansGuardian+Squid 在squid.conf 內的 http_port 就要唔用transparent. 若果不用Dansguardian 就要加返,如果唔係會出Error
2014/12/13 15:22:43| clientTryParseRequest: FD 12 ( Invalid Request

Test #1: 安裝OpenDNS

Test #2: Privoxy

root@openwrt:~# opkg update
root@openwrt:~# opkg install privoxy

root@openwrt:~# vi /etc/privoxy/config

    accept-intercepted-requests 1

root@openwrt:~# /etc/init.d/privoxy enable
root@openwrt:~# /etc/init.d/privoxy start

root@openwrt:~# vi /etc/config/firewall
#transpart proxy for privoxy

config redirect
    option proto 'tcp'
    option target 'DNAT'
    option dest 'lan'
    option name 'transparent-proxy for HTTP'
    option src 'lan'
    option dest_port '8118'
    option src_dport '80'
    option dest_ip ''    
    option src_dip '!'

Install samba

root@openwrt:~# opkg update
root@openwrt:~# opkg install luci-app-samba
root@openwrt:~# opkg install samba36-server

root@openwrt:~# vi /etc/config/firewall (follow

config 'rule'
    option 'src' 'lan'
    option 'proto' 'udp'
    option 'dest_port' '137-138'
    option 'target' 'ACCEPT'

config 'rule'
    option 'src' 'lan'
    option 'proto' 'tcp'
    option 'dest_port' '139'
    option 'target' 'ACCEPT'

config 'rule'
    option 'src' 'lan'
    option 'proto' 'tcp'
    option 'dest_port' '445'
    option 'target' 'ACCEPT'

root@openwrt:~# vi /etc/config/samba

# change workgroups

# enable start up when reboot

root@openwrt:~# /etc/init.d/samba enable
root@openwrt:~# /etc/init.d/firewall restart
root@openwrt:~# /etc/init.d/samba start

Install Bittorrent Client - Transmission

root@openwrt:~# opkg update
root@openwrt:~# opkg install transmission-daemon
root@openwrt:~# opkg install transmission-cli
root@openwrt:~# opkg install transmission-web
root@openwrt:~# opkg install transmission-remote
root@openwrt:~# opkg install luci-app-transmission

got some problem
Dec 13 23:34:04 OpenWrt daemon.err transmission-daemon[17437]: UDP Failed to set receive buffer: requested 4194304, got 327680 (tr-udp.c:77)
Dec 13 23:34:04 OpenWrt daemon.err transmission-daemon[17437]: UDP Failed to set send buffer: requested 1048576, got 327680 (tr-udp.c:88)

root@openwrt:~# vi /etc/sysctl.con

#for bittorrent
    net.core.rmem_max = 4194304
    net.core.wmem_max = 1048576
不過在 /etc/sysctl.conf加都冇用,因為openwrt 每次reboot 都overwrite (see 要在/etc/init.d/transmission 的startup script 內加 [...] start() { #新加入的 sysctl -w net.core.rmem_max=4194304 sysctl -w net.core.wmem_max=1048576 #新加入的要在start tranmission 前run config_load 'transmission' config_foreach start_instance 'transmission' } [...] 有時transmission 自動死機 root@OpenWrt:/etc# vi /root/ !/bin/sh if [ -f /mnt/usb/USB_DISK_NOT_PRESENT ]; then echo [Panic!] exit as no usb mount!! exit fi VAR=`ps | grep transmission | grep -v grep` if [ -z "$VAR" ]; then #if no transmission found -> start transmission /etc/init.d/transmission start fi

Install minidlna

opkg install minidlna
opkg install luci-app-minidlna

不過發現不太支援 mp4

在Samsung Galaxy S Advance 安裝CM11

部手機太慢了,而且已很久沒有update, 想舊機再番新。

1. 於
2. 下載Roms and Gapps 並儲存於SD 卡root 內
3. Reboot in Recovery Mode 要volume up + power + home 按至綠公仔出先得
4. Wipe data /factory reset  - volume 上下, power 決定
5. 安裝 同 gapps. Gapps 要在 下載
6. Reboot

Google Play要安裝新版本,可自行google 一下

Saturday, November 29, 2014

BB100 + BBTV + Router + Magic TV

剛剛轉了用BB100 ,送一了個BBTV 放在廳中看電視,另師傅拉一條線入書房連router 上網用。

知道港視開張了,而家中的Magic TV 3300D 開始支援港視,所以就想一想如何實現Magic TV 上網大計。

1. 用BBTV + Router (openwrt) 做WDS 而用WDS連入Magic TV同電視 (不過WDS要夾,openwrt 最好同openwrt 先得,BBTV 冇試過)
2. 買過新的Magic TV USB 原來唔係隻隻夾。 (最貴)
3. 將原來的Router (openwrt) 做Client Mode 拉Cable 。(試過,不過上唔到網)
4. 看這篇文,想過可能要用舊Router 轉做Switch 在BBTV 前做分線。(我家中有共有兩個舊Router) How to Reuse your old Wi-Fi route as a Network Switch?

最後我想過一個問題,HKBB 有一條線入家中的BBTV 機頂盒,而那條Lan 線最尾是開义的,當時我想莫非BBTV這麼強,需要雙Cable 來支援。

原來不是的,原來BBTV 偷線用,將一條Cable 又做入屋又做入房。 原來一條Lan Cable 有8條線,基本上用4條就夠,所以將其中4條由機房入BBTV 而將同一條線的其餘4條做由BBTV到機房。所以條線轉做兩頭蛇。

最後發現原來可以將個Router 放在 BBTV 後面 之後再接返入到應該插BBTV Lan位條線插入Router Lan 位即可。

再Diable BBTV 本身個Wi-Fi 即可成屋同一個網絡了。


Monday, July 14, 2014

Scribus 內使用中文字型 Winxp+Scribus



中文字型只可以選 SimHei, 其他PMingLiu 用不到。不知何解。

用Scribus 用來做一本約百多頁的雜誌(內部用),發現基本功能不錯,只不過中文對位有很大改善的空間,若想左右對齊是做不到的,很多是右手邊會對不好。



Tuesday, June 24, 2014

Delete Cache in Samsung Galaxy S Advance

Software mathod

Hard Ware Method

How to Boot Into Samsung Galaxy S Advance Recovery Mode

 入左Recovery mode 之後
用Volumn 上下,選wipe cache partition 按power 確定
之後選reboot 即可
[Guide] Rebooting into Recovery Mode for the Galaxy S2, S3, and Tab2

Tuesday, May 28, 2013

[Excel] VBA Marco - Resizing all image in worksheet

想將網上一張表格抄在Excel 內用,而這張資料表有很多圖片。貼在Excel Worksheet 內全部放大了。