メイン

2005年01月13日

SuSE Linux 9.2をVMWareにインストール

とりあえずメモ。

1.VMWare上で日本語のインストーラーを使う方法

SuSEのインストーラーが起動したら、boot optionに「vnc=1」と入力する。少しインストールが進んだところで、vncのパスワードを聞かれるので、適当に設定。そのあとVMWare上に表示されたURLをブラウザーで開くと、Javaが起動して、日本語のグラフィカルなインストーラーが使える。インストールの途中で一度再起動するが、そのときもboot optionに「vnc=1」を指定すればOK。ネットワークはBridged・インストール中にランレベルを3に指定。

2.VMWare-Toolsのインストール

あらかじめsax2でX Window Systemの設定を済ませておく。あとは以下のようにコマンドを入力すると、VMWare-Toolsをインストールできる。X.orgを使用する他のディストリビューションでも、同じ方法でインストールできるようだ。

cd /root
wget http://woody.linif.org/vmconffix.sh
chmod a+x vmconffix.sh
mount /dev/cdrom /mnt
cd /tmp
tar xzf /mnt/vmware-linux-tools.tar.gz
umount /mnt
cd vmware-tools-distrib

/root/vmconffix.sh /tmp/vmware-tools-distrib/vmware-install.pl

2003年02月18日

ザウルスがサーバーに

Linux を搭載した電子手帳「ザウルス」って、Web サーバー(Apache)や Mail サーバー(Postfix)が動くんですね(笑)。知りませんでした。私は Linux が言論の自由の象徴のように感じることがあります。Linux と IP アドレスがあれば、なんでも言えるでしょう。アナーキーな面もありますが(笑)。こんなデバイスがイラクや北朝鮮や中国で普及するようになるといいですね。

2003年02月10日

iPod で Linux !?

Linux を Apple の iPod で動かすことに成功したらしいですね。MP3 プレーヤーでも動くとは、いやはや、なんというか(笑)。もう Linux 界隈で何が起ころうとも驚いてはいけないのかも知れません(笑)。

Linux QoS 設定スクリプト

Linux ルーターに QoS を設定しました。快適、快適。って Linux を使わない人にはまったく興味のない話題だと思いますが(笑)。私が設定したスクリプトを書いておきますので、QoS を使いたい方は、参考にしてください。スクリプトを走らせた後に

tc -s class ls dev eth0

とコマンドを打つと、HTTP や FTP がトラフィックコントロールされている様子がわかります。

=== 以下スクリプト ===

#!/bin/sh

################
# ルールの初期化
/sbin/tc qdisc del dev eth0 root
/sbin/tc qdisc del dev eth1 root

##############################
# ルートクラス・親クラスの作成

## /dev/eth0 のルートクラスに cbq をセットし、ハンドルを 10 とする ##
/sbin/tc qdisc add dev eth0 root handle 10: cbq bandwidth 10Mbit avpkt 1000 cell 8

## /dev/eth1 のルートクラスに cbq をセットし、ハンドルを 11 とする ##
/sbin/tc qdisc add dev eth1 root handle 11: cbq bandwidth 10Mbit avpkt 1000 cell 8

## 10Mbit/sec の帯域クラスを priority 8 で作成 (classid 10:1)
## 以後、handle 10:1 を parent とするクラスは最大で 10Mbit/sec の
## 帯域が利用可能となる。
/sbin/tc class add dev eth0 parent 10:0 classid 10:1 cbq bandwidth 10Mbit rate 10Mbit allot 1514 cell 8 weight 1Mbit prio 8 maxburst 20 avpkt 1000

## 10Mbit/sec の帯域クラスを priority 8 で作成 (classid 10:1)
## 以後、handle 11:1 を parent とするクラスは最大で 10Mbit/sec の
## 帯域が利用可能となる。
/sbin/tc class add dev eth1 parent 11:0 classid 11:1 cbq bandwidth 10Mbit rate 10Mbit allot 1514 cell 8 weight 1Mbit prio 8 maxburst 20 avpkt 1000

