2007年8月30日 星期四

Fonera GCC IPK

root@OpenWrt:~# ipkg install libgcc_4.1.1-8_mips.ipk
Upgrading libgcc on root from 3.4.6-8 to 4.1.1-8...
Configuring libgcc
Done.
WARNING: Unable to remove temporary directory: /tmp/ipkg-rDpCrp: Directory not empty


網路上找到的
有空來試試~~

Qmail On Linux

wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz
wget http://shupp.org/software/netqmail-1.05.tar.gz
//wget http://shupp.org/patches/qmail-toaster-0.8.3.patch.bz2
wget http://shupp.org/software/vpopmail-5.4.13.tar.gz
//wget http://shupp.org/patches/vpopmail-5.4.13-cumulative-1.patch
//wget http://shupp.org/software/autorespond-2.0.4.tar.gz
//wget http://shupp.org/patches/autorespond-2.0.4-2.0.5.patch
//wget http://shupp.org/software/qmailadmin-1.2.10.tar.gz
//wget http://shupp.org/software/qmailadmin-help-1.0.8.tar.gz
wget http://cr.yp.to/software/ezmlm-0.53.tar.gz
wget http://shupp.org/software/ezmlm-idx-0.443.tar.gz
wget http://nchc.dl.sourceforge.net/sourceforge/courier/courier-imap-4.1.1.tar.bz2
wget http://shupp.org/software/courier-authlib-0.58.tar.bz2
//wget http://shupp.org/software/squirrelmail-1.4.6.tar.bz2
//wget http://shupp.org/software/quota_usage-1.3.1-1.2.7.tar.gz
wget http://shupp.org/software/toaster-scripts-0.8.1.tar.gz

刪除已有的SMTP/POP/IMAP元件:

rpm -e --nodeps sendmail
rpm -e --nodeps postfix

tar -zxvf tar/netqmail-1.05.tar.gz
cd netqmail-1.05
./collate.sh

cd..


## daemontools ##
tar -zxvf daemontools-0.76.tar.gz
cd admin/daemontools-0.76
patch -p1 < ../netqmail-1.05/other-patches/daemontools- 0.76.errno.patch
package/install

cd..

## ucspi-tcp ##
tar -zxvf ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
patch -p1 < ../netqmail-1.05/other-patches/ucspi-tcp-0.88.a_record.patch
patch -p1 < ../netqmail-1.05/other-patches/ucspi-tcp-0.88.errno.patch
patch -p1 < ../netqmail-1.05/other-patches/ucspi-tcp-0.88.nodefaultrbl.patch
make
make setup check

## Qmail ##
mkdir /var/qmail
groupadd nofiles
useradd -g nofiles -d /var/qmail/alias alias
useradd -g nofiles -d /var/qmail qmaild
useradd -g nofiles -d /var/qmail qmaill
useradd -g nofiles -d /var/qmail qmailp
groupadd qmail
useradd -g qmail -d /var/qmail qmailq
useradd -g qmail -d /var/qmail qmailr
useradd -g qmail -d /var/qmail qmails


tar -zxvf toaster-scripts-0.8.1.tar.gz

cd netqmail-1.05/netqmail-1.05/

ln -s /usr/kerberos/include/com_err.h /usr/kerberos/include/krb5.h /usr/kerberos/include/profile.h /usr/include/

vi qmail-smtpd.c //搜索函數 straynewline 中的451改為553

# 當你的伺服器收到無效格式的郵件時,會發送:"I am not going to accept that message at the moment,you can try again later",對方伺服器收到後,幾秒鐘後又會發送同樣的郵件給你,造成多次的重復。
# 改553後,你的伺服器將直接發送:"I am not going to accept that message,don't try sending it again.",告訴對方的伺服器不要再發這封無效的信件。

make
make setup check

echo 3 > /var/qmail/control/spfbehavior


(cd ~alias; echo "max@shengmax.com" > .qmail-postmaster ;\
echo "max@shengmax.com" > .qmail-mailer-daemon ;\
echo "max@shengmax.com" > .qmail-root )
chmod 644 ~alias/.qmail*

vi /etc/man.config # 加 "MANPATH /var/qmail/man"

chmod 644 /var/qmail/alias/.qmail*

echo 1 > /var/qmail/control/mfcheck
echo ./Maildir/ >/var/qmail/control/defaultdelivery
cd -

# 用"crontab -e"在crontab里增加下面,每天晚上更新temp keys
01 01 * * * /var/qmail/bin/update_tmprsadh > /dev/null 2>&1

mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
mkdir -p /var/qmail/supervise/qmail-pop3d/log
mkdir -p /var/qmail/supervise/qmail-pop3ds/log
chmod +t /var/qmail/supervise/qmail-send
chmod +t /var/qmail/supervise/qmail-smtpd
chmod +t /var/qmail/supervise/qmail-pop3d/log
chmod +t /var/qmail/supervise/qmail-pop3ds/log
cp /usr/local/qmail_src/toaster-scripts-0.8.1/send.run /var/qmail/supervise/qmail-send/run
cp /usr/local/qmail_src/toaster-scripts-0.8.1/send.log.run /var/qmail/supervise/qmail-send/log/run
cp /usr/local/qmail_src/toaster-scripts-0.8.1/smtpd.run /var/qmail/supervise/qmail-smtpd/run
cp /usr/local/qmail_src/toaster-scripts-0.8.1/smtpd.log.run /var/qmail/supervise/qmail-smtpd/log/run
cp /usr/local/qmail_src/toaster-scripts-0.8.1/pop3d.run /var/qmail/supervise/qmail-pop3d/run
cp /usr/local/qmail_src/toaster-scripts-0.8.1/pop3d.log.run /var/qmail/supervise/qmail-pop3d/log/run
cp /usr/local/qmail_src/toaster-scripts-0.8.1/pop3ds.run /var/qmail/supervise/qmail-pop3ds/run
cp /usr/local/qmail_src/toaster-scripts-0.8.1/pop3ds.log.run /var/qmail/supervise/qmail-pop3ds/log/run
echo 20 > /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming
chmod 755 /var/qmail/supervise/qmail-send/run
chmod 755 /var/qmail/supervise/qmail-send/log/run
chmod 755 /var/qmail/supervise/qmail-smtpd/run
chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
chmod 755 /var/qmail/supervise/qmail-pop3d/run
chmod 755 /var/qmail/supervise/qmail-pop3d/log/run
chmod 755 /var/qmail/supervise/qmail-pop3ds/run
chmod 755 /var/qmail/supervise/qmail-pop3ds/log/run
mkdir -p /var/log/qmail/smtpd
mkdir -p /var/log/qmail/pop3d
mkdir -p /var/log/qmail/pop3ds
chown -R qmaill /var/log/qmail

#啟動腳本:

