2005/12/22

OpenWRT進階設定 - DNS Server

OpenWRT本身預設使用dnsmasq作為dns proxy, 其實dnsmasq除了可以將query request轉送給真正的dns server之外, 它也可以讀取/etc/hosts或指定的檔案中的設定, 並將結果回覆給client, 所以dnsmasq非常適合最為一個小型區域網路中的dns server, 而且不管是正向或反向查詢都可正常運作, 做法如下, 請編輯/etc/init.d/S50dnsmasq, 輸入以下內容,

    #!/bin/sh
    dnsmasq --domain=$(nvram get dhcp_domain)

上面的敘述中, 我們從nvram變數dhcp_domain讀取domain的名稱, 這麼做的目的是為了可以查詢如server1.alphalab.org之類的名稱(假設我們的domain叫做alphalab.org), 所以我們必須把domain的名稱寫到nvram中,

    root@wrt54gs:~# nvram set dhcp_domain=alphalab.org root@wrt54gs:~# nvram commit

接著我們可以開始加入電腦名稱到/etc/hosts中,

    127.0.0.1 localhost wrt54gs.alphalab.org wrt54gs
    192.168.200.248 x255.alphalab.org x255
    192.168.200.150 x230.alphalab.org x230

2005/12/21

OpenWRT進階設定 - DHCP Server

Openwrt預設安裝的dhcp server是dnsmasq, dnsmasq基本上是一個小型的domain name server但也同時提供dhcp server的功能, 又小又好用, 功能也不少, 實在沒什麼好挑剔的, 不過剛好我的環境中需架設PXE Server, 需要dhcp server, 偏偏dnsmasq不提供指向tftp server的功能, 可是同一lan中同時有兩個dhcp server會很麻煩, 分開兩個lan也是麻煩, 所以一直很想使用功能較完整的dhcp server來取代dnsmasq的dhcp功能, 首先下載我們需要的dhcp server, 可以在這裡http://openwrt.alphacore.net/ 找到,

    root@wrt54gs:~# wget \
    http://openwrt.alphacore.net/dhcpd_3.0.1_mipsel.ipk

接下來進行安裝,

    root@wrt54gs:~# ipkg install dhcpd_3.0.1_mipsel.ipk

安裝好後, 還需要撰寫/etc/dhcpd.conf, 內容大致如下,

    #/etc/dhcpd.conf
    default-lease-time 7776000;
    max-lease-time 7776000;
    ddns-update-style none;
    server-name drbl;
    option routers 192.168.200.254;
    option domain-name "alphalab.org";
    option domain-name-servers 192.168.200.254;
    option subnet-mask 255.255.255.0;
    option broadcast-address 192.168.200.255;

    filename = "pxelinux.0";

    subnet 192.168.200.0 netmask 255.255.255.0 {
      range 192.168.200.240 192.168.200.249;
      host p5020 {
        hardware ethernet 00:0B:5D:24:20:63;
        fixed-address 192.168.200.100;
      }
    }

因為dhcpd執行的時候需要dhcpd.leases檔案存在, 所以我們先產生一個空的給他,

    root@wrt54gs:~# echo "" > /etc/dhcpd.leases

接下來撰寫啟動腳本, 我們將dhcpd的啟動放在dnsmasq之後, 請建立一個檔案/etc/init.d/S51dhcpd, 內容如下,

    #!/bin/sh
    /usr/sbin/dhcpd -lf /etc/dhcpd.leases br0

為了不與dnsmasq的dhcp server衝突, 我們必須關閉dnsmasq的dhcp功能, 請修改/etc/init.d/S50dnsmasq如下,

    #!/bin/sh
    /usr/sbin/dnsmasq

2005/12/18

夭壽喔 - Creating an XP Pro VM for the free VMware Player

VMware最近推出了一個免費的VMware Player, 讓你可以免費執行VMware Workstation, GSX, ESX等軟體建立出來的虛擬機器, 但是如果你沒有這些需付費的軟體該怎麼辦? 別擔心, 這篇文章交你怎麼使用免費的QEMU來製作可讓VMware Player執行的VM喔, 真是夭壽好用咧!

