2003年05月30日

Shorewall

Shorewall 是一套很棒的 Netfilter 整合工具,他把 iptables, ip, tc... 等一堆 netfilter 指令整合起來,把繁瑣的指令就變成幾個設定檔了。

她有很高的可塑性,您可以在設定檔中依喜好設定 rules,因此她可以用於 router/firewall/gateway ,幾乎 netfilter 所支援的 都可以做到:

位址/路由轉換


    # Masquerading/SNAT
    # Port Forwarding (DNAT).
    # Static NAT.
    # Proxy ARP.
    # Policy Routing


虛擬私人網路


    # IPSEC,
    # GRE
    # IPIP
    # OpenVPN
    # PPTP clients and Servers


流量/頻寬控制


    Traffic Control/Shaping


有了這個工具的幫忙,想打造個五個介面的 firewall 也不是難事了(至少我是如此做)。

安裝請用 apt-get install shorewall ,官方網頁: http://www.shorewall.net

Posted by Andrew at 19:10 | Comments (0) | TrackBack

2003年05月29日

Taiwan Explorer Club

這真是個非常有創意的遊戲網站,他們希望透過開放式原始碼作業系統的使用,讓大家養成對開放式原始碼的正確認識,並減少因為使用不當的封閉程式而造成對網路安全防範的困難,進而減少網路犯罪。

http://wargame.free-bsd.org/index.php

Posted by Andrew at 00:15 | Comments (0) | TrackBack

2003年05月27日

Unstable DRBD for Debian

deb http://www.csee.wvu.edu/~katta/drbd/debs binary/
deb-src http://www.csee.wvu.edu/~katta/drbd/debs source/

Posted by Andrew at 16:14 | Comments (3) | TrackBack

Upgrade to software-raid 1

現在的 IDE 硬碟越來越便宜,也越來越容易損壞,所以市面上出了一堆 IDE RAID 卡,但我發現在 Debian 上面都非常難裝,為了晚上能安心睡覺,還是弄弄 kernel 內建的 md 吧。

但我的系統已經安裝了 Debian,是否有辦法把現有系統升級成 md 呢?

答案是有的,這邊就跟各位分享我升級成 raid 1 的經驗。

升級過程的步驟請繼續看下去 :p

1. 加入一顆相當大小的新硬碟到系統,並建立 raid partations type=fd


[root]# fdisk /dev/hdc

2. apt-get install raidtools2


[root]# cp /usr/share/doc/raidtools2/examples/raid1.conf.sample /etc/raidtab

3. 在 /etc/raidtab 中將舊硬碟的 partations 加上 failed-disk 標示, 並將 chunk-size 改為 32, 下面是我的設定:


# Sample raid-1 configuration
raiddev /dev/md0
raid-level 1
nr-raid-disks 2
nr-spare-disks 0
chunk-size 32

device /dev/hda1
failed-disk 0

device /dev/hdc1
raid-disk 1

4. 建立 raid, mkraid /dev/md? or more.


[root]# mkraid /dev/md0

5. 建立檔案系統, mke2fs -j -b 4096 -R stride=X /dev/md? X=chunk-size/4


[root]# mke2fs -j -b 4096 -R stride=8 /dev/md0

6. 掛上 raid 及複製資料 mount /dev/md? and cp -ax / /mnt


[root]# mount /dev/md0 /mnt
[root]# cp -ax / /mnt

7. 替開機做準備


[root]# chroot /mnt
[root]# mount -t proc /proc /proc

安裝支援 md 的 kernel,您可以自行編譯或是安裝 debian package
若打算安裝 debian package 的話,首先在 /etc/kernel-img.conf 內要有


do_initrd = yes

接著安裝 kernel

[root]# apt-get install kernel-2.4.20-1-686 kernel-headers-2.4.20-1-686

在 lilo.conf 中設定:

boot=/dev/md0
raid-extra-boot="/dev/hda,/dev/hdc"
root=/dev/md0
append="md=0,/dev/hda1,/dev/hdc1"
initrd=/initrd.img

別忘了 /etc/fstab 中也要改為


/dev/md0 / ext3 defaults,errors=remount-ro 0 1

8. 寫入 lilo 並重開機測試 raid


[root]# lilo -v

若無錯誤訊息則

[root]# reboot

9. 測試 ok 的話, 將舊的 partation type 修改為 fd 並存檔


[root]# fdisk /dev/hda

注意: 若無法 reload partation table 錯誤訊息出現, 則需要再 reboot 一次取得正確的分割表

10. 在raidtab, 將 failed-disk 改為 raid-disk 並加入 raid, fdisk and then raidhotadd /dev/md? /dev/hda?


