logo logo logo logo http://netkiller.mefound.com/
http://netkiller.mooo.com/
http://netkiller.8800.org/

Hello CQ DE BG7NYT - I enjoy Outdoor,Photography and Amateur Radio

版权声明:你可以任意转载,转载时请务必标明文章原始出处和作者信息及本声明。

How to Install and Configure INND under RedHat Linux



{literal}

How to Install and Configure INN
under RedHat Linux
by netkiller

参考文档:
http://allendowney.com/essays/inn_how_to.html
http://www.stunnel.org/

前言

我们为什么要使用新闻组?他有那些优点?

  1. 新闻组大部分都是开放地,不用象BBS那样每次进入时输入用户,密码
  2. 新闻组使用物理磁盘文件存储文章,与Maildir类似,优点支持海量存储,缺点不便于查询
  3. 支持推拉复制,共享/交换资源,而BBS要靠人工转贴。
  4. 新闻组可以使用GUI工具,WEB收发。其中GUI工具(Outlook/Netscape...)很方便
  5. 新闻组阅读文章方式,是先下载后阅读。所以脱机一样可以阅读先前打开过的文章
  6. news2mail 可以将组中的文章推到邮件列表里
  7. 连接数远远超过基于数据库的BBS

Microsoft 是目前我发现的一个最有代表的新闻组解决方案。

http://www.microsoft.com/china/community/Newsgroup/NGList.aspx

news://msnews.microsoft.com

他使用新闻组做后台数据存储,前使用是WEB界面,使用数据做索引来提高查询速度。

最界上最大的新闻组应该是Google的新闻组。

http://www.google.com/grphp?hl=zh-CN&tab=wg&ie=UTF-8&oe=UTF-8&q=

Google 使用新闻组的海量存储特点为搜索引擎数据存储。