##################################
# /dev/eth0 の帯域制御クラスの作成

## 10Mbit/sec の帯域クラスを priority 1, classid 10:61, parent 10:1 で ##
## 作成し tbf スケジューラを設定 ##
/sbin/tc class add dev eth0 parent 10:1 classid 10:61 cbq bandwidth 10Mbit rate 10Mbit allot 1514 cell 8 weight 1Mbit prio 1 maxburst 20 avpkt 1000 bounded
/sbin/tc qdisc add dev eth0 parent 10:61 tbf rate 10Mbit buffer 10Kb/8 limit 15Kb

## 10Mbit/sec の帯域クラスを priority 3, classid 10:63, parent 10:1 で ##
## 作成し tbf スケジューラを設定 ##
/sbin/tc class add dev eth0 parent 10:1 classid 10:63 cbq bandwidth 10Mbit rate 10Mbit allot 1514 cell 8 weight 1Mbit prio 3 maxburst 20 avpkt 1000 bounded
/sbin/tc qdisc add dev eth0 parent 10:63 tbf rate 10Mbit buffer 10Kb/8 limit 15Kb

## 10Mbit/sec の帯域クラスを priority 5, classid 10:65, parent 10:1 で ##
## 作成し tbf スケジューラを設定 ##
/sbin/tc class add dev eth0 parent 10:1 classid 10:65 cbq bandwidth 10Mbit rate 10Mbit allot 1514 cell 8 weight 1Mbit prio 5 maxburst 20 avpkt 1000 bounded
/sbin/tc qdisc add dev eth0 parent 10:65 tbf rate 10Mbit buffer 10Kb/8 limit 15Kb

## 10Mbit/sec の帯域クラスを priority 7, classid 10:67, parent 10:1 で ##
## 作成し tbf スケジューラを設定 帯域制限あり ##
/sbin/tc class add dev eth0 parent 10:1 classid 10:67 cbq bandwidth 10Mbit rate 224Kbit allot 1514 cell 8 weight 22Kbit prio 7 maxburst 20 avpkt 1000 bounded
/sbin/tc qdisc add dev eth0 parent 10:67 tbf rate 224Kbit buffer 10Kb/8 limit 15Kb

##################################
# /dev/eth1 の帯域制御クラスの作成

## 10Mbit/sec の帯域クラスを priority 1, classid 11:61, parent 11:1 で ##
## 作成し tbf スケジューラを設定 ##
/sbin/tc class add dev eth1 parent 11:1 classid 11:61 cbq bandwidth 10Mbit rate 10Mbit allot 1514 cell 8 weight 1Mbit prio 1 maxburst 20 avpkt 1000 bounded
/sbin/tc qdisc add dev eth1 parent 11:61 tbf rate 10Mbit buffer 10Kb/8 limit 15Kb

## 10Mbit/sec の帯域クラスを priority 3, classid 11:63, parent 11:1 で ##
## 作成し tbf スケジューラを設定 ##
/sbin/tc class add dev eth1 parent 11:1 classid 11:63 cbq bandwidth 10Mbit rate 10Mbit allot 1514 cell 8 weight 1Mbit prio 3 maxburst 20 avpkt 1000 bounded
/sbin/tc qdisc add dev eth1 parent 11:63 tbf rate 10Mbit buffer 10Kb/8 limit 15Kb

## 10Mbit/sec の帯域クラスを priority 5, classid 11:65, parent 11:1 で ##
## 作成し tbf スケジューラを設定 ##
/sbin/tc class add dev eth1 parent 11:1 classid 11:65 cbq bandwidth 10Mbit rate 10Mbit allot 1514 cell 8 weight 1Mbit prio 5 maxburst 20 avpkt 1000 bounded
/sbin/tc qdisc add dev eth1 parent 11:65 tbf rate 10Mbit buffer 10Kb/8 limit 15Kb