cp /usr/local/qmail_src/toaster-scripts-0.8.1/rc /var/qmail/
cp /usr/local/qmail_src/toaster-scripts-0.8.1/qmailctl /var/qmail/bin/
chmod 755 /var/qmail/rc
chmod 755 /var/qmail/bin/qmailctl

ln -s /var/qmail/bin/qmailctl /usr/bin
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail

# 用daemontools來啟動qmail-send和qmail-smtpd
ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service

#命令:

#開始,停止,重啟,查看列等
#qmailctl start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help

sleep 5
qmailctl stat


日志:
/var/log/maillog
/var/log/qmail/current
/var/log/qmail/pop3d/current
/var/log/qmail/pop3ds/current
/var/log/qmail/smtpd/current

## Vpopmail ##
groupadd -g 89 vchkpw
useradd -u 89 -g vchkpw vpopmail

mkdir -p /home/vpopmail
mkdir -p /home/vpopmail/etc

echo "shengmax.com" > /home/vpopmail/etc/defaultdomain

echo '127.0.0.1:allow,RELAYCLIENT=""' > /home/vpopmail/etc/tcp.smtp

cd /home/vpopmail/etc
tcprules tcp.smtp.cdb tcp.smtp.tmp < tcp.smtp

echo "localhost|0|vpopmail|cys12345|vpopmail" > /home/vpopmail/etc/vpopmail.mysql

chmod 640 /home/vpopmail/etc/vpopmail.mysql
chown -R vpopmail.vchkpw /home/vpopmail/etc

cd /usr/local/qmail_src/vpopmail-5.4.13

mysql -uroot -p

CREATE DATABASE vpopmail;
grant all on vpopmail.* to vpopmail@localhost identified by "cys12345";
FLUSH PRIVILEGES;
QUIT;


tar zxvf vpopmail-5.4.13.tar.gz
cd vpopmail-5.4.13

./configure --enable-incdir=/usr/include/mysql --enable-libdir=/usr/lib/mysql --disable-roaming-users --enable-logging=p --disable-passwd --enable-clear-passwd --disable-domain-quotas --enable-auth-module=mysql --enable-auth-logging --enable-sql-logging --disable-valias --disable-mysql-limits

make
make install-strip

#管理:
echo 'export PATH=$PATH:/home/vpopmail/bin' >> /etc/profile
source /etc/profile

# 添加域,前面是域名,后面是管理(postmaster)密碼
vadddomain shengmax.com
cys12345
cys12345

#如果你想設定郵箱容量限制,那麼修改 vlimits.default:
vi ~vpopmail/etc/vlimits.default
# in particular set the default mailbox size to be something reasonable eg 10Mb
default_quota 1024576 (修改這個內容,默認的是10M; 50M=52428800)

# 添加用戶
vadduser max@shengmax.com cys12345
vmoduser -c MAX max@shengmax.com

# 設置郵箱容量達到90%的警告信息
vi /home/vpopmail/domains/.quotawarn.msg

From: 電子郵件管理員
Reply-To: max@shengmax.com
To: 電子郵件用戶
Subject: 電子郵件空間警告
Mime-Version: 1.0
Content-Type: text/html; charset=big5
Content-Transfer-Encoding: base64

您的電子郵件空間已經達到90%.如果想繼續使用,請刪除一些信件.
如果需要協助,請聯絡電子郵件管理員:
Email : max@shengmax.com

# 設置電子郵件已滿的警告信息
echo "電子郵件被拒絕,用戶的電子郵件空間已滿." > /home/vpopmail/domains/.over-quota.msg

#啟動腳本:

cp /usr/local/qmail_src/toaster-scripts-0.8.1/vpopmailctl /var/qmail/bin
ln -s /var/qmail/bin/vpopmailctl /usr/bin
chmod 755 /var/qmail/bin/vpopmailctl

# 用daemontools來啟動qmail-pop3d和qmail-pop3ds
ln -s /var/qmail/supervise/qmail-pop3d /service
ln -s /var/qmail/supervise/qmail-pop3ds /service

#修正:

# mysql支持
cd /usr/local/qmail_src/netqmail-1.05/netqmail-1.05
bunzip2 -c ../../qmail-toaster-0.8.3.patch.bz2 | patch -p0
make clean
make
qmailctl stop
make setup check
qmailctl start


## Courier-IMAP ##
rpm -ivh ftp://ftp.pbone.net/mirror/ftp.pld-linux.org/dists/1.0/PLD/i386/PLD/RPMS/expect-5.37-1.i386.rpm ftp://ftp.pbone.net/mirror/www.python.org/pyvault/centos-3-i386/tcltk83-8.3.5-2.el3.pyv.i386.rpm
tar -xjvf courier-authlib-0.58.tar.bz2
cd courier-authlib-0.58
chown -R vpopmail:vchkpw ../courier-authlib-0.58
su vpopmail
umask 0022

./configure --with-redhat
make
exit
make install-strip
make install-configure

cp courier-authlib.sysvinit /etc/init.d/courier-authlib
chmod 755 /etc/init.d/courier-authlib
ln -s ../init.d/courier-authlib /etc/rc0.d/K30courier-authlib
ln -s ../init.d/courier-authlib /etc/rc1.d/K30courier-authlib
ln -s ../init.d/courier-authlib /etc/rc2.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc3.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc4.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc5.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc6.d/K30courier-authlib

#Configure:
vi /usr/local/etc/authlib/authdaemonrc
Change authmodulelist="..." to authmodulelist="authvchkpw"

#Start Authlib's Authdaemon Server
/etc/init.d/courier-authlib start
cd ..

tar -xjvf courier-imap-4.1.1.tar.bz2

cd courier-imap-4.1.1

chown -R vpopmail:vchkpw ../courier-imap-4.1.1
su vpopmail
umask 0022

./configure --with-redhat

make
exit
make install-strip
make install-configure

cp courier-imap.sysvinit /etc/init.d/courier-imap
chmod 755 /etc/init.d/courier-imap
ln -s ../init.d/courier-imap /etc/rc0.d/K30courier-imap
ln -s ../init.d/courier-imap /etc/rc1.d/K30courier-imap
ln -s ../init.d/courier-imap /etc/rc2.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc3.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc4.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc5.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc6.d/K30courier-imap

#Configure:
vi /usr/lib/courier-imap/etc/imapd
Change 'IMAPDSTART=NO' to 'IMAPDSTART=YES'

vi /usr/lib/courier-imap/etc/imapd-ssl
Change 'IMAPDSSLSTART=NO' to 'IMAPDSSLSTART=YES'

# optional: The first time courier-imap is started, the SSL certificate
# is first created using "localhost" as the "common name".
# If you want to change this to match your hostname, you can customize
# the CN line in /usr/lib/courier-imap/etc/imapd.cnf (and pop3d.cnf of
# you choose to use courier's pop3d) so that the common name matches
# your server name BEFORE you start the server for the first time


#Start IMAP server
/etc/init.d/courier-imap start
cd ..



## autorespond ##

