在debian(sarge)下安装stun server的过程



在debian(sarge)下安装stun server的过程

STUN协议定义:http://www.ietf.org/rfc/rfc3489.txt
STUN协议的实现项目: http://sourceforge.net/projects/stun/ and http://developer.berlios.de/projects/mystun/

下面描述在debian(sarge)下安装stun server的过程:

1:做stun server的机器需要双网卡,我的测试机器的/etc/network/interfaces文件内容如附录1.

2:下载stund的程序源代码并编译
wget http://aleron.dl.sourceforge.net/sourceforge/stun/stund_0.94_Oct29.tgz
tar xzvf stund_0.94_Oct29.tgz
cd stund
make   ## 编译生成程序 server
mkdir -p /root/bin
cp server /root/bin ##根据自己的需要放置到相应的目录

3: 制作辅助脚本文件 start_stund_server.sh(参见附录2)和stop_stund_server.sh(参见附录3)
chmod +x start_stund_server.sh
chmod +x stop_stund_server.sh
4: 修改start_stund_server.sh 文件中的ip地址为实际使用的地址
5:为了使系统启动时自动加载,创建文件 /etc/init.d/stund (参见附录4)
chmod +x /etc/init.d/stund
   使用rcconf命令,在其中选择stund来激活启动是自动加载.当然,你也可以使用别的工具,
   比如 sysvconf等。
6:不希望reboot机器,现在先手工启动stund、
/etc/init.d/stund start
7: 检查一下看看是否正常:
# ps aux | grep /root/bin/server
root       950 0.0 0.0 2436 888 ?        S    03:45   0:00 /root/bin/server -h 210.202.244.132 -a 210.202.244.133 -b    当然可以进一步检查,看看端口是否正常:
# netstat -na | grep 347
udp        0      0 210.202.244.133:3478    0.0.0.0:*
udp        0      0 210.202.244.132:3478    0.0.0.0:*
udp        0      0 210.202.244.133:3479    0.0.0.0:*
udp        0      0 210.202.244.132:3479    0.0.0.0:* 8: 好了,可以下载一个客户端来测试一下了,http://sourceforge.net/projects/stun/提供一个windows的客户段
   用起来不错的。你可以比较一下自己的server和公网上的server测试结果是否一样来判定自己的server是否工作    公网上stun server有:
current iTalk stun-server at: 216.16.193.43
WinStun default server: larry.gloo.net
vovida.org active stun-server : 128.107.250.38 128.107.250.39

9:希望一切顺利。

附录1: # cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 210.202.244.132
        netmask 255.255.255.192
        network 210.202.244.128
        broadcast 210.202.244.191
        gateway 210.202.244.190

auto eth1
iface eth1 inet static
        address 210.202.244.133
        netmask 255.255.255.192
        network 210.202.244.128
        broadcast 210.202.244.191 附录2: # cat /root/bin/start_stund_server.sh
/root/bin/server -h 210.202.244.132 -a 210.202.244.133 -b > /dev/null 2>&1

附录3: # cat /root/bin/stop_stund_server.sh
killall /root/bin/server

附录4: # cat /etc/init.d/stund

#! /bin/sh # /etc/init.d/stund: start and stop the STUND daemon
#

DAEMON_START="/root/bin/start_stund_server.sh"
DAEMON_STOP="/root/bin/stop_stund_server.sh"

test -x $DAEMON_START || exit 0
test -x $DAEMON_STOP || exit 0

case "$1" in
start)
    echo -n "Starting STUND server: stund"
    $DAEMON_START
    echo "ok."
    ;;

stop)
    echo -n "Stopping STUND server: stund"
    $DAEMON_STOP
    echo "ok."
    ;;

reload|force-reload)
    echo -n "Restarting STUND server: stund"
    $DAEMON_STOP
    $DAEMON_START
    echo "ok."
    ;;

restart)
    echo -n "Restarting STUND server: stund"
    $DAEMON_STOP
    $DAEMON_START
    echo "ok."
    ;;

*)
    echo "Usage: /etc/init.d/stund {start|stop|reload|force-reload|restart}"
    exit 1

esac

exit 0


转自:http://www.huomo.cn/os/article-1337f.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值