目前最流行的闻新组服务器有三种:

  1. INN 是Unix like 平台
  2. Microsoft IIS 中的闻新组服务器
  3. DNEWS (新帆就是这个)

 

  1. 安装INN

    使用RPM方式安装
    mount /mnt/cdrom
    cd /mnt/cdrom/RedHat/RPMS
    rpm -i cleanfeed-0.95.7b-12.noarch.rpm inn-2.3.2-5.i386.rpm

     
    • Some of the files that get created are:
      # cron jobs that expire messages, etc.
      /etc/cron.daily/inn-cron-expire
      /etc/cron.hourly/inn-cron-nntpsend
      /etc/cron.hourly/inn-cron-rnews
       
    • # 配置文件
      /etc/news

      # 启动文件和脚本
      /etc/rc.d/init.d/innd
      /etc/rc.news

       
    • # inn文档
      /usr/share/doc/inn-2.3.2

       
    • # history files and related stuff
      /var/lib/news
      /var/lib/news/active
      /var/lib/news/active.times
      /var/lib/news/distributions
      /var/lib/news/history
      /var/lib/news/newsgroups
      /var/lib/news/subscriptions
      /var/lib/news/tmp
      /var/log/news
      /var/log/news/OLD
      /var/run/news

       
    • # spooled articles
      /var/spool/news
      /var/spool/news/archive
      /var/spool/news/articles
      /var/spool/news/incoming
      /var/spool/news/incoming/bad
      /var/spool/news/innfeed
      /var/spool/news/outgoing
      /var/spool/news/overview

       
  2. 配置

    切换到news用户,如果用户不存在,请自己创建

    su - news


    进入/etc/news目录,编辑配置文件

    chown news.news inn.conf
    vi inn.conf

    organization: Netkiller's News Server

    # General Settings

    domain: news.example.net
    innflags:
    mailcmd: /usr/lib/news/bin/innmail
    server: localhost

    # Posting

    fromhost: news.example.net
    moderatormailer: mailer@example.net



     

  3. 修改storage.conf加入:
     
    method tradspool {
    newsgroups: *
    class: 0
    }



     

  4. 在 readers.conf文件中加入:
     
    auth "local" {
    hosts: "*.example.net, example.net"
    default: "@example.net"
    }

    access "local" {
    users: "@wexample.net"
    newsgroups: "*"
    }

    注:在使用telnet ip nntp测试时,提示
    502 You have no permission to talk. Goodbye.
    尝试下面配置方法再试

    auth "local" {
    hosts: "*"
    default: "*"
    }

    access "local" {
    users: "*"
    newsgroups: "*"
    }

     

  5. 创建历史数据库文件
     
    cd /var/lib/news
    /usr/lib/news/bin/makedbz -i
    chmod 664 *n*

    mv history.n.dir history.dir
    mv history.n.hash history.hash
    mv history.n.index history.index


     

  6. 测试INN,如果inncheck没有错误就可以启动INN了。
     
    [root@linuxas3 root]# su news
    sh-2.05b$ cd /usr/lib/news/bin/
    sh-2.05b$ ./inncheck
    sh-2.05b$
     


     

  7. 启动守护进程
     
    [root@linuxas3 root]# /etc/init.d/innd start
    Starting INND system: [ OK ]
    [root@linuxas3 root]#
     

    or

    [root@linuxas3 root]# service innd start
    Starting INND system: [ OK ]
    [root@linuxas3 root]#
     

    如果你想让系统启动时就运行守护进程。

    chkconfig innd on

    [root@linuxas3 root]# chkconfig innd on
     

     

  8. 创建组

    ctlinnd newgroup comp.lang.python
    ctlinnd newgroup comp.lang.perl

    使用 ctlinnd

    这 个 指 令 的 大 部 份 功 能 都 只 会 在 INND 开 启 后 才 可 以 使 用 , 例 如 就 是 新 增 Newsgroup , 您 可 以 参考 ctlinnd 的 系 统 手 册 。 以 下 是 一 些 常 用 的 功 能 解 释 及 例 子 。

    格 式 : ctlinnd newgroup [groupname]
    例 子 : ctlinnd newgroup group.readers.discuss
     

    这 个 作 法 是 新 增 一 个 名 为 "group.readers.discuss" 的 Newsgroup

    格式: ctlinnd rmgroup [groupname]
    例子: ctlinnd rmgroup group.test.unused
     

    这个指令是可以删除 [groupname] 的 Newsgroup。

    格式: ctlinnd cannel [message-id]
    例子: ctlinnd cancel 3BCBF4B3.8AD48C8F@linux.org.hk
     

    把 Message-ID 为 "3BCBF4B3.8AD48C8F@linux.org.hk" 的 文 章 删 除 , 而 这 个 Message-ID 可 以 在 "View Source" 时 看到 , 就 如 图 二 中 是 在 Netscape 中 的 画 面 , 图 中 打 圈 的 就 是 Message-ID 的 位 置, 不 过 要 注 意 是 某 些 的 Message-ID 是 包 括 了 "$" 号 的 , 这 时 可 别 忘 记 在 "$" 号 前 加 上 "\" , 也就 是 "\$"。

    格式: ctlinnd pause [reason]
    例子: ctlinnd pause maintenance
     

    暂 停 一 切 的 连 线 及 不 准 许 新 的 文 章 , 这 个 适 合 作 为 暂 时 性 的 服 务 暂 停 。 而 [reason] 部 份 是 关键 钥 , 您 可 以 输 入 任 何 的 [reason] , 下 文 再 谈 。

    格式: ctlinnd throttle [reason]
    例子: ctlinnd throttle upgrade
     

    暂 停 一 切 的 连 线 及 不 准 许 新 的 文 章 , 并 且 也 会 关 闭 INND 的 "history" 檔 案 。 这 个 适 合 作 为 长 时期 的 服 务 暂 停 。 而 [reason] 部 份 是 关 键 钥 , 您 可 以 输 入 任 何 的 [reason] , 下 文 再 谈 。

    格式: ctlinnd go [reason]
    例子: ctlinnd go maintenance
     

    这 个 "go" 功 能 是 使 已 暂 停 服 务 的 innd 继 续 服 务 ,例 如 是 在 "pause" 或 是 "throttle" 后 , 可 以 使 用 这个 功 能 , 但 是 要 注 意 笔 者 刚 才 提 过 [reason] 一 事 , 在 "go" 中 使 用 的 [reason] 必 须 要 与 "pause" 或是 "throttle" 中 的 [reason] 相 同 。

     


     

    [root@linuxas3 root]# su news
    sh-2.05b$ cd /usr/lib/news/bin/
    sh-2.05b$ ./ctlinnd newgroup cn.os.linux
    Ok
    sh-2.05b$
     

  9. telnet 测试
    sh-2.05b$ telnet localhost nntp
    Trying 127.0.0.1...
    Connected to linuxas3.9812.net (127.0.0.1).
    Escape character is '^]'.
    200 linuxas3.9812.net InterNetNews server INN 2.3.5 ready
    list
    215
    control 0000000000 0000000001 n
    control.cancel 0000000000 0000000001 n
    control.checkgroups 0000000000 0000000001 n
    control.newgroup 0000000000 0000000001 n
    control.rmgroup 0000000000 0000000001 n
    junk 0000000000 0000000001 n
    cn.mail 0000000000 0000000001 y
    cn.mail.qmail 0000000000 0000000001 y
    cn.mail.postfix 0000000001 0000000001 y
    cn.lang.php 0000000000 0000000001 y
    cn.lang.java 0000000000 0000000001 y
    cn.lang.perl 0000000000 0000000001 y
    cn.lang.python 0000000000 0000000001 y
    cn.lang 0000000000 0000000001 y
    .
    quit
    205 .
    Connection closed by foreign host.
    sh-2.05b$

     

  10. Outlook/Netscape 新闻组客户端。
    在IE/Netscape中输入:
    news://news.example.net/
     
  11. 通过SSL连接
