stone(パケットリピータ)

さて、今日は真面目にお仕事の準備。
構築中のサーバにパケットリピータ(Stone)を仕込むことになりました。
本来ブログは、こんな作業ログを書き溜めて、何時でも引き出せる、メモ帳の様な物。
日記的な用途に使われ始めたので、それが当たり前みたいになっちゃいましたね。
今回は、ローカルエリアに存在するクライアントがクラウド化されて、インターネット上にホスティングされたメールサーバにアクセスするための中継サーバに組み込みます。
何でこんな事をするのかって・・・とても簡単で、大事な理由があるんです。
自宅からなら、何処のメールサーバにアクセスしようと、だれも文句は言いませんが、社内からは、不特定のメールサーバにアクセスされるとトラブルの元です。
ウィルス付きメールを社内に持ち込まれたり、その他セキュリティホールを作ってしまう事になります。
特定のサーバ以外には、アクセス出来ないようにするためです。
それと、誰が何時アクセスしたか、Stoneのアクセスログで一目瞭然。
悪さは出来ませんね。
それでは、ソフトウェアをダウンロードしましょう。
————
#cd /usr/local/src
#wget http://www.gcd.org/sengoku/stone/stone-2.3e.tar.gz
————
これでダウンロード完了。
次に解凍。
————
#tar xzvf stone-2.3e.tar.gz
————
あれ、何故か解凍ディレクトリが、「stone-2.3d-2.3.2.7」になってる・・・・
ま! 良いか(^_^;)
解凍したディレクトリに入ります。
————
#cd stone-2.3d-2.3.2.7
#ls -la
-rw-r–r– 1 154 3001 21562 3月 1 2005 GPL.txt
-rw-r–r– 1 154 3001 6057 2月 5 2008 Makefile
-rw-r–r– 1 154 3001 14830 2月 5 2008 README.en.txt
-rw-r–r– 1 154 3001 17452 2月 5 2008 README.txt
-rw-r–r– 1 154 3001 18605 2月 5 2008 cryptoapi.c
-rw-r–r– 1 154 3001 60 2月 5 2008 logmsg.mc
-rw-r–r– 1 154 3001 274140 2月 5 2008 stone.c
-rw-r–r– 1 154 3001 970 2月 5 2008 stone.spec
————-
チャンと、解凍されてますね。
さて、じゃ、コンパイルです。
————-
#make linux
##########この辺に一杯メッセージが出ます。
#ls -la
-rw-r–r– 1 154 3001 21562 3月 1 2005 GPL.txt
-rw-r–r– 1 154 3001 6057 2月 5 2008 Makefile
-rw-r–r– 1 154 3001 14830 2月 5 2008 README.en.txt
-rw-r–r– 1 154 3001 17452 2月 5 2008 README.txt
-rw-r–r– 1 154 3001 18605 2月 5 2008 cryptoapi.c
-rw-r–r– 1 154 3001 60 2月 5 2008 logmsg.mc
-rwxr-xr-x 1 root 3001 98192 9月 2 00:04 stone
-rw-r–r– 1 154 3001 274140 2月 5 2008 stone.c
-rw-r–r– 1 154 3001 970 2月 5 2008 stone.spec
————-
stone が生成されたます。
生成された、実行ファイルをお気に入りのディレクトリにコピーします。
————-
#cp stone /usr/local/bin
————-
次に環境ファイルと起動スクリプトを作成しましょう。
—– /etc/stone.conf —–
-l
-a /var/log/stone/access.log
-L /var/log/stone/error.log
-n
-D
-d
xxx.xxx.xxx.xxx:110 9110 192.168.0.0/255.255.0.0 localhost —
xxx.xxx.xxx.xxx:25 9025 192.168.0.0/255.255.0.0 localhost
——– eof ———
早い話・・・・
port 9110 で来たパケットを xxx.xxx.xxx.xxx の port 110 に転送します。
同じく
prot 9025 で来たパケットを xxx.xxx.xxx.xxx の port 25 に転送します。
と書いてあります。
次に起動スクリプト・・・・
——- /etc/init.d/stoned ——
#!/bin/sh
#
# chkconfig: 345 91 35
# description: Starts and stops the stone packet repeater daemon
# Source function library.
. /etc/rc.d/init.d/functions
# Check that smb.conf exists.
[ -f /etc/stone.conf ] || exit 0
# See how we were called.
case “$1" in
start)
echo -n “Starting stone: "
/usr/local/bin/stone -C /etc/stone.conf &
echo “done."
;;
stop)
echo -n “Shutting down stone: "
killall stone
echo “done."
;;
restart)
echo -n “Restarting stone: "
$0 stop
$0 start
echo “done."
;;
*)
echo “Usage: stone {start|stop|restart}"
exit 1
esac
——- eof ——
これだけでは、自動起動しないので、chkconfig で登録します。
——————-
#chkconfig –add stoned
#chkconfig stoned on
——————-
ログのローテーション設定等残ってますが、取り敢えずこれで起動できるはずです。
——————-
/etc/init.d/stoned start
——————-
さて、通信試験をしてみましょう。
——————-
# telnet localhost 9110
Trying 127.0.0.1…
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]’.
+OK Dovecot ready.
user test-user01
+OK
pass xxxxxxxxxxx
+OK Logged in.
list
+OK 3 messages:
1 50307
2 11081
3 11317
.
quit
+OK Logging out.
Connection closed by foreign host.
—————–
本来は、110 で受け付けるはずのサーバが9110で受け付けてくれました。
パケットリピート成功。

PCとネット

Posted by papas