tar -xzvf autorespond-2.0.4.tar.gz
cd autorespond-2.0.4
patch -p1 < ../autorespond-2.0.4-2.0.5.patch
make
make install
cd ..



## ezmlm-idx ##

tar -xzvf ezmlm-0.53.tar.gz
tar -xzvf ezmlm-idx-0.443.tar.gz
mv ezmlm-idx-0.443/* ezmlm-0.53/ -f
cd ezmlm-0.53
patch -p0 < idx.patch
make
make setup
cd ..


## Qmailadmin ##

#Info: http://sourceforge.net/projects/qmailadmin

#Install:

tar -xzvf qmailadmin-1.2.10.tar.gz
cd qmailadmin-1.2.10
./configure --enable-help --enable-htmldir=/var/www/html --enable-cgibindir=/var/www/cgi-bin
make
make install-strip
cd ..
tar -xzvf qmailadmin-help-1.0.8.tar.gz
cd qmailadmin-help-1.0.8
mkdir /var/www/html/images/qmailadmin/help
cp -rp * /var/www/html/images/qmailadmin/help

cd ..


http://mail.shengmax.com/cgi-bin/qmailadmin

## qmail的防垃圾郵件 ##

1.封ip

針對有些垃圾郵件發送方是固定的ip或者固定ip段,那我們可以限制他們的smtp連接

vi tcp.smtp

218.61.128.61:deny
限制218.61.128.61的機器跟我的qmail服務器有任何smtp的連接
或者:

218.61.128.:deny
禁止218.61.128網段的機器跟我的qmail有任何的smtp連接。
然後

tcprules tcp.smtp.cdb tcp.smtp.tmp < tcp.smtp
生成新的tcp.smtp.cdb

當然你也可以通過iptables來限制smtp端口的連接。

2.封某個帳號
主要針對某些比較正規的垃圾郵件發送者

vi /var/qmail/control/badmailfrom

編輯/var/qmail/control/badmailfrom文件(如果沒有可以新建一個)將要拒收的郵件地址寫入,每條記錄?一行如:
    

123@123.com

  這樣所有FROM來自123@123.com的郵件都會被郵件服務器拒收。

  同樣也可以對一個域進行拒收,在badmailfrom文件中加入
    

@test.com

  這樣所有來自test.com的任何地址的電子郵件都會被服務器拒收。


3.設置.qmail-default文件
vi /var/qmail/alias/.qmail-default

/var/vpopmail/bin/vdelivermail '' bounce-no-mailbox
這樣垃圾郵件發過來,如果是一個不存在的郵箱,會自動彈回郵件,並告知no this mailbox


4。使用第三方的rbl服務,其實就是利用dns反查詢,可以防止有些人自架mail server發垃圾信的行為。

我用的是中國反垃圾郵件聯盟的CDL+DNS反查詢方式的實時黑名單技術,這個服務是免費的,但必須申請才能使用

申請服務後,在你的SMTP?動腳本,加上/usr/local/bin/rblsmtpd,如下

#!/bin/sh
QMAILDUID=qmaild
NOFILESGID=nofiles

/usr/local/bin/tcpserver -H -R -l 0 -t 1 -v -p -x /var/vpopmail/etc/tcp.smtp.cdb -u $QMAILDUID -g $NOFILESGID 0
smtp /usr/local/bin/rblsmtpd -r cblplus.anti-spam.org.cn/var/qmail/bin/qmail-smtpd hostname /var/vpopmail/bin
/vchkpw /bin/true /bin/cmd5checkpw /bin/true 2>&1 | /var/qmail/bin/splogger smtpd 3 &


## sqwebmail ##

查看/home/vpopmail/etc/目錄下有沒有inc_deps及lib_deps這兩個文件。
若沒則需建立這兩個文件。
內容如下:
inc_deps的內容如下:

  -I/home/vpopmail/include

ib_deps的內容如下:

  -L/home/vpopmail/lib -lvpopmail

(如不建的話./configure 時會出錯喲)

設置環境變數(加在root得.basrc)

INCS=-I/usr/include/mysql
export INCS
LIBS="-L/usr/lib/mysql -lmysqlclient -lz"
export LIBS
CPPFLAGS=-I/usr/include/mysql
LDFLAGS=-L/usr/lib/mysql
export CPPFLAGS
export LDFLAGS



./configure --with-cachedir --without-gzip --enable-webpass=yes --enable-softtimeout=300 --enable-autopurge=180 --enable-maxpurge=180 --with-htmldir=/ShareHome/php/sqwebmail --with-htmllibdir=/ShareHome/php/sqwebmail --enable-cgibindir=/ShareHome/php/sqwebmail/cgi-bin --enable-imagedir=/ShareHome/php/sqwebmail/images --enable-imageurl=/images --enable-mimecharset=big5 --with-maxargsize=5000000 --with-maxformargsize=5000000 --with-maxmsgsize=5000000 --without-ispell --with-authshadow --with-authmysql --with-authldap --with-authuserdb --with-authpwd --without-authpam --with-authvchkpw --without-authdaemon
./configure --with-cachedir --without-gzip --enable-webpass=yes --enable-softtimeout=300 --enable-autopurge=180 --enable-maxpurge=180 --with-htmldir=/ShareHome/php/sqwebmail --with-htmllibdir=/ShareHome/php/sqwebmail --enable-cgibindir=/ShareHome/php/sqwebmail/cgi-bin --enable-imagedir=/ShareHome/php/sqwebmail/images --enable-imageurl=/images --enable-mimecharset=big5 --with-defaultlang=big5 --with-maxargsize=5000000 --with-maxformargsize=5000000 --with-maxmsgsize=5000000 --without-ispell --with-authshadow --with-authmysql --with-authldap --with-authuserdb --with-authpwd --without-authpam --with-authvchkpw --without-authdaemon
make configure-check
make check
make
make install-strip
make install-configure

備份Pcanywhere設定

Pcanywhere設定
都是放在

C:\Documents and Settings\All Users\Application Data\Symantec\pcAnywhere

將他備份就可以了

Putty設定檔

每次重新安裝 Windows 後,
其中一個必裝的軟件是 PuTTY,
但每次也要將自己每一台主機加上去實在很麻煩,
以下是匯出 PuTTY 設定備份的方法:

1. 按 "開始" -> "執行",然後輸入 "RegEdt32" 並按確定。
2. 移到 HKEY_CURRENT_USER\Software\SimonTatham
3. 選擇 SimonTatham 後按 "檔案" -> "匯出"。
4. 儲存好匯出的登錄檔。
5. 將登錄檔放到需要匯入設定的電腦上,並 right click 該檔案後按 "合拼"。

DD-WRT 刷回 FON

1.
抓FON解壓

wget http://www.hotlinkfiles.com/files/176104_p4wta/fonera_0.7.1.3.fon

dd if=fonera_0.7.1.3.fon of=fonera_0.7.1.3.fon.tgz bs=1 skip=519

tar -zxvf fonera_0.7.1.3.fon.tgz

會解出下面三個file
rootfs.squashfs
kernel.lzma
hotfix

2.
開始工作

ip_address -l 192.168.1.254/24 -h 192.168.1.166

fis init
load -r -v -b 0x80040450 rootfs.squashfs
fis create -b 0x80040450 -f 0xA8030000 -l 0x00700000 -e 0x00000000 rootfs
load -r -b %{FREEMEMLO} kernel.lzma
fis create -r 0x80041000 -e 0x80041000 vmlinux.bin.l7
fis load -l vmlinux.bin.l7
exec

3.
大功告成

La Fonera 刷成 DD-WRT

1.
所需東東

(1) putty: http://www.chiark.greenend.org.uk/~sgtatham/putty/
(2) TFTP server: http://sourceforge.net/projects/tftp-server/
(3) HFS(Http File Server): http://www.rejetto.com/hfs/?f=dl
(4) openwrt-ar531x-2.4-vmlinux-CAMICIA.lzmaout.hex
(5) DD-WRT root.fs and vmlinux.bin.l7 : DD-WRT 下載處

2.
SSH 連到 La Fonera

cd /tmp
wget http://fonera.info/camicia/openwrt-ar531x-2.4-vmlinux-CAMICIA.lzma
mtd -e vmlinux.bin.l7 write openwrt-ar531x-2.4-vmlinux-CAMICIA.lzma vmlinux.bin.l7
reboot

cd /tmp
wget http://fonera.info/camicia/out.hex
mtd -e "RedBoot config" write out.hex "RedBoot config"
reboot

3.
連到La Fonera使用 RedBoot 刷入 DD-WRT
設定電腦ip為192.168.1.166
拷貝 root.fs 及 vmlinux.bin.l7 到 TFTP server 資料夾

telnet 192.168.1.254 9000 來連入

RedBoot> ip_address -l 192.168.1.254/24 -h 192.168.1.166
RedBoot> fis init
RedBoot> load -r -v -b 0x80041000 root.fs
RedBoot> fis create -b 0x80041000 -f 0xA8030000 -l 0x002C0000 -e 0x00000000 rootfs
RedBoot> load -r -v -b 0x80041000 vmlinux.bin.l7
RedBoot> fis create -r 0x80041000 -e 0x80041000 -l 0x000E0000 vmlinux.bin.l7
RedBoot> fis create -f 0xA83D0000 -l 0x00010000 -n nvram
RedBoot> reset

在以上過程中, 需要有耐心去等待, 一步步來, 別不小心刷掛了La Fonera

4.
以上都ok了
就可以用 http://192.168.1.1 來連入了

預設
帳號: root
密碼: admin

La Fonera PLUS 可用 Serial console 連入

網路上看到的




好像可用Serial console 連入,等拿到La Fonera PLUS來試試玩玩看


出處
http://www.francofon.fr/news-article-81-La-Fonera---en-details--Tout-sur-la-Fonera-Plus-


但實際接線連入 圖上的 TX 及 RX 畫反了,

且Serial console 連入後, 結果一直出現

: Sending discover...
: Sending discover...
: Sending discover...


沒法到 command 頁

所以應該 不能開啟 ssh 了

OpenVPN 用戶端使用帳號/密碼的驗證方式

OpenVPN 是屬於 SSL VPN 應用的類型,用戶端需有經由主機簽署的憑證才可以連線,這樣雖然安全但對一些可能會隨時更換機器的用戶而言,卻不是很方便。

這篇文章是以帳號/密碼為主要的登入方式,用戶不需在更換機器後還要向主機重新申請憑證的往返程序。

如果還不了解什麼是 OpenVPN,請參考這篇文章 [轉]OpenVPN中文概述 。

在繼續下述的安裝說明,請先閱讀這篇文章 Install OpenVPN on CentOS 4.4 ,因為以下步驟是延續該文章的進階設定。

作者:A-Lang (alang[dot]hsu[at]gmail[dot]com)

1. 檢查包含的套件有 mysql, mysql-devel, pam_mysql, 如尚未安裝請利用 yum 或網站 rpm.pbone.net 搜尋.
因為找不到相應 CentOS 4 的 pam_mysql 版本, 用 Google 搜尋到最新版的 source rpm , 再進行編譯安裝.
# wget http://www.lfarkas.org/linux/packages/centos/5/SRPMS/pam_mysql-0.7RC1-0.src.rpm
# rpmbuild --rebuild pam_mysql-0.7RC1-0.src.rpm
# rpm -Uvh /usr/src/redhat/RPMS/i386/pam_mysql-*.rpm

2. 建立資料庫管理 VPN 的登入帳號
# mysql -u root -p
mysql> create database vpndb;
mysql> use vpndb;
mysql> CREATE TABLE vpnuser (
-> name char(20) NOT NULL,
-> password char(128) default NULL,
-> active int(10) NOT NULL DEFAULT 1,
-> PRIMARY KEY (name)
-> );
mysql> insert into vpnuser (name,password) values('vpn','vpn');

3. 新增一個檔案 /etc/pam.d/openvpn, 內容如下。
auth sufficient pam_mysql.so user=dbuser passwd=dbpass host=localhost db=vpndb
table=vpnuser usercolumn=name passwdcolumn=password
where=active=1 sqllog=0 crypt=0
account required pam_mysql.so user=dbuser passwd=dbpass host=localhost db=vpndb
table=vpnuser usercolumn=name passwdcolumn=password
where=active=1 sqllog=0 crypt=0
說明:
dbuser -- 可存取 vpndb 的帳戶
dbpass -- 同上的密碼
crypt(0) -- Used to decide to use MySQL's PASSWORD() function or crypt()
0 = No encryption. Passwords in database in plaintext. NOT recommended!
1 = Use crypt
2 = Use MySQL PASSWORD() function

4. 測試 pam_mysql 是否正常運作
# saslauthd -a pam
# testsaslauthd -u vpn -p vpn -s openvpn
0: OK "Success."

5. 防止 Dos 的惡意攻擊, 請建立 "HMAC firewall"。
# cd /etc/openvpn/easy-rsa
# openvpn --genkey --secret keys/ta.key
# cd /etc/openvpn
# cp easy-rsa/keys/ta.key ./

6. 修改 OpenVPN 設定檔
# vi /etc/openvpn/server.conf
# For authentication by user/pass
tls-auth ta.key 0
plugin ./openvpn-auth-pam.so openvpn
client-cert-not-required
username-as-common-name

以上是依據這篇 Install OpenVPN on CentOS 4.4 所提及 server.conf 的內容,為使能以 user/pass 方式登入,需再補充的項目。

# cd /etc/openvpn
# cp /usr/share/openvpn/plugin/lib/openvpn-auth-pam.so ./

7. 啟動或重啟 OpenVPN 服務
# service openvpn start

8. 製作用戶端的安裝套件
基本上將用戶端需要的設定檔及 ca.crt,ta.key 憑證檔打包進安裝檔, 用戶在安裝後即可連線。
請參考文件 http://openvpn.se/files/howto/openvpn-howto_roll_your_own_installation_package-Rev1.1.html



Error: Failed build dependencies:
cyrus-sasl-devel is needed by pam_mysql-0.7RC1-0.i386
Answer:
yum install cyrus-sasl-devel

Error:
0: NO "authentication failed"
Answer: crypt 請改用 0, 編者使用 2 也就是 MySQL 的加密函數 password() 但始終無法驗證成功。


參考連結:
http://bbs.chinaunix.net/viewthread.php?tid=513004&extra=page%3D1

Install OpenVPN on CentOS 4.4

Install OpenVPN on CentOS 4.4

What's OpenVPN:
OpenVPN is a full-featured SSL VPN which implements OSI layer 2 or 3 secure network extension using the industry standard SSL/TLS protocol, supports flexible client authentication methods based on certificates, smart cards, and/or username/password credentials, and allows user or group-specific access control policies using firewall rules applied to the VPN virtual interface. OpenVPN is not a web application proxy and does not operate through a web browser.

OpenVPN 2.0 expands on the capabilities of OpenVPN 1.x by offering a scalable client/server mode, allowing multiple clients to connect to a single OpenVPN server process over a single TCP or UDP port.


Author: A-Lang (alang[dot]hsu[at]gmail[dot]com)

Our System Environment:
Server>
OS : CentOS Linux V4.4/kernel 2.6.9-34.0.2.EL
Real IP : 192.168.10.10
VPN IP : 10.8.0.1

Client>
OS : Windows XP Home
Real IP : 192.168.0.163(dhcp mode)
VPN IP : 10.8.0.x (server assigned)

Reference Document:
http://www.study-area.org/tips/openvpn.html

==============
For Server
==============
1. Download package files
#wget http://openvpn.net/release/openvpn-2.0.9.tar.gz
#wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpm

2. Install package
#rpmbuild --rebuild lzo-1.08-4.rf.src.rpm
#rpm -Uvh /usr/src/redhat/RPMS/i386/lzo-*.rpm

#rpmbuild -tb openvpn-2.0.9.tar.gz
#rpm -Uvh /usr/src/redhat/RPMS/i386/openvpn-2.0.9-1.i386.rpm


Error:
Failed build dependencies:
autoconf is needed by lzo-1.08-4.rf.i386
Answer:
yum install autoconf.noarch
--
Error:
Failed build dependencies:
pam-devel is needed by openvpn-2.0.9-1.i386
Answer:
yum install pam-devel

3. Copy the sample configuration files
#cp -r /usr/share/doc/openvpn-2.0.9/easy-rsa/ /etc/openvpn/
#cp /usr/share/doc/openvpn-2.0.9/sample-config-files/server.conf /etc/openvpn/

4. Configure the CA
#cd /etc/openvpn/easy-rsa/
#vi vars
export KEY_COUNTRY=TW
export KEY_PROVINCE=Taiwan
export KEY_CITY=Hsinchu
export KEY_ORG="ALANGVPN"
export KEY_EMAIL="vpn@myvpn.ca.mail"

#. ./vars
#./clean-all

5. Build the root CA
#./build-ca
......++++++
writing new private key to 'ca.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [TW]:
State or Province Name (full name) [TAIWAN]:
Locality Name (eg, city) [HSINCHU]:
Organization Name (eg, company) [ALANGVPN]:
Organizational Unit Name (eg, section) []:linux
Common Name (eg, your name or your server's hostname) []:VPN
Email Address [vpn@myvpn.ca.mail]:

6. Build the server key and crt
#./build-key-server ovpnsrv1
Generating a 1024 bit RSA private key
.....++++++
........................++++++
writing new private key to 'ovpnsrv1.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [TW]:
State or Province Name (full name) [TAIWAN]:
Locality Name (eg, city) [HSINCHU]:
Organization Name (eg, company) [ALANGVPN]:
Organizational Unit Name (eg, section) []:linux
Common Name (eg, your name or your server's hostname) []:VPN
Email Address [vpn@myvpn.ca.mail]:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /etc/openvpn/easy-rsa/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName :PRINTABLE:'TW'
stateOrProvinceName :PRINTABLE:'TAIWAN'
localityName :PRINTABLE:'HSINCHU'
organizationName :PRINTABLE:'ALANGVPN'
organizationalUnitName:PRINTABLE:'linux'
commonName :PRINTABLE:'VPN'
emailAddress :IA5STRING:'vpn@myvpn.ca.mail'
Certificate is to be certified until Jun 27 05:21:29 2017 GMT (3650 days)
Sign the certificate? [y/n]:y


1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

7. Build the Diffie Hellman parameters
#./build-dh
Generating DH parameters, 1024 bit long safe prime, generator 2
This is going to take a long time
..........

8. Install the CA file which server request
#cp keys/ca.crt ../
#cp keys/dh1024.pem ../
#cp keys/ovpnsrv1.key ../
#cp keys/ovpnsrv1.crt ../

9. Setting the server configuration for OpenVPN
#cd ../
#vi server.conf
dev tap
;dev tun
ca ca.crt
cert ovpnsrv1.crt
key ovpnsrv1.key # This file should be kept secret

10. Startup the service
#service openvpn restart
#chkconfig openvpn on

==============
For Client
==============
1. Download and install the OpenVPN GUI for Windows
http://openvpn.se/files/install_packages/openvpn-2.0.9-gui-1.0.3-install.exe

2. Configure the CA
cmd.exe
>cd "c:Program FilesOpenVPNeasy-rsa"
>copy vars.bat.sample vars.bat
edit vars.bat
set KEY_COUNTRY=TW
set KEY_PROVINCE=TAIWAN
set KEY_CITY=HSINCHU
set KEY_ORG=ALANGVPN
set KEY_EMAIL=vpn@myvpn.ca.mail
(PS. Above must be same as the server)

3. Double-Click the file vars.bat or run this batch file with command-line to load the configuration above.

4. Build the client key and csr
>cp openssl.cnf.sample openssl.cnf
>md keys
>build-key alanghome

5. Copy the client csr file to server and then sign up the csr file with command 'sign-req' .
Copy the keys/alanghome.csr of client to the directory /etc/openvpn/easy-rsa/keys of server.
#cd /etc/openvpn/easy-rsa/
#./sign-req alanghome
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName :PRINTABLE:'TW'
stateOrProvinceName :PRINTABLE:'TAIWAN'
localityName :PRINTABLE:'HSINCHU'
organizationName :PRINTABLE:'ALANGVPN'
organizationalUnitName:PRINTABLE:'linux'
commonName :PRINTABLE:'alanghome'
emailAddress :IA5STRING:'vpn@myvpn.ca.mail'
Certificate is to be certified until Jun 27 06:40:48 2017 GMT (3650 days)
Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

6. Return to client, install the CA files (including alanghome.crt and ca.crt)
Copy the crt file(alanghome.crt) that server made and ca.crt of server to the directory Program Files/OpenVPN/config of client.
>cd ../config
>copy ../easy-rsakeysalanghome.key ./

7. Setting the client configuration for OpenVPN
>copy ../sample-config/client.ovpn ./
Right-Click the OpenVPN GUI icon in the bottom right-hand corner, select 'Edit Config'
dev tap
;dev tun
dev-node OpenVPN_Tap
remote 192.168.10.10 1194
ca ca.crt
cert alanghome.crt
key alanghome.key
ns-cert-type server



8. Configure the network interface for OpenVPN
Select "Control Panel" -> "Network Connection" -> "TAP-Win32#(#)"
Right-Click to rename as 'OpenVPN_Tap'



9. Startup the connection of client
In the task-bar, select "OpenVPN GUI" -> right-click "Connect"



Here you should can connect with OpenVPN server thru VPN. However general web browsing will be accomplished with direct connections that bypass the VPN.
If you want to browse web thru VPN , please continue to follow the steps below.

1. Add the following directive to the server configuration file 'server.conf'
push "redirect-gateway def1"
push "dhcp-option DNS 168.95.1.1"

2. Setting NAT routing for VPN client on server (設定NAT)
#vi /etc/openvpn/start-nat.sh
#!/bin/bash

ipt="/sbin/iptables"

# Clean the all rules (清除所有iptables)
$ipt -F
$ipt -X
$ipt -t nat -F
$ipt -t nat -X

# Enable ip_forward
echo "1" > /proc/sys/net/ipv4/ip_forward

# For NAT routing
$ipt -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
$ipt -t nat -L

#cd /etc/openvpn
#./start-nat.sh

See Also:

http://blog.chinaunix.net/u/9284/article.php?frmid=28653
http://openvpn.net/howto.html
http://openvpn.se/index.html
http://bbs.chinaunix.net/viewthread.php?tid=935322&extra=page%3D3
http://bbs.chinaunix.net/viewthread.php?tid=503434&extra=page%3D4

OpenVPN中文概述

OpenVPN中文概述

http://dev.csdn.net/article/79/79321.shtm
趣多多 譯

OpenVPN 是一個具備完全特徵的SSL VPN解決方案,能夠進行大範圍的配置操作,包括遠程訪問、站點-站點間VPN、WiFi安全及企業級遠程訪問解決方案,支持負載均衡,錯誤恢復及細粒度的訪問控制。

OpenVPN通過使用工業標準SSL/TLS協議 實現了OSI 2層及3層安全網絡擴展,支持靈活的基於證書、智能卡的客戶端認證方法,允許通過在VPN虛擬接口上應用防火牆規則實現用戶及組訪問控制策略。OpenVPN並非一個Web應用代理,也不能通過Web瀏覽器進行操作。

作為一個不錯的關於OpenVPN的概念介紹,可以參考James Ynan在Linux Fest Northwest 上2004年發表的程序註釋--理解用戶空間VPN:歷史、概念基礎及實際應用(Understanding the User-Space VPN: History, Conceptual Foundations, and Practical Usage)。也可以參考Charlie Hosner的OpenVPN及SSL VPN革命(OpenVPN and the SSL VPN Revolution)。

OpenVPN 是一個開源項目,遵從GPL許可協議。商業許可對重新發佈其基於OpenVPN的應用程序的公司也有效。獲得更多信息請聯繫info@openvpn.net。

OpenVPN 能夠運行於Linux、Windows 2000/XP及更高版本、OpenBSD、FreeBSD、NetBSD、Mac OS X及Solaris平台。
通過OpenVPN,你可以:

在任意IP局部網絡或虛擬以太網適配器上通過單個UDP或TCP端口建立隧道;

使用一或多台機器配置可裁剪的、負載均衡的VPN服務器群以處理成千上萬的來自VPN客戶端的動態連接;

能夠使用在OpenSSL庫中所提供所有的加密、認證及證書特性以保護私有網絡在Internet網絡上的數據傳輸;

使用OpenSSL庫所支持的任意加密算法、密鑰長度或HMAC數字簽名(用於數據報完整性檢查);

先把基於靜態密鑰傳統加密方法或基於證書的公鑰加密方法;

使用靜態、預先公有的密鑰或基於TLS的動態密鑰交換;

使用實時的自適配壓縮及流量整形以管理鏈路帶寬分配;

為動態公共點(如DHCP或撥號客戶端)提供隧道傳輸;

無需顯示定義防火牆規則為面向連接的防火牆提供網絡隧道傳輸;

基於NAT的網絡隧道;

通過虛擬的tap設備創建安全的以太網橋;

在Windows或Mac OS X系統上通過GUI界面控制OpenVPN。



OpenVPN與其它VPN有何區別?

OpenVPN的主要特徵包括跨平台的可移植性、優秀的穩定性、成百上千或成千上個客戶端支持的可伸展性、相對簡單的安裝過程、支持動態IP地址及NAT。

OpenVPN 提供一個設計為易於針對站點定制的可擴展的VPN框架,例如提供發佈自定義安裝包到客戶端,或通過OpenVPN插件模塊接口支持可選的認證方法(例如openvpn-auth-pam 模塊允許OpenVPN使用任意PAM認證方法認證客戶端,這種方法可以單獨使用,也可以與基於X509證書結合使用以進行認證)。

OpenVPN 提供一個管理接口,可以用於遠端控制或中央控制一個OpenVPN守護進程。管理接口也可以用於開發基於GUI或web的前端應用程序。

在Windows平台上,OpenVPN能夠使用Windows Crypto API從智能卡上讀取證書或私鑰。

OpenVPN 使用設計用於可保護被動攻擊和主動攻擊的工業強度的安全模型。OpenVPN的安全模型基於SSL/TLS進行會話認證及使用IPSec ESP協議用於基於UDP的安全隧道傳輸。OpenVPN支持X509 PKI (public key infrastructure)用於會話認證,TLS協議用於密鑰交換,OpenSSL的加密算法無關的EVP接口用於加密隧道數據,HMAC-SHA1算法用於認證隧道數據。

OpenVPN建立為可移植的, OpenVPN可以運行於Linux、Solaris、OpenBSD、FreeBSD、NetBSD、Mac OS X及Windows 2000/XP,因為OpenVPN作為用戶空間守護進程編寫而非內核模塊或對IP層的複雜變更,移植操作的簡易性是值得留意的。

OpenVPN易於使用,通常,一個隧道的建立和配置可以通過一個單獨的命令完成(無需任何必要的配置文件)。OpenVPN文檔包含了的示例進行了詳細解釋。

OpenVPN 經過嚴格設計,並在不可靠的網絡中進行了強度測試。OpenVPN的一個主要的設計目標就是在正常操作和錯誤恢復情況下IP層都能夠快速響應。這意味著如果IP層斷開5分鐘,當它再次恢復時,隧道流量能夠立即恢復,即使動態密鑰交換在這期間已經過期。

OpenVPN 有著健壯的模塊設計。所有加密都由OpenSSL庫處理,所有IP隧道功能都由TUN/TAP虛擬網絡驅動提供。

模塊化的好處是顯而易見的,例如,OpenVPN可以與新版本的OpenSSL庫動態鏈接並立即能夠使用其在新版本中所提供的新功能。例如,當OpenVPN基於最後版本的OpenSSL(0.9.7)編譯時,它能夠使用新的加密算法,如AES-256(高級加載標準,256位密鑰),以及OpenSSL特定目的的硬件加速器優化加密、解密及認證性能的加密引擎功能。

同樣地,OpenVPN的用戶空間設計易於移植到任何包含TUN/TAP虛擬網絡驅動的OS中。

OpenVPN 運行速度很快,在Pentium II 266MHz機器上運行Redhat 7.2 ,使用基於TLS的認證方法,Blowfish加密算法,SHA1 用於隧道數據認證,當隧道傳輸一個巨大的,經過預先壓縮文件的FTP會話時,OpenVPN達到了每秒(CPU時間,包括內核及用戶態時間)1.455MB的收/發傳輸速度。

OpenVPN提供了用於控制VPN隧道的安全參數的選項,同時提供了用於保證服務器本身安全的選項,例如—chroot用於限制OpenVPN守護進程能夠訪問的文件系統部分,--user 及—group選項用於降低守護進程在初始化之後的優先級,--mlock用於確認密鑰原始內容及隧道數據從不被分頁到磁盤上,從而避免被後期恢復。

為什麼先把TLS作為OpenVPN的根本認證及密鑰協商協議呢?TLS是SSL協議族的最後成果,最初由Netscape開發用於他們最初的安全web瀏覽器。多年來,TLS及其SSL前身已經在web上得到了廣泛應用,並得到了深入的弱點分析。這些分析使得它不斷被加強,從而形成如今的協議,SSL/TLS被認為是最強壯及最成熟的安全協議之一。因此,我們相信TLS是作為VPN產品認證及密鑰交換機制的極好的先把。

OpenVPN 支持IPSec或PPTP嗎?
目前被廣泛應用的VPN實現中有三個主流:SSL、IPSec及PPTP。OpenVPN是一個SSL VPN,因此並不與IPSec、L2TP或PPTP兼容。
IPSec協議設計為內核空間IP棧的修正,不同的操作系統需要其自身的IPSec實現。
相對而言,OpenVPN的用戶空間實現允許跨操作系統及處理器體系、防火牆及NAT友好操作、動態地址支持、多協議支持(包括協議橋接)的移植。
優點與缺點並存,OpenVPN的主要優點在於可移植、易於配置及與NAT和動態地址兼容。OpenVPN的安裝和使用與其它安全相關的守護進程軟件,例如SSH相似。
由於歷史因素,IPSecr的優點在於獲得了眾多廠商的支持,雖然OpenVPN也逐漸開始致力於硬件設備的支持。
PPTP協議的優點在於其在Windows平台預裝了客戶端,密碼分析專家已經透露了其安全弱點。

OpenVPN符合標準嗎?
作為一個用戶空間VPN守護進程,OpenVPN與SSL/TLS、RSA證書及X509 PKI、NAT、DHCP及TUN/TAP兼容。
OpenVPN與IPSec、IKE、PPTP或L2TP並不兼容。

OpenVPN 隧道能夠基於TCP連接傳輸嗎?
是的,OpenVPN 1.5以上版本均支持基於TCP連接的隧道傳輸。

我是否能夠使用web瀏覽器作為OpenVPN客戶端?
不可以,雖然OpenVPN使用SSL/TLS協議用於安全傳輸,OpenVPN並不是一個Web應用代理。它是一個OSI 2層或3層Internet網絡隧道解決方案,要求OpenVPN同時安裝於客戶端和服務器端。


編譯OpenVPN
OpenVPN 在Linux或BSD系列系統中很容易通過源碼編譯。而在Windows上編譯則比較複雜,你可以在OpenVPN下載站中找到預編譯的安裝包。


OpenVPN 的編譯:
基於OpenSSL 加密及SSL庫(版本0.9.6或更高),可以提供基於證書的認證、公鑰加密、基於TLS的動態密鑰交換;
只基於OpenSSL加密庫,可以提供基於靜態密鑰的傳統加密和認證;
不基於OpenSSL,只提供未加密的UDP隧道。
OpenVPN也可以與LZO實時加密庫鏈接。OpenVPN支持自適配壓縮,這意味著它可以在隧道數據流能夠被壓縮時進行鏈路壓縮。
OpenVPN完全運行於用戶空間,除了在Windows、Linux及BSD系列系統上需要TUN/TAP虛擬網絡驅動外,不需要其它任何特殊的內核組件。

捐助OpenVPN項目
請考慮捐助OpenVPN項目。OpenVPN是GPL協議下一個完全由社區支持的成果,你的捐助對我們大有幫助,它可以確保OpenVPN的持續開發,包括保持最高安全性,維持一個嚴格的測試程序,添加新特性,改善文檔及提供技術支持。

OpenVPN web status - Use PHP

以網頁顯示 OpenVPN 目前連線的狀況,用 PHP 撰寫。

預覽圖:



步驟一:將這一行加入 /etc/openvpn/server.conf

management localhost 7505

步驟二:新增 vpnstat.php,並置於網站可存取目錄內,內容如下:

=============================================
<?php

// OpenVPN (php-based) web status script
//
// This script has been released to the public domain by Pablo Hoffman
// on February 28, 2007.
//
// Original location:
// http://pablohoffman.com/software/vpnstatus/vpnstatus.txt

// Configuration values --------
$vpn_name = "My VPN";
$vpn_host = "localhost";
$vpn_port = 7505;
// -----------------------------

$fp = fsockopen($vpn_host, $vpn_port, $errno, $errstr, 30);

if (!$fp) {
echo "$errstr ($errno)<br />";
exit;
}

fwrite($fp, "status");
sleep(1);
fwrite($fp, "quit");
sleep(1);

$clients = array();

$inclients = $inrouting = false;

while (!feof($fp)) {

$line = fgets($fp, 128);

if (substr($line, 0, 13) == "ROUTING TABLE") {
$inclients = false;
}

if ($inclients) {
$cdata = split(',', $line);
$clines[$cdata[1]] = array($cdata[2], $cdata[3], $cdata[4]);
}

if (substr($line, 0, 11) == "Common Name") {$inclients = true;}

if (substr($line, 0, 12) == "GLOBAL STATS") {$inrouting = false;}

if ($inrouting) {
$routedata = split(',', $line);
array_push($clients, array_merge($routedata, $clines[$routedata[2]]));
}

if (substr($line, 0, 15) == "Virtual Address") {$inrouting = true;}

}

$headers = array('VPN Address', 'Name', 'Real Address', 'Last Act', 'Recv', 'Sent', 'Connected Since');

$tdalign = array('left', 'left', 'left', 'left', 'right', 'right', 'left');

/* DEBUGprint "<pre>";
print_r($headers);
print_r($clients);
print_r($clines);
print_r($routedata);
print "</pre>";
*/