[root]# raidhotadd /dev/md0 /dev/hda1

這下可以安心睡覺了,因為我知道就算硬碟壞了,也不會再是一堆麻煩的還原程序了....

Posted by Andrew at 01:39 | Comments (2) | TrackBack

2003年05月26日

High-Availability mail server

有過一次慘痛的教訓,一台 Compaq Server 上的 RAID 控制器出問題,原本上面跑的 RAID 1(mirror) 就掛了,雖然資料都可以從備份中還原,但是出事當時手邊並未有備用機器可以替換,且從備份中做災後重建也得花不少時間,對於一個使用 email 當作嘴巴跟耳朵的公司來說,損失是非常大的。

現在要開始想想怎麼做台 HA 的 mail server,一般的 HA 系統好像都是兩台電腦使用同一個 Shared Storage ,然後 run heartbeat,這時會有一台 idle 的電腦傾聽 running 那台的心跳聲,若聽不到就馬上接手該接手的工作。

我的問題是:

1.如何在不利用第三台的情況下讓 兩台的 account 同步?
2.如何讓兩台所安裝的 packages 同步?
3.該 share storage 的 controler 還是有可能出問題,要怎麼替 share storage 做 HA ?

應該還有些問題是我未考慮到的,歡迎提出您的看法,謝謝。

Posted by Andrew at 17:03 | Comments (1) | TrackBack

2003年05月21日

PPTPD draft notes

PPTP + MPPE on TrustedDebian draft notes

Andrew Lee alee at winklerpartners.com

PPTPD can make VPN easy for both UNIX and Windows users.

Here I just writen about how to setup pptpd on my TrustedDebian box, ABSOLUTELY NO WARRANTY, you should be able to setup the routing of vpn by yourself after you set pptpd up.

1) Install a new kerenl from kernel-source package with kernel-patch-mppe


[root]# apt-get install kernel-package kernel-patch-mppe kernel-source-2.4.20-1
[root]# cd /usr/src && tar xfj kernel-source-2.4.20.tar.bz2
[root]# cp /boot/config-2.4.20 .config
[root]# make oldconfig

Enable PPP_MPPE as a module

[root]# make-kpkg --append_to_version -mppe --bzimage --initrd kernel-headers kernel-image
[root]# cd ..
[root]# dpkg -i kernel-headers-2.4.20-mppe_10.00.Custom_i386.deb kernel-image-2.4.20-mppe_10.00.Custom_i386.deb
[root]# cat "alias ppp-compress-18 ppp_mppe" >> /etc/modutils/ppp

% I recommend to install grub instead lilo. %

2) Recompile a PPPD from source with mppe support

Download http://www.advancevpn.com/public/ppp-2.4.1.tar.gz
Download http://www.advancevpn.com/public/ppp-2.4.1-openssl-0.9.6-mppe-patch.gz

If you would like have LDAP support, try this: Download ftp://kalamazoolinux.org/pub/projects/awilliam/pppd-ldap/ppp-2.4.1LDAP.tgz
and then


[root]# apt-get install libldap2-dev

Compile pppd with mppe support:

[root]# tar fxz ppp-2.4.1.tar.gz
[root]# cd ppp-2.4.1
[root]# zcat ../ppp-2.4.1-openssl-0.9.6-mppe-patch.gz | patch -p1
[root]# ./configure

Add IBM stack smashing protector & PaX address layout randomization to
pppd/Makefile:

-COPTS = -O2 -pipe -Wall -g
+COPTS = -O2 -pipe -Wall -g -fstack-protector -fPIC


[root]# make
[root]# cp /usr/sbin/pppd /usr/sbin/pppd.debian
[root]# dpkg-divert --divert /usr/sbin/pppd.debian /usr/sbin/pppd
[root]# cp pppd/pppd /usr/sbin/pppd

You might test the pppd with mppe support by

[root]# strings /usr/sbin/pppd|grep -i mppe|wc -l

3) Install and setup pptpd

[root]# apt-get install pptpd

Edit /etc/ppp/pptpd-options, change 'servername' first and then make it
looks like these:
        
auth
+chap
+chapms
+chapms-v2
mppe-128
mppe-stateless
ipcp-accept-local
ipcp-accept-remote
lcp-echo-failure 3
lcp-echo-interval 5
deflate 0

Put pdc's ip as wins ip.

Edit /etc/pptpd.conf to add localip and remoteip


localip 192.168.0.4
remoteip 192.168.0.96-99

Posted by Andrew at 14:22 | Comments (2) | TrackBack

2003年05月19日

Backup tools

There is a nice backup/rescue tool in Sid(unstable) which is called mondo.

Posted by Andrew at 02:37 | Comments (0) | TrackBack