## 10Mbit/sec の帯域クラスを priority 7, classid 11:67, parent 11:1 で ##
## 作成し tbf スケジューラを設定 ##
/sbin/tc class add dev eth1 parent 11:1 classid 11:67 cbq bandwidth 10Mbit rate 10Mbit allot 1514 cell 8 weight 1Mbit prio 7 maxburst 20 avpkt 1000 bounded
/sbin/tc qdisc add dev eth1 parent 11:67 tbf rate 10Mbit buffer 10Kb/8 limit 15Kb

##########################################
# 各帯域クラスを適用するネットワークを定義

## DNS
/sbin/tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dport 53 0xffff flowid 10:61
/sbin/tc filter add dev eth1 parent 11:0 protocol ip prio 100 u32 match ip sport 53 0xffff flowid 11:61

## SSH
/sbin/tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dport 22 0xffff flowid 10:63
/sbin/tc filter add dev eth1 parent 11:0 protocol ip prio 100 u32 match ip sport 22 0xffff flowid 11:63

## HTTP
/sbin/tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dport 80 0xffff flowid 10:63
/sbin/tc filter add dev eth1 parent 11:0 protocol ip prio 100 u32 match ip sport 80 0xffff flowid 11:63
/sbin/tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dport 443 0xffff flowid 10:63
/sbin/tc filter add dev eth1 parent 11:0 protocol ip prio 100 u32 match ip sport 443 0xffff flowid 11:63

## MAIL
/sbin/tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dport 25 0xffff flowid 10:63
/sbin/tc filter add dev eth1 parent 11:0 protocol ip prio 100 u32 match ip sport 25 0xffff flowid 11:63
/sbin/tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dport 110 0xffff flowid 10:63
/sbin/tc filter add dev eth1 parent 11:0 protocol ip prio 100 u32 match ip sport 110 0xffff flowid 11:63
/sbin/tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dport 143 0xffff flowid 10:63
/sbin/tc filter add dev eth1 parent 11:0 protocol ip prio 100 u32 match ip sport 143 0xffff flowid 11:63

## NTP
/sbin/tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dport 123 0xffff flowid 10:63
/sbin/tc filter add dev eth1 parent 11:0 protocol ip prio 100 u32 match ip sport 123 0xffff flowid 11:63

## FTP
/sbin/tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dport 20 0xffff flowid 10:65
/sbin/tc filter add dev eth1 parent 11:0 protocol ip prio 100 u32 match ip sport 20 0xffff flowid 11:65
/sbin/tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dport 21 0xffff flowid 10:65
/sbin/tc filter add dev eth1 parent 11:0 protocol ip prio 100 u32 match ip sport 21 0xffff flowid 11:65

## その他
/sbin/tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dst any flowid 10:67
/sbin/tc filter add dev eth1 parent 11:0 protocol ip prio 100 u32 match ip dst any flowid 11:67

=== 以上 ===

2003年02月09日

Linux を UPnP 対応ルーターに

先日、古~いノートパソコン(486DX/4 75MHz)に Linux をインストールして、自宅のファイアーウォール・ルーターにしました。懐かしい CPU が現役でカタコトと動いているのを見るのは、楽しいです。その時に、Linux を UPnP 対応ルーターにできることがわかり、設定してみました。上手く動いているようなので、設定方法のメモ書きを載せておきます。ある程度 Linux の知識がある方なら、簡単だと思います。

●Linux-IGD インストールメモ

使用したカーネルのバージョンは2.4.19。コンパイルに必要なライブラリーなどは適宜インストール。

1. Linux SDK for UPnP のインストール

Open Source Linux SDK for UPnP Devices 1.0

アーカイブを展開し、Windows Messenger に対応するために、src/ssdp/ssdplib.c の406行目を
SelfAddr.sin_addr.s_addr = inet_addr(SSDP_IP);
から
SelfAddr.sin_addr.s_addr = htonl(INADDR_ANY);
に書き換える。