fclose($fp);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $vpn_name ?> status</title>
<meta equiv="'refresh'" content="'300'">
<style type="text/css">

body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
background-color: #E5EAF0;
}

h1 {
color: green;
font-size: 24px;
text-align: center;
padding-bottom: 0;margin-bottom: 0;
}

p.info {
text-align: center;
font-size: 12px;
}

.status0 {
background: #ebb;
}

.status1 {
background: lime;
}

table {
#border: medium solid maroon;
margin: 0 auto;border-collapse: collapse;
}

th {
background: maroon;
color: white;
}

tr {
border-bottom: 1px solid silver;
}

td {
padding: 0px 10px 0px 10px;
}

</style>
</head>
<body>
<table>
<tr>
<?php
foreach ($headers as $th) {
?>
<th><?php echo $th?></th>
<?php
}
?>
</tr>
<?php
foreach ($clients as $client) {
$client[3] = date ('Y-m-d H:i', strtotime($client[3]));
$client[6] = date ('Y-m-d H:i', strtotime($client[6]));
$client[4] = number_format($client[4], 0, '', '.');
$client[5] = number_format($client[5], 0, '', '.');
$client[2] = preg_replace('/(.*):.*/', '$1', $client[2]);
$i = 0;
?>
<tr>
<?php
foreach ($client as $td) {
?>
<td align="'<?php">'><?php echo $td?></td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
<p class="'info'">This page gets reloaded every 5 min.<br />Last update:
<b><?php echo date ("Y-m-d H:i:s") ?></b>
</p>
</body>
</html>
================================================

MakeNSIS on Linux

NSIS

是一個可以將應用程式打包編譯成windows的安裝程式

以下是NSIS在Linux下安裝的說明

MakeNSIS on Linux
I was supposed to create a Windows installer recently, but I just hate using Windows. NSIS was the chosen installer creator. I was lucky to be able to compile the NSIS installer on Linux.

The installer just ran without any glitches on wine. So testing the installer as not an issue as well.

Let me guide you through installing NSIS on Linux and how to use it on Linux.

http://nsis.sourceforge.net/Download

Requires


* Python version 1.6 and above (http://www.python.org/)
* SCons version 0.96.93 and above (http://www.scons.org/)
* C compiler

Steps



Download both the release and the source of x.xx.
nsis-x.xx.zip nsis-x-xx-src.tar.gz


Extract both into one parent parent directory

|
+-- nsis-x.xx
+-- nsis-x.xx-src


Change to the source directory
$ cd nsis-x.xx-src


Compile makensis using scon
$ scons SKIPSTUBS=all SKIPPLUGINS=all SKIPUTILS=all SKIPMISC=all


Copy makensis to the release
$ cp build/release/makensis/makensis ../nsis-x.xx/makensis


Change to the
$ cd ..


Install - Copy makensis to the install location
$ sudo cp -r nsis-x.xx/* /usr/local/share/nsis/


Create the link from the bin directory to the makensis such that
makensis is accessible from the command line.
$ sudo link /usr/local/share/nsis/makensis /usr/bin/makensis

DynDNS on La Fonera

NSLU2-Linux 提到 - HowTo / DynDNSupdate browse
能在 La Fonera 上面更新 dyndns 的 script。真是方便。

主要程式 dnsupd 是從 fragrantblue COPY 來的,
但放到La Fonera有問題不能跑, 再經過修改後的結果如下囉!!

1.建立dnsupd
vi /bin/dnsupd
=================================================
#!/bin/sh
user=
pass=
domain=
wildcard=[ON|OFF]

if [ ! -f /tmp/old.ip ]
then
echo "Current IP Address: 0.0.0.0" > /tmp/old.ip
fi

wget -q http://checkip.dyndns.com:8245/index.html --output-document=/tmp/new.ip

if [ "`cat /tmp/new.ip`" = "`cat /tmp/old.ip`" ]
then
echo "No new IP"
rm -f /tmp/new.ip
else
PAT='Current IP Address:.*[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'
if grep -q "${PAT}" /tmp/new.ip && grep -q "${PAT}" /tmp/old.ip; then
wget -q "http://${user}:${pass}@members.dyndns.org:8245/nic/update?hostname=${domain}&wildcard=${wildcard}" -O /tmp/upd.ip
echo "New IP"
rm -f /tmp/upd.ip
mv /tmp/new.ip /tmp/old.ip
fi
fi
==========================================

2.設定啟動執行
vi /etc/init.d/S60dnsupd
==========================================
#!/bin/sh
if [ -n "`pidof dnsupd`" ]; then
/bin/killall dnsupd 2>/dev/null
fi
umask 077
/bin/dnsupd
==========================================

3.變更權限
chmod 755 /bin/dnsupd
chmod 755 /etc/init.d/S60dnsupd

4.定時查驗ip是否變更
crontab -e (加入下一行)
==========================================
*/15 * * * * /bin/dnsupd &>/dev/nul
==========================================

La Fonera 加裝散熱風扇

看到最近網站上大家都在發表自行改裝的散熱裝置
我也來分享一下我之前改裝的成果
1.
所需物品如下:
(1)一分二的3pin電源線(我只找到這種的線)
(2)風扇 (3 x 3 x 0.5 cm), 因我不喜歡去改那散熱片, 特別去量大小找這size的
這size剛好可放那空間(圖三位置)


2.
將一分二的3pin電源線一條剪下 在電源座下依正負極焊上去, 正負極我是看變電器上的標示



3.
風扇底部有膠, 將他貼在散熱片上, 就完成了, 是可以靠左邊貼上並開個洞將熱氣吹出會更好, 但我不喜歡將Fon開洞所以就這樣貼上


4.
最後蓋上外衣, 在改裝前FON溫度近70度, 改裝後溫度為近60度, 約下降10度, 主要是我沒將FON開洞將熱氣吹出, 而是在內部循環


5.
有人問那風扇多少錢??
我是在是在台北車站新光三越旁的NOVA(台北市館前路2號)
地下一樓的店面買的
(一下樓往左邊轉, 走到底的角落那家, 就可看到風扇專賣店)

那個的確不便宜, 要200元
我在裝時
是有考慮風的方向要朝哪,想了一陣子
1.靠左邊貼上,風的方向朝左吹並開個洞, 將熱氣吹
2.風的方向朝右吹讓熱風在內部循環
因但我不喜歡將Fon開洞, 所以就選第二項就這樣貼上

小麥B落開張

歡迎大家來交流
並交個朋友