[root@linuxas3 news]# cat sasl.conf
tls_ca_path: /usr/lib/news/lib
tls_cert_file: /usr/lib/news/lib/cert.pem
tls_key_file: /usr/lib/news/lib/cert.pem
[root@linuxas3 news]#

[root@linuxas3 news]# cd /usr/lib/news/lib
[root@linuxas3 lib]# ll
total 88
-rwxr-x--- 1 news news 3546 Jul 3 2003 docheckgroups
-rw-r----- 1 news news 68532 Jul 3 2003 innreport_inn.pm
-rw-r--r-- 1 news news 2661 Jul 3 2003 innshellvars
-rw-r--r-- 1 news news 3139 Jul 3 2003 innshellvars.pl
-rw-r--r-- 1 news news 3453 Jul 3 2003 innshellvars.tcl
[root@linuxas3 lib]#
 

 创建证书

[root@linuxas3 lib]# openssl req -new -x509 -nodes \
> -out cert.pem -days 366 \
> -keyout cert.pem
Generating a 1024 bit RSA private key
....................++++++
...............................++++++
writing new private key to 'cert.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:Guang dong
Locality Name (eg, city) [Newbury]:Shen Zhen
Organization Name (eg, company) [My Company Ltd]:netkiller
Organizational Unit Name (eg, section) []:netkiller
Common Name (eg, your name or your server's hostname) []:as3.9812.net
Email Address []:openunix@163.com
[root@linuxas3 lib]#
 

设置权限

[root@linuxas3 lib]# chown news cert.pem
[root@linuxas3 lib]# chgrp news cert.pem
[root@linuxas3 lib]# chmod 640 cert.pem
[root@linuxas3 lib]# ll
total 92
-rw-r----- 1 news news 2205 May 7 17:31 cert.pem
-rwxr-x--- 1 news news 3546 Jul 3 2003 docheckgroups
-rw-r----- 1 news news 68532 Jul 3 2003 innreport_inn.pm
-rw-r--r-- 1 news news 2661 Jul 3 2003 innshellvars
-rw-r--r-- 1 news news 3139 Jul 3 2003 innshellvars.pl
-rw-r--r-- 1 news news 3453 Jul 3 2003 innshellvars.tcl
[root@linuxas3 lib]#
 

通过Stunnel 实现SSL连接INN

  1. 创建服务器证书
[root@linuxas3 root]# cd /etc/stunnel/
[root@linuxas3 stunnel]# ls
stunnel.conf-sample stunnel.pem
[root@linuxas3 stunnel]# cp stunnel.conf-sample stunnel.conf
[root@linuxas3 stunnel]# mv stunnel.pem stunnel.pem.old
 

[root@linuxas3 stunnel]# cp /usr/share/ssl/openssl.cnf /etc/openssl.cnf
[root@linuxas3 stunnel]# openssl req -new -x509 -days 365 -nodes -config /etc/openssl.cnf -out stunnel.pem -keyout stunnel.pem

Generating a 1024 bit RSA private key
....................++++++
.......................++++++
writing new private key to 'stunnel.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:GD
Locality Name (eg, city) [Newbury]:Shen Zhen
Organization Name (eg, company) [My Company Ltd]:none
Organizational Unit Name (eg, section) []:postfix
Common Name (eg, your name or your server's hostname) []:netkiller
Email Address []:openunix@163.com
[root@linuxas3 stunnel]# openssl gendh 512 >> stunnel.pem
[root@linuxas3 stunnel]# openssl x509 -subject -dates -fingerprint -in stunnel.pem
[root@linuxas3 stunnel]# chmod 600 /etc/stunnel/stunnel.pem
 

  1. Stunnel 客户方式不需要证书。Stunnel 服务方式需要一个证书文件。
    Stunnel 在 SSL Http Proxy 服务器是以服务方式运行的,所以必须要有一个证书。通过 openssl.exe 创建服务器证书。下面我将 Stunnel 关于创建证书的翻译如下:
    “...运行下面的命令
    openssl req -new -x509 -days 365 -nodes -config openssl.cnf -out stunnel.pem -keyout stunnel.pem
    这将会创建一个自己给自己签名的证书。参数的含义:
    -days 365
    使这个证书的有效期是1年,之后它将不能再用。
    -new
    创建一个新的证书
    -x509
    创建一个 X509 证书(自己签名的)
    -nodes
    这个证书没有密码
    -config openssl.cnf
    OpenSSL 使用的配置文件 (可能需要修改的有[CA_default]和[req_distinguished_name]这两个 section,译者)
    -out stunnel.pem
    把 SSL 证书写到哪里
    -keyout stunnel.pem
    把 SSL 证书放到这个文件中

    这个命令将会问你以下问题:
    问题的回答示范
    Country name 国家代码 PL, UK, US, CA...我国是CN,HK,TW
    State or Province name 省
    Locality Name 市
    Organization Name 公司、组织名称
    Organizational Unit Name 部门名称
    Common Name (FQDN) www.example.com

    注意:Common Name (FQDN) 应该是运行 stunnel 机器的主机名。如果你能通过不同的主机名访问这台机器,有些 SSL 客户会警告这个主机的证书有问题,所以最好是使它和用户访问的主机名匹配。

    openssl gendh 512>> stunnel.pem
    这将生成 Diffie-Hellman 部分, 追加到 pem 文件中。

    openssl x509 -subject -dates -fingerprint -in stunnel.pem
    这个命令是将你的证书信息在屏幕显示出来。”

     
  2. 配置/运行 Stunnel

    stunnel 默认配置文件是 /etc/stunnel/stunnel.conf
    下面是最小的服务方式配置文件内容示范:

    key = stunnel.pem
    [http2ssl]
    accept = 443
    connect = 127.0.0.1:80

    含义:使用 stunnel.pem 证书,将 127.0.0.1: 80 的端口加密映射成本机443端口,“ http2ssl ”是名称,可以改成其它的标识。

    配置文件文件还有其它内容,详情请看帮助。

    直接运行stunnel,就可以启动 Stunnel 了。
     
[root@linuxas3 stunnel]# stunnel
[root@linuxas3 stunnel]# nmap localhost

Starting nmap V. 3.00 ( www.insecure.org/nmap/ )
Interesting ports on linuxas3.9812.net (127.0.0.1):
(The 1583 ports scanned but not shown below are in state: closed)
Port State Service
22/tcp open ssh
25/tcp open smtp
80/tcp open http
110/tcp open pop-3
111/tcp open sunrpc
119/tcp open nntp
143/tcp open imap2
443/tcp open https
465/tcp open smtps
563/tcp open snews
631/tcp open ipp
993/tcp open imaps
995/tcp open pop3s
3306/tcp open mysql
5000/tcp open UPnP
5001/tcp open commplex-link
8009/tcp open ajp13
8080/tcp open http-proxy

Nmap run completed -- 1 IP address (1 host up) scanned in 3 seconds
[root@linuxas3 stunnel]#
 

cn.mail
cn.mail.qmail
cn.mail.postfix

cn.lang.c
cn.lang.php
cn.lang.perl
cn.lang.java
cn.lang.python

cn.comp.linux.development
cn.comp.linux.install
cn.comp.linux.admin
cn.comp.linux.misc
cn.comp.linux.application
cn.comp.freebsd
cn.comp.minix
cn.comp.solaris.admin
cn.comp.lang.c
cn.comp.lang.php
cn.comp.lang.perl
cn.comp.lang.python
cn.comp.lang.java.development
cn.comp.lang.java.jsp
cn.rec.amateurradio
cn.comp.linux.x
cn.comp.linux.advocacy
 

{/literal}
About Us | Site Map | Privacy Policy | Contact Us
Copyright © 2002-2004 netkiller All Rights Reserved