CentOS 5.2 に OpenVPN を突っ込むテスト[8]

CentOS 5.2 に OpenVPN を突っ込むテスト[7]の続きです。

とりあえず、OpenVPN関係のお話は終わり(お

で、今回は CentOS 5.2 に OpenVPN を突っ込むテスト[2] にあるように、既存のネットワークを壊さないために、ルーティング方式を採用している。この場合、接続クライアント(10.8.0.x)は、OpenVPNサーバ(10.8.0.1/192.168.1.x)にのみ接続が可能なので、社内LANに繋がる意味は結構薄い。(SSHで、10.8.0.1にログインして、そのサーバを踏み台に、192.168.0.xに繋げるのは可能だけど)

そこで、OpenVPNサーバにサービス用プロキシーソフトをインストールする事に。最初の要望は、HTTPだけだったので、パッケージにあるSquidをインストールしたが、社内IRCにも繋ぎたい!という要望があったので、別の手を考える。最初、IRCサーバ自体をOpenVPNサーバで動かす予定だったのだが、コンパイルは通らない上に、社内IRCサーバに繋がらないので断念。

そこで、思い出したのが Delegate! 簡易的なプロトコルであるIRCもリレー出来るだろうと実験してみたところ、ドンピシャで出来たので採用~

マニュアルとか: http://i-red.info/docs/Manual.htm

sudo yum install gcc
sudo yum install gcc-c++
sudo yum install openssl-devel
sudo yum install crypto-utils

tar xvfz delegate9.9.1.tar.gz で解凍。delegate9.9.1 ディレクトリで make

$ sudo su –
# mkdir /usr/local/delegate
# cd /home/hoge/src/delegate9.9.1/
# cp src/delegated /usr/local/delegate/
# cd /home/hoge/src/delegate9.9.1/subin
# cp dgbind /usr/local/delegate/ ←いらないかも
# cp dgchroot /usr/local/delegate/ ←いらないかも
# cp dgcpnod /usr/local/delegate/ ←いらないかも
# cp dgdate /usr/local/delegate/ ←いらないかも
# cp dgpam /usr/local/delegate/ ←いらないかも
# chown -R nobody:nobody /usr/local/delegate/
# cd /usr/local/delegate/

IRCテスト

# cd /usr/local/delegate/
# ./delegated -P6667 SERVER=tcprelay://[社内IRCサーバIP]:6667

HTTP/HTTPSテスト

# cd /usr/local/delegate/
# ./delegated -P3128 SERVER=http

無事に動いたら、delegated -Fkill –P6667 / delegated -Fkill –P3128 で止める。

/etc/init.d/delegate を作る。(まあ、適当)

#!/bin/sh
#
# delegate      This shell script takes care of starting and stopping
#               delegate on RedHat or other chkconfig-based system.
#
# chkconfig: – 24 76
#
# processname: delegate
# description: delegate
#

# To install:
#   copy this file to /etc/rc.d/init.d/delegate
#   shell> chkconfig –add delegate

# To uninstall:
#   run: chkconfig –del delegate

# Location of delegate binary
delegate="/usr/local/delegate/delegated"

for location in $delegate
do
if [ -f "$location" ]
then
delegate=$location
fi
done

# Our working directory
work=/var/spool/delegate-${OWNER}

# Check that binary exists
if ! [ -f  $delegate ]
then
echo "delegate binary not found"
exit 0
fi

# See how we were called.
case "$1" in
start)
echo -n $"Starting delegate: "

$delegate -P6667 SERVER=tcprelay://[社内IRCサーバIP]:6667
$delegate -P3128 SERVER=http

;;
stop)
echo -n $"Shutting down delegate: "

$delegate -Fkill -P6667
$delegate -Fkill -P3128

;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage: delegate {start|stop|restart}"
exit 1
;;
esac
exit 0

自動実行させる方法

# chkconfig -add delegate
# chkconfig delegate on

あとは、リブートするなり、/etc/init.d/dalegate start するなりして下さい。

[追記] iptables にポートを追加し忘れた。

CentOS 5.2 に OpenVPN を突っ込むテスト[4] を参考にroot権限で

sudo vi /etc/sysconfig/iptables

–dport 1194の下ぐらいに

-A RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 3128 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 6667 -j ACCEPT

80/443は、社内LANからApacheが見えるように。

次に、iptables で上の行を有効・保存します。

sudo /etc/init.d/iptables restart
sudo /etc/init.d/iptables save

アクセスを確認して、終了~

Related Posts with Thumbnails
カテゴリー: PC, お仕事, 日記   タグ: , , , , , ,   この投稿のパーマリンク

コメントは受け付けていません。