Chinaunix首页 | 论坛 | 博客
  • 博客访问: 151777
  • 博文数量: 11
  • 博客积分: 1198
  • 博客等级: 少尉
  • 技术积分: 335
  • 用 户 组: 普通用户
  • 注册时间: 2005-03-10 11:48
文章分类

全部博文(11)

文章存档

2013年(2)

2012年(1)

2010年(2)

2009年(4)

2008年(2)

我的朋友

分类:

2008-07-23 14:28:50

    Stunnel 可以非常方便的实现端口加密转发功能,我们可以用他来实现很多加密端口的传输。这里只做了简单的介绍,更深层次的功能还有待进一步挖掘。

 

下载源码

Stunnel网站

下载源码

 

 

http://kai0200.cublog.cn/

编译安装

./configure --prefix=/work/stunnel

--with-nspr-includes=/usr/include/nspr

 --with-nspr-libs=/usr/lib

--with-nss-includes=/usr/include/nss

--with-nss-libs=/usr/lib

 

make; makeinstall;

 

 

http://kai0200.cublog.cn/

 

生成.pem文件

测试发现

Red Hat Enterprise Linux AS release 3 (Taroon Update 4) 进入下面目录

/usr/share/ssl/certs

Red Hat Enterprise Linux Server release 5 (Tikanga) 进入下面目录

/etc/pki/tls/certs

 

执行一下命令

make stunnel.pem

通过默认默认目录下的Makefile文件对stunnel的支持我们可以生成一个支持stunnel.pem的密钥。

 

cp -rf  stunnel.pem  /work/stunnel/etc/stunnel/ 把密钥拷贝到对应的目录下。

 

mkdir -p /work/stunnel/var/run/stunnel/

chown  -R nobody:nobody /work/stunnel/  修改为nobody权限

 

 

http://kai0200.cublog.cn/

修改配置文件

cd /work/stunnel

vi etc/stunnel/stunnel.conf

 

增加以下内容(需要修改一下目录指向和ip端口就可以用了!),

stunnel 3版和4版本有很大区别,4版本的注释有些时候是“#”,现在拿到的最新版本又是“;”.这个自己看默认配置吧!

; Sample stunnel configuration file

; Copyright by Michal Trojnara 2002

 

; Comment it out on Win32 cert

cert = /work/stunnel/etc/stunnel/stunnel.pem

;chroot = /work/stunnel/var/run/stunnel/

; PID is created inside chroot jail

;pid =/work/stunnel/var/run/stunnel/stunnel.pid

setuid = root

setgid = root

 

; Workaround for Eudora bug

;options = DONT_INSERT_EMPTY_FRAGMENTS

 

; Authentication stuff

;verify = 2

; don't forget about c_rehash CApath

; it is located inside chroot jail:

;CApath = /certs

; or simply use CAfile instead:

;CAfile = /work/stunnel/etc/stunnel/certs.pem

; CRL path or file (inside chroot jail):

;CRLpath = /crls

; or simply use CAfile instead:

;CRLfile = /work/stunnel/etc/stunnel/crls.pem

 

; Some debugging stuff

; 注意调整调试级别,如果测试正常设置低一点的模式,否则可能日志过大1-7(7最大)

debug = 1    

output = stunnel.log

 

; Use it for client mode

;client = yes

 

; Service-level configuration

 

; pop3s 设置,

;accept = ip:port connetc = ip:port 可以指定ip和端口,我做的设置就是访问

;本地的995端口为加密,然后在把数据传输的网内的服务器172.16.100.168:110上。

[pop3s]

accept  = 995

connect = 172.16.100.168:110

 

[imaps]

accept  = 993

connect = 172.16.100.168:143

 

[ssmtp]

accept  = 465

connect = 172.16.100.168:25

 

[s1]

accept  = 5000

connect = mail.osw.pl:110

; delay = yes

 

[s2]

accept  = 5001

connect = mail.osw.pl:25

 

;[https]

;accept  = 443

;connect = 80

;TIMEOUTclose = 0

;inetd mode must define a remote host or an executable

 

 

Stunnel 服务的启动和停止

/work/stunnel4.25/bin/stunnel 服务就可以启动了。

如果配置了 output = stunnel.log 在当前目录下就会有一个日志文件了。

 

 

 

阅读(2666) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~