make
make install

でインストール。

2. Linux-IGD のインストール

現在の最新版(0.92)にはバグ(メモリーリーク)があるので、CVS で開発版を落としたほうが良い。

Linux UPnP Internet Gateway Device

make
make install

でインストール。Linux-IGD は /usr/sbin/ に iptables コマンドがあるのを前提に動作するので、もし違う場所に iptables があれば、以下のコマンドでリンクしておく。

ln -s /sbin/iptables /usr/sbin/iptables

ログの設定。/etc/syslog.conf をチェックし、

*.=debug /var/log/debug

を必要に応じて追加する。


3. ネットワークの設定

以下のコマンドを実行。int_if は LAN 側のインターフェース。

route add -net 239.0.0.0 netmask 255.0.0.0 int_if
(route add -net 239.0.0.0 netmask 255.0.0.0 eth0 など)

iptables の設定で、FORWARD のデフォルトを ACCEPT に設定する(重要)。FORWARD のフィルターは、最小限にしておく。以下の設定を参考に。$EXTIF は インターネット側、$INTIF は LAN 側のインターフェース。必要に応じてeth0 や ppp0 などに置き換える。

iptables -P INPUT DROP
iptables -F INPUT
iptables -P OUTPUT ACCEPT
iptables -F OUTPUT
iptables -P FORWARD ACCEPT
iptables -F FORWARD
iptables -t nat -F

iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE

iptables -N log_drop
iptables -A log_drop -p icmp -j LOG --log-level warning --log-prefix "DROP " -m limit --limit 1/s
iptables -A log_drop -j LOG --log-level warning --log-prefix "DROP "
iptables -A log_drop -j DROP

iptables -N global-in
iptables -A global-in -p tcp --dport ssh -j ACCEPT
iptables -A global-in -p tcp --dport www -j ACCEPT
iptables -A global-in -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A global-in -j log_drop

iptables -N global-out
iptables -A global-out -p udp --dport 137:139 -j DROP
iptables -A global-out -p tcp --dport 137:139 -j DROP
iptables -A global-out -p udp --dport 445 -j DROP
iptables -A global-out -p tcp --dport 445 -j DROP
iptables -A global-out -d 10.0.0.0/8 -j log_drop
iptables -A global-out -d 172.16.0.0/12 -j log_drop
iptables -A global-out -d 192.168.0.0/16 -j log_drop

iptables -A INPUT -i $INTIF -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT

iptables -I INPUT -i $EXTIF -j global-in
iptables -I FORWARD -o $EXTIF -j global-out
iptables -I OUTPUT -o $EXTIF -j global-out


4. Linux-IGD を起動

以下のコマンドで起動する。

upnpd ext_if int_if
(例・upnpd ppp0 eth0)

/var/log/debug をチェックして、Linux-IGD が問題なく起動していることを確認。
次に、LAN 内の Windows を起動。Windows XP であれば、コントロールパネルのネットワークを設定するところに、Linux-IGD のアイコンが見える。

iptalbes -L -t nat

を実行し、NAT テーブルを確認しておく。

MSN Messenger (あるいは Windows Messenger)を起動したあと、Linux で

iptalbes -L -t nat

を実行して、新たに NAT が設定されていれば OK 。
音声通話ができるかどうか、確認する。

これまでの設定を rc.local などに書き込んで作業完了。

5. うまく動かないときのチェックポイント

  • Windows2000 では、UPnP を通して音声を送るために DirectX 8.1 が必要

  • MSN Messengaer のバージョンは、4.6か4.7が良い?(未確認) YAMAHA のルーターのサポートページには、MSN Messenger 5.0 が UPnP に対応していないとの情報あり

  • Linux SDK for UPnP をデバッグオプションをつけて make したらうまく動いたという報告がメーリングリストにある。しかし、開発者はこのオプションを試したことがないとのこと