URL: http://johnbokma.com/.../vmware-player-windows-xp.html

How to build MapFS from source

Build the MapFS from source

以下是我編譯mapfs.ko的步驟:

  • cd /tmp
  • tar zxvf mapfs-1.0-0.1035.tar.gz
  • cd /lib/modules/`uname -r`/build
  • make SUBDIRS=/tmp/mapfs-1.0-0.1035 modules
  • cd kernel/fs
  • mkdir mapfs
  • cp /tmp/mapfs-1.0-0.1035 modules/mapfs.ko mapfs
  • chmod 744 mapfs/mapfs.ko
  • depmod
  • Okay!

至於如何載入就比較傷腦筋了, 因為有幾個相關了kernel symbols需要設定, 找了半天卻找不到相關文件解釋如何設定, 網路上又好像沒什麼人在用這東西, 不過還好, 最後還是在它的mailing list中看到一篇文章有提到載入的方式, 我只有改了一下路徑

  • 建立一個script檔案loadmapfs內容如下
    #!/bin/sh
    mapfsargs=$(for ksym in $(strings /lib/modules/$(uname -r)/kernel/fs/mapfs/mapfs.ko | awk '/from System.map/ {match($0,"^parm=([^:]+):",a); print a[1];}'); do sym=${ksym#ksym_}; addr=$(awk '/ '$sym'$/ {print $1}' /boot/System.map-$(uname -r)); echo " $ksym=0x$addr "; done)
    modprobe mapfs $mapfsargs
  • 執行./loadmapfs即可

2005/12/16

記起來 - MapFS

MapFS implements a Linux filesystem which utilizes copy-on-write functionality and existing Linux filesystems to allow component filesystems (or portions thereof) to be combined into a single virtual filesystem that appears to be fully writable. It is written in C, uses the standard Linux kernel VFS and loadable module interfaces for defining new filesystem types to the kernel, and supports (at least) kernel versions 2.4.7 to 2.6.13.

URL: http://sourceforge.net/projects/mapfs

記起來 - UnionFS - A Stackable Unification File System

This project builds a stackable unification file system, which can appear to merge the contents of several directories (branches), while keeping their physical content separate. Unionfs is useful for unified source tree management, merged contents of split CD-ROM, merged separate software package directories, data grids, and more. Unionfs allows any mix of read-only and read-write branches, as well as insertion and deletion of branches anywhere in the fan-out. To maintain unix semantics, Unionfs handles elimination of duplicates, partial-error conditions, and more. Unionfs is part of the larger FiST project.

URL: http://www.fsl.cs.sunysb.edu/project-unionfs.html

2005/12/15

你今天roomba了嗎?

什麼是roomba? 簡單講他是個會到處跑的吸塵器, 可是如果以為就這麼簡單, 那就太委屈他了, 其實它應該算是個不折不扣的機器人! 別小看它, 人家可是系出名門呢 - 麻省理工(MIT), 其實注意roomba也好一段時間了, 上禮拜突然在網路上看到在賣, 猶豫幾天之後還是給他刷了一台回來, 不出幾天, roomba就在我家出現了!

2005/12/14

人生就像大便...

掛網掛到精神不濟時, 突然幾句話閃過眼角...

    人生就像大便 一旦沖走了就不會再回來
    人生就像大便 怎麼拉就是那模樣,但每次又不太一樣
    人生就像大便 有時候拉的很爽,有時候卻拉的很難過
    人生就像大便 你永遠不知道會拉出個什麼東東
    人生就像大便 想要怎麼結果,就要先怎麼栽
    人生就像大便 隨時都可能突然地想..嗯嗯
    人生就像大便 往往努力了半天卻只迸出幾個屁
    人生就像大便 就算點綴得再漂亮,其本質還是一樣
    人生就像大便 只有自己默默的勇敢面對
    人生就像大便 有青才敢大聲
    所以,就像大家常說的------->「你去吃大便啦!!」
    其實,他的本義是『你要認真融入自己的生活。』
真是好樣的...