A new Page of Sealinger

Maybe I was a Bird in another Life !

Subscribe to RSS feed

关于sendmail与主机名的一些问题

系统环境:rhel as 4 update 4

今天在查看服务器的logwatch邮件时,发现有的/var/分区磁盘空间占用有点多,感觉应该是有不正常的日志产生了。

登录系统,查看/var/spool/mail/,果然邮件文件比较大。

1. 首先知道要优化监控脚本了,这个事情一直想做,可是老是没时间(有优先级更高的任务啊```)sad

于是把脚本中没用的输出到重定向到 /dev/null ,一般我们是这么写的,比如apache的关闭信息:
apachectl stop > /dev/null 2>&1

这样就不会产生烦人的邮件了。

2. 有些日志邮件是比较怪的,比如:
From MAILER-DAEMON@mob2  Mon Apr 30 17:25:57 2007
Date: Thu, 26 Apr 2007 09:26:42 +0800
From: Mail Delivery Subsystem <MAILER-DAEMON@mob2>
To: <squid@mob2>
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
        boundary="l3Q1QdbT009121.1177550802/localhost.localdomain"
Subject: Warning: could not send message for past 4 hours
Auto-Submitted: auto-generated (warning-timeout)

This is a MIME-encapsulated message

--l3Q1QdbT009121.1177550802/localhost.localdomain

    **********************************************
    **      THIS IS A WARNING MESSAGE ONLY      **
    **  YOU DO NOT NEED TO RESEND YOUR MESSAGE  **
    **********************************************

The original message was received at Thu, 26 Apr 2007 05:01:01 +0800
from localhost.localdomain [127.0.0.1]

   ----- Transcript of session follows -----
<squid@mob2>... Deferred: Connection refused by mob2.localdomain.
Warning: message still undelivered after 4 hours
Will keep trying until message is 5 days old

连接被拒绝了。但这是本地传送,有什么好拒绝的?
再看这个主机名(mob2.localdomain)比较奇怪,查看一下:
# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=mob2
GATEWAY=192.168.4.1
# hostname --long
mob2

没这么配置主机名啊````

之前查看各个服务器的Logwatch邮件的时候,有那么一两台主机的logwatch邮件标题就是“LogWatch for name.localdomain”的格式,而不像其他的大部分都是“LogWatch for name”,当时就感觉奇怪,因为系统安装时设置都是一样的格式,没有用FQDN格式的长主机名,但为何有的显示name,有的显示name.localdomain呢?还待研究````

而且/var/spool/mail 下的邮件文件在阅读后,都变的很小了,但/var/分区还是占用较大,du一把:
[root@mob2 var]# du -sh ./*
...
344M     ./spool
...

随手ls一个文件夹:/var/spool/mqueue ,竟然翻了不知多少屏的文件,看名字,这应该是sendmail的邮件队列文件夹。mailq一把:
# mailq |less
l3TCx1Me027333      110 Sun Apr 29 20:59 <nemo@mob2>
                 (Deferred: Connection refused by mob2.localdomain.)
                                         <nemo@mob2>

发现都是这种被拒绝连接的队列````汗````yikes

感觉原因是不是找不到这个mob2.localdomain主机名呢?修改一下/etc/hosts试试:
# vi /etc/hosts
127.0.0.1               localhost.localdomain localhost mob2.localdomain
192.168.4.148           mob2

重启一下sendmail服务,过了一会,显示nemo用户收到新邮件,查看一把,真是N多啊```看来邮件队列总算被发出去了。

使用yum更新Redhat ES 4


参考:使用yum自動更新RedHat AS 4

用Nessus扫描出一台rhel es 4服务器有很多(多达147个)漏洞,老板要求让我第一时间把High级别的漏洞解决。

查看了一下一百多页的扫描报告,这台机器大部分的漏洞都是说软件包的漏洞,Redhat官方网站都有说明的,升级版本就可以了。但是那么多软件包一个一个来找更新岂不太麻烦?何况还会有包依赖问题,会牵连出更多更多的包要更新````

于是计划使用apt或yum。

搜索了一下,如果用Yum来更新Fedora,那是方便至极,yum资源站点很多而且很新。但正统Redhat Linux的资源就少了,一般有更新到最高版本Redhat Linux 9,企业版rhel真是难觅。以前找到的Redhat官方的下载资源也丢了````

后来搜索到如上文章,用Centos的资源来更新rhel。Centos改自rhel,应该是差不多的,于是一试```

首先用http://rpm.pbone.net/搜了一个yum-2.9.4-74.el4.at.i386.rpm ,安装时显示:

# rpm -ivh yum-2.9.4-74.el4.at.i386.rpm 
warning: yum-2.9.4-74.el4.at.i386.rpm: V3 DSA signature: NOKEY, key ID 66534c2b
error: Failed dependencies:
        /usr/lib/python2.3/site-packages/elementtree is needed by yum-2.9.4-74.el4.at.i386
        /usr/lib/python2.3/site-packages/rpm is needed by yum-2.9.4-74.el4.at.i386
        /usr/lib/python2.3/site-packages/sqlite is needed by yum-2.9.4-74.el4.at.i386
        /usr/lib/python2.3/site-packages/sqlitecachec.py is needed by yum-2.9.4-74.el4.at.i386
        /usr/lib/python2.3/site-packages/urlgrabber is needed by yum-2.9.4-74.el4.at.i386
        python(abi) = 2.3 is needed by yum-2.9.4-74.el4.at.i386
    Suggested resolutions:
        yum-2.1.11-3.noarch.rpm

后来找到似乎是yum的官方站点——Yellow dog Updater, Modified,哈哈,很多版本````

上面提示建议安装yum-2.1.11-3.noarch.rpm,那就下载了个yum-2.1.11-1.noarch.rpm 。安装OK:

# rpm -ivh yum-2.1.11-1.noarch.rpm 
warning: yum-2.1.11-1.noarch.rpm: V3 DSA signature: NOKEY, key ID 69886cc7
Preparing...                ########################################### [100%]
   1:yum                    ########################################### [100%]

下面开始配置yum:

# vi /etc/yum.conf 

[base]
name=CentOS 4.4 for RHEL4 - Base
baseurl=http://mirror.be10.com/centos/4/os/i386/
#因为我的系统是rhel es 4(没有update的)

[updates]
name=CentOS 4.4 for RHEL4 - Updates
baseurl=http://mirror.be10.com/centos/4/updates/i386/

下面来更新```
首先有个漏洞是关于vim的,先来查查vim:

# yum list |less
...
vim-common.i386                          1:6.3.035-3            installed       
vim-enhanced.i386                        1:6.3.035-3            installed       
vim-minimal.i386                         1:6.3.035-3            installed  
...

更新一下试试:

# yum update vim-common
Setting up Update Process
Setting up Repo:  base
repomd.xml                100% |=========================| 1.1 kB    00:00     
Setting up Repo:  updates
repomd.xml                100% |=========================|  951 B    00:00     
Reading repository metadata in from local files
base      : ################################################## 1499/1499
updates   : ################################################## 346/346
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for vim-common to pack into transaction set.
vim-common-6.3.046-0.40E. 100% |=========================| 116 kB    00:00     
---> Package vim-common.i386 1:6.3.046-0.40E.7 set to be updated
--> Running transaction check
--> Processing Dependency: vim-common= 1:6.3.035-3 for package: vim-enhanced
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for vim-enhanced to pack into transaction set.
vim-enhanced-6.3.046-0.40 100% |=========================| 7.2 kB    00:00     
---> Package vim-enhanced.i386 1:6.3.046-0.40E.7 set to be updated
--> Running transaction check

Dependencies Resolved
Transaction Listing:
  Update: vim-common.i386 1:6.3.046-0.40E.7

Performing the following to resolve dependencies:
  Update: vim-enhanced.i386 1:6.3.046-0.40E.7
Is this ok [y/N]: y
Downloading Packages:
vim-common-6.3.046-0.40E. 100% |=========================| 3.4 MB    00:03     
vim-enhanced-6.3.046-0.40 100% |=========================| 956 kB    00:01     
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating: vim-common 100 % done 1/4 
Updating: vim-enhanced 100 % done 2/4 
Completing update for vim-common  - 3/4
Completing update for vim-enhanced  - 4/4

Updated: vim-common.i386 1:6.3.046-0.40E.7
Dependency Updated: vim-enhanced.i386 1:6.3.046-0.40E.7
Complete!

看,自动解决包依赖关系,自动 下载更新,爽````!

编译出现<undefined reference to `_Unwind_Resume'>或<invalid option `tune=pentium4'>错误问题解决


运行环境:
rhel es 4
Oracle 10g 10.1.0.3

=========================================================

在rhel es 4上安装fcgi-2.4.0,编译时出现如下错误:

g++ -g -O2 -o .libs/echo-cpp echo-cpp.o  ../libfcgi/.libs/libfcgi++.so /home/nemo/build/fcgi-2.4.0/libfcgi/.libs/libfcgi.so -lnsl -Wl,--rpath -Wl,/usr/local/lib
echo-cpp.o(.text+0x443): In function `main':
/home/lee/build/fcgi-2.4.0/examples/echo-cpp.cpp:175: undefined reference to `_Unwind_Resume'
collect2: ld returned 1 exit status
make[2]: *** [echo-cpp] Error 1

还有就是安装ImageMagick-6.3.2,编译时有这样的错误:

gcc -c  -I../ -I.. -I/usr/include/freetype2 -I/X11 -I/usr/include/libxml2 -D_REENTRANT -

D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -

D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -g -O2 -Wall -W -pthread -O2 -g -pipe -m32 -march=i386 

-mtune=pentium4   -DVERSION=\"6.3.2\" -DXS_VERSION=\"6.3.2\" -fPIC "-I/usr/lib/perl5/5.8.5/i386-

linux-thread-multi/CORE"  -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magick.c
cc1: invalid option `tune=pentium4'
make[1]: *** [Magick.o] Error 1

google了一下,大概发现是gcc版本的问题。
这台机器安装了Oracle 10g,安装前有一些compat版gcc是需要安装的:

compat-libgcc-296-2.96-132.7.2
compat-gcc-32-c++-3.2.3-47.3
compat-gcc-32-3.2.3-47.3

是不是这些补丁引起gcc不符合要求呢?
对比一下这台机器和其他没有安装oracle的机器(即没有安装gcc compat补丁)的gcc和g++版本信息:

安装了Oracle的机器:

$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++ --disable-libgcj --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47.3)

$ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++ --disable-libgcj --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-47.3)

没有安装Oracle的机器:

$ gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --

enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit 

--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

$ g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --

enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit 

--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

应该有多个gcc,我们来找一找:

$ which gcc
/usr/bin/gcc
$ cd /usr/bin
$ ls gcc*
gcc  gcc32  gcc.orig

有三个,gcc32应该是3.2版的,我们来看下gcc.orig的信息:

$ gcc.orig -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

OK!符合!应该就是它了!
再来看看g++ :

$ ls g++*
g++  g++32  g++.orig
$ g++.orig -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

OK!都找到了!
把原来的gcc和g++备份一下,拷贝 gcc.orig 和 g++.orig 为gcc/g++ ,重新编译,成功!````

新版GPL 3草案周三发布


新版GPL 3草案周三发布

自由软件的根基 GNU General Public License (GPL) 3 将在周三(2007/03/28/)早上发布,根据自由软件基金会FSF周一的说法,新的草案将修正许可中的语言表达,以防止类似于Novell和Microsoft前些日子达成的交易行为生成.开源软件团体多次延迟了新版GPL的产生,连Linux之父Linus都曾多次公开反对GPL v3.

v3草案将公开接受意见60天,之后FSF将发布一个最终草案进行30天的公开审核.GPL v3将对自由软件界产生深远影响,发布后,FSF所控制的GNU系统将全面迁移到GPL3下(Linux暂时仍然工作在v2,原因前面说过了).

cnBeta采译自CRN
查看:New GPL 3 Draft Due Wednesday

Linux媒体中心--LinuxMCE(Wow!)


Linux媒体中心--LinuxMCE(Wow!)

Linux媒体中心--LinuxMCE,外观可一点不比微软的差!LinuxMCE,是基于MythTV核心.据官方称,目前只支持ubuntu 6.10,其他版本需要等待.内含截图和下载,Linux爱好者们千万别错过!






观看:一段Google Video
访问:LinuxMCE

网络安全工具介绍

网络安全工具介绍

开源界的安全/黑客工具真是数都数不过来,装好的Linux系统本身就带很多工具,而且都大名鼎鼎,非常好用。下面是一些网上看到的工具(也有w!ndow$下的),做个记录。

工具: Smokeping (网络延迟监测工具)
网址: http://people.ee.ethz.ch/~oetiker/webtools/smokeping/
类别:开放源码
平台: Linux/BSD/Unix/Windows
简介: Smokeping 延迟监测工具采用 ping 等多种方式监测从网管中心到出口的各条重要线路的延迟情况。利用这一工具可以监测网络的性能是否能满足各种应用的需要。 SmokePing 工作的方式与 MRTG 类似。使用 RRDtool 作为自己登录和图形化后台,整个系统工作效率非常高
---------------------------------------------------------------------

工具: getif ( MIB 浏览器)
网址: http://www.wtcs.org/snmp4tpc/getif.htm

类别:开放源码
平台: /Windows
简介: Getif 是一个 windows 版的 MIB 浏览器。输入某设备的 IP 地址和 snmp 读密码,就可以查看该设备上所有支持的 SNMP MIB 值。
---------------------------------------------------------------------

工具: Ethereal (网络协议检测工具)
网址: http://www.ethereal.com/
类别:开放源码
平台: Linux/BSD/Unix/Windows
简介: Ethereal 是一款免费的网络协议分析程序,支持 Unix 、 Windows 。借助这个程序,你既可以直接从网络上抓取数据进行分析,也可以对由其他嗅探器抓取后保存在硬盘上的数据进行分析。你能交互式地浏览抓取到的数据包,查看每一个数据包的摘要和详细信息。 Ethereal 有多种强大的特征,如支持几乎所有的协议、丰富的过滤语言、易于查看 TCP 会话经重构后的数据流等。
---------------------------------------------------------------------

工具: Iperf (网络性能测量工具)
网址: http://dast.nlanr.net/Projects/Iperf/
类别:开放源码
平台: Linux/BSD/Unix/Windows
简介: Iperf 是一个 TCP/IP 和 UDP/IP 的性能测量工具,能够提供网络吞吐率信息,以及震动、丢包率、最大段和最大传输单元大小等统计信息;从而能够帮助我们测试网络性能,定位网络瓶颈。其设计从根本上克服了原来的一些工具,如 ttcp 和 nettest 等的固有的缺陷。

----------------------------------------------------------------------
工具: Snort (免费的入侵检测系统)
网址: http://www.snort.org/
类别:开放源码
平台: Linux/BSD/Unix/Windows
简介: Snort 是一款轻量级的网络入侵检测系统,能够在 IP 网络上进行实时的流量分析和数据包记录。它不仅能进行协议分析、内容检索、内容匹配,而且能用于侦测诸如缓冲溢出、隐秘端口扫描、 CGI 攻击、 SMB 探测、操作系统指纹识别等大量的攻击或非法探测。 Snort 使用灵活的规则去描述哪些流量应该被收集或被忽略,并且提供一个模块化的探测引擎。

-----------------------------------------------------------------------
工具: Netcat (网络瑞士军刀)
网址: http://www.atstake.com/research/tools/network_utilities/
类别:开放源码
平台: Linux/BSD/Unix/Windows
简介:一个简单而有用的工具,透过使用 TCP 或 UDP 协议的网络连接去读写数据。它被设计成一个稳定的后门工具,能够直接由其它程序和脚本轻松驱动。同时,它也是一个功能强大的网络调试和探测工具,能够建立你需要的几乎所有类型的网络连接,还有几个很有意思的内置功能。

------------------------------------------------------------------------
工具: TCPDump/WinDump (用于网络监测和数据收集的优秀嗅探器)
网址: http://www.tcpdump.org/http://windump.polito.it/
类别:开放源码
平台: Linux/BSD/Unix/Windows
简介: Tcpdump 是一款众人皆知和受人喜欢的基于命令行的网络数据包分析和嗅探工具。它能把匹配规则的数据包的包头给显示出来。你能使用这个工具去查找网络问题或者去监视网络上的状况。 WinDump 是 Tcpdump 在 Windows 平台上的移植版。

---------------------------------------------------------------------
工具: Hping2 (类似 ping 的网络探测工具)
网址: http://www.hping.org/
类别:开放源码
平台: Linux/BSD/Unix
简介: hping2 能发送自定义的 ICMP/UDP/TCP 包到目标地址并且显示包的响应情况。它有一个方便的 traceroute 模式,并且支持 IP 分片。这个工具在 traceroute 、 ping 和探测防火墙后的主机时特别有用。

---------------------------------------------------------------------
工具: Firewalk (高级的 traceroute )
网址: http://www.packetfactory.net/projects/firewalk/
类别:开放源码
平台: Linux/BSD/Unix
简介: Firewalk 使用类似 traceroute 的技术来分析 IP 包的响应,从而测定网关的访问控制列表和绘制网络图。 2002 年 10 月,这个一流的工具在原来的基础上进行了重新开发。需要注意到的是, Firewalk 里面的大多数功能也能由 Hping2 的 traceroute 选项来实现。

---------------------------------------------------------------------
工具: SolarWinds Toolsets (大量的网络发现、监视、攻击工具)
网址: http://www.solarwinds.net/
类别:商业
平台: Windows
简介: SolarWinds 包含大量适合系统管理员做特殊用途的工具,与安全相关的工具包括许多的网络发现扫描器( network discovery scanner )和一个 SNMP 强力破解器。

--------------------------------------------------------------------
工具: NGrep (方便的包匹配和显示工具)
网址: http://www.packetfactory.net/projects/ngrep/
类别:开放源码
平台: Linux/BSD/Unix/Windows
简介: NGrep 在网络层实现了 GNU grep 的大多数功能,基于 pcap ,可以使你通过指定扩展的正则表达式或十六进制表达式去匹配网络上的数据流量。它当前能够识别流经以太网、 PPP 、 SLIP 、 FDDI 、令牌网和回环设备上的 TCP 、 UDP 和 ICMP 数据包,并且和其他常见的嗅探工具(如 tcpdump 和 snoop )一样,理解 bpf 过滤机制。
---------------------------------------------------------------------

工具: NTop (网络使用状况监测软件)
网址: http://www.ntop.org/
类别:开放源码
平台: Linux/BSD/Unix/Windows
简介: Ntop 是一款显示网络使用状况的流量监测软件,类似于 UNIX 平台上监视系统进程的 top 命令。在交互模式下, ntop 会将网络的使用状况显示在用户的终端上;在 Web 模式下, ntop 会做为一个 web 服务器,创建包含网络状况的 HTML 网页返回给用户。
----------------------------------------------------------------------

工具: Paketto Keiretsu (极端的 TCP/IP )
网址: http://www.doxpara.com/paketto
类别:开放源码
平台: Linux/BSD/Unix
简介: Paketto Keiretsu 是一组使用新式的不常见的策略去操作 TCP/IP 网络的工具集合,开发的最初本意是为了在现有 TCP/IP 架构里去实现一些功能,但现在已经远远超出了最初的本意。包含的工具有: Scanrand ,一个罕见的快速的网络服务和拓朴发现系统; Minewt ,一个 NAT/MAT 路由器; linkcat ,把以太网链路做为标准的输入输出; Paratrace ,不产生新的连接就能追踪网络路径; Phentropy ,使用 OpenQVIS 在三维拓朴空间里能绘制出任意总量的数据源图形。

安装DNS缓存服务器-djbdns


公司服务器集群想搞个DNS缓存服务器,以提高DNS解析速度。本来rhel4自带的BIND9默认配置就是缓存服务器了,老大说搞个其他的,用BIND好像有点小题大作````提供给我了一些资料,里面有个djbdns。

我了解了一下,原来djbdns是qmail作者写的一个简单、高效和安全的DNS cache Server,下面是一些网上介绍:

djbdns 是一個由 Qmail 的作者所設計的新一代 DNS server ,這套djbdns採用了跟BIND不同的思考方向,在程式的架構上也和BIND一手撐天的做法完全不同。它採用模組化的方式,將DNS運作上的各個角色都適當地分配到不同程式上面。採用UNIX的設計哲學,堅持讓一個程式做好一件事的方式,將DNS中最主要的Cache Server、Content Server的角色分離開來,由不同的程式來負責不同的事。

本人本来就非常喜欢qmail,这样爱屋及乌,马上着手研究安装djbdns!

下面给大家介绍一下安装方法:

安装环境:
redhat enterprise linux 4
daemontools 0.76
ucspi-tcp 0.88
djbdns 1.05 (http://cr.yp.to/djbdns.html)

1. 安装djbdns前,需要安装两个工具,即daemontoolsucspi-tcp

1)daemontools是一个收集管理UNIX进程的工具.用它来监听djbdns进程

     mkdir -p /package
     chmod 1755 /package
     cd /package
     gunzip daemontools-0.76.tar
     tar -xpf daemontools-0.76.tar
     rm daemontools-0.76.tar
     cd admin/daemontools-0.76
     package/install

很简单吧,这样就安装完了;下面来安装ucspi-tcp:

2)ucspi-tcp软件包由一组工具组成。它们用来简单的建立客户机-服务器tcp后台程序。TcpServer是一个比inetd安全性更好的选择。它内建有基于规则的连接控制,能完善地在达到预定义的最大系统负载时将连接推迟,这点比 inetd好。

     gunzip ucspi-tcp-0.88.tar
     tar -xf ucspi-tcp-0.88.tar
     cd ucspi-tcp-0.88
     make
     make setup check


2. 真是简单,现在我们来安装我们的主角-djbdns

1) 如果你想把参考文档安装在本机,以便方便使用elinks来查看,则:

   gunzip < doc.tar.gz | (cd /; tar -xf -)

然后运行slashdoc-merge脚本来生成 /doc/commands.html index文件就可以啦````

2) 安装djbdns-1.05

     gunzip djbdns-1.05.tar
     tar -xf djbdns-1.05.tar
     cd djbdns-1.05
     echo gcc -O2 -include /usr/include/errno.h > conf-cc
     make
     make setup check

哈,真是简单````

3. 配置djbdns让它成为你的网络的DNS Cache Server

1) 首先以root用户创建两个系统账户,名字为Gdnscache and Gdnslog;

2) 以root用户来建立/etc/dnscache 服务目录(命令的最后接你机器的IP)

dnscache-conf Gdnscache Gdnslog /etc/dnscache 10.53.0.1

这个目录包含一些日志文件和一些配置文件。

3) 以root用户,告诉svscan这个新服务,并使用svstat命令检查运行状态

     ln -s /etc/dnscache /service
     sleep 5
     svstat /service/dnscache

4) 以root用户,在/etc/dnscache/root/ip目录建立文件,限制只有你希望的客户端IP才能使用这个DNS CACHE,如:

    touch /etc/dnscache/root/ip/10.53.0

这样10.53.0.*的IP客户端才能使用你的DNS CACHE。

5) 在/etc/resolv.conf中设置DNS为本机,加nameserver 10.53.0.1 为第一行。测试一下:
     dnsip www.cnn.com
     dnsip www.fsf.org

看能不能返回IP地址?哈哈```恭喜你,成功了!

6) 默认djbdns使用1MB的内存作为它的cache,你可以调整为100MB:

     echo 100000000 > /service/dnscache/env/CACHESIZE
     echo 104857600 > /service/dnscache/env/DATALIMIT
     svc -t /service/dnscache    #重启dnscache

目前最全的网通和电信IP段


    电信的                        |                网通的   
    58.32.0.0/13              |                58.16.0.0/16     
    58.40.0.0/15              |                58.17.0.0/17     
    58.42.0.0/16              |                58.17.128.0/17   
    58.43.0.0/16              |                58.18.0.0/16     
    58.44.0.0/14              |                58.19.0.0/16     
    58.48.0.0/13              |                58.20.0.0/16     
    58.56.0.0/15              |                58.21.0.0/16     
    58.58.0.0/16              |                58.22.0.0/15     
    58.59.0.0/17              |                58.240.0.0/15    
    58.60.0.0/14              |                58.242.0.0/15    
    58.208.0.0/12             |                58.244.0.0/15    
    59.32.0.0/13              |                58.246.0.0/15    
    59.40.0.0/15              |                58.248.0.0/13    
    59.42.0.0/16              |                60.0.0.0/13      
    59.43.0.0/16              |                60.8.0.0/15      
    59.44.0.0/14              |                60.10.0.0/16     
    59.48.0.0/16              |                60.11.0.0/16     
    59.49.0.0/17              |                60.12.0.0/16     
    59.49.128.0/17            |                60.13.0.0/18     
    59.50.0.0/16              |                60.13.128.0/17   
    59.51.0.0/17              |                60.14.0.0/15     
    59.51.128.0/17            |                60.16.0.0/13     
    59.52.0.0/14              |                60.24.0.0/14     
    59.56.0.0/14              |                60.28.0.0/15     
    59.60.0.0/15              |                60.30.0.0/16     
    59.62.0.0/15              |                60.31.0.0/16     
    60.160.0.0/15             |                60.208.0.0/13    
    60.162.0.0/15             |                60.216.0.0/15    
    60.164.0.0/15             |                60.218.0.0/15    
    60.168.0.0/13             |                60.220.0.0/14    
    60.176.0.0/12             |                61.48.0.0/13     
    61.132.0.0/16             |                61.133.0.0/17    
    61.133.128.0/17           |                61.134.96.0/19   
    61.134.0.0/18             |                61.134.128.0/17  
    61.134.64.0/19            |                61.135.0.0/16    
    61.136.128.0/17           |                61.137.128.0/17  
    61.137.0.0/17             |                61.138.0.0/17    
    61.138.192.0/18           |                61.138.128.0/18  
    61.139.0.0/17             |                61.139.128.0/18  
    61.139.192.0/18           |                61.148.0.0/15    
    61.140.0.0/14             |                61.156.0.0/16    
    61.144.0.0/14             |                61.159.0.0/18    
    61.152.0.0/14             |                61.161.0.0/18    
    61.157.0.0/16             |                61.161.128.0/17  
    61.159.64.0/18            |                61.162.0.0/16    
    61.159.128.0/17           |                61.163.0.0/16    
    61.160.0.0/16             |                61.167.0.0/16    
    61.161.64.0/18            |                61.168.0.0/16    
    61.164.0.0/15             |                61.176.0.0/16    
    61.166.0.0/16             |                61.179.0.0/16    
    61.169.0.0/16             |                61.181.0.0/16    
    61.170.0.0/15             |                61.182.0.0/16    
    61.172.0.0/14             |                61.189.0.0/17    
    61.177.0.0/16             |                125.32.0.0/16    
    61.178.0.0/16             |                202.96.0.0/18    
    61.180.0.0/17             |                202.96.64.0/21   
    61.183.0.0/16             |                202.96.72.0/21   
    61.184.0.0/14             |                202.97.128.0/18  
    61.188.0.0/16             |                202.97.224.0/21  
    61.189.128.0/17           |                202.97.240.0/20  
    61.190.0.0/15             |                202.98.0.0/21    
    125.64.0.0/13             |                202.98.8.0/21    
    125.72.0.0/16             |                202.99.64.0/19   
    125.80.0.0/13             |                202.99.96.0/21   
    125.88.0.0/13             |                202.99.128.0/19  
    125.104.0.0/13            |                202.99.160.0/21  
    125.112.0.0/12            |                202.99.168.0/21  
    202.96.96.0/21            |                202.99.176.0/20  
    202.96.104.0/21           |                202.99.208.0/20  
    202.96.112.0/20           |                202.99.224.0/21  
    202.96.128.0/21           |                202.99.232.0/21  
    202.96.136.0/21           |                202.99.240.0/20  
    202.96.144.0/20           |                202.102.128.0/21 
    202.96.160.0/21           |                202.102.224.0/21 
    202.96.168.0/21           |                202.102.232.0/21 
    202.96.176.0/20           |                202.106.0.0/16   
    202.96.200.0/21           |                202.107.0.0/17   
    202.96.208.0/20           |                202.108.0.0/16   
    202.96.224.0/21           |                202.110.0.0/17   
    202.97.0.0/21             |                202.111.128.0/18 
    202.97.8.0/21             |                203.93.8.0/24    
    202.97.16.0/20            |                203.93.192.0/18  
    202.97.32.0/19            |                210.13.128.0/17  
    202.97.64.0/19            |                210.14.160.0/19  
    202.97.96.0/20            |                210.14.192.0/19  
    202.97.112.0/20           |                210.15.32.0/19   
    202.98.32.0/21            |                210.15.96.0/19   
    202.98.48.0/20            |                210.15.128.0/18  
    202.98.64.0/19            |                210.21.0.0/16    
    202.98.96.0/21            |                210.52.128.0/17  
    202.98.128.0/19           |                210.53.0.0/17    
    202.98.160.0/21           |                210.53.128.0/17  
    202.98.168.0/21           |                210.74.96.0/19   
    202.98.192.0/21           |                210.74.128.0/19  
    202.98.200.0/21           |                210.82.0.0/15    
    202.98.208.0/20           |                218.8.0.0/14     
    202.98.224.0/21           |                218.12.0.0/16    
    202.98.232.0/21           |                218.21.128.0/17  
    202.98.240.0/20           |                218.24.0.0/14    
    202.99.192.0/21           |                218.56.0.0/14    
    202.100.96.0/21           |                218.60.0.0/15    
    202.100.104.0/21          |                218.67.128.0/17  
    202.100.112.0/20          |                218.68.0.0/15    
    202.100.136.0/21          |                218.104.0.0/14   
    202.100.160.0/21          |                219.154.0.0/15   
    202.100.168.0/21          |                219.156.0.0/15   
    202.100.176.0/20          |                219.158.0.0/17   
    202.100.192.0/21          |                219.158.128.0/17 
    202.100.208.0/20          |                219.159.0.0/18   
    202.100.224.0/19          |                220.252.0.0/16   
    202.101.0.0/18            |                221.0.0.0/15     
    202.101.64.0/19           |                221.2.0.0/16     
    202.101.96.0/19           |                221.3.0.0/17     
    202.101.128.0/18          |                221.3.128.0/17   
    202.101.224.0/21          |                221.4.0.0/16     
    202.102.0.0/19            |                221.5.0.0/17     
    202.102.32.0/19           |                221.5.128.0/17   
    202.102.64.0/18           |                221.6.0.0/16     
    202.103.0.0/21            |                221.7.0.0/19     
    202.103.8.0/21            |                221.7.32.0/19    
    202.103.16.0/20           |                221.7.64.0/19    
    202.103.32.0/19           |                221.7.96.0/19    
    202.103.192.0/19          |                221.8.0.0/15     
    202.103.224.0/21          |                221.10.0.0/16    
    202.104.0.0/15            |                221.11.0.0/17    
    202.107.128.0/17          |                221.11.128.0/18  
    202.109.0.0/16            |                221.11.192.0/19  
    202.110.128.0/18          |                221.12.0.0/17    
    202.111.0.0/17            |                221.12.128.0/18  
    203.130.32.0/19           |                221.13.0.0/18    
    203.212.0.0/20            |                221.13.64.0/19   
    210.192.96.0/19           |                221.13.96.0/19   
    218.4.0.0/15              |                221.13.128.0/17  
    218.6.0.0/16              |                221.14.0.0/15    
    218.13.0.0/16             |                221.192.0.0/15   
    218.14.0.0/15             |                221.194.0.0/16   
    218.16.0.0/14             |                221.195.0.0/16   
    218.20.0.0/16             |                221.196.0.0/15   
    218.21.0.0/17             |                221.198.0.0/16   
    218.22.0.0/15             |                221.199.0.0/19   
    218.30.0.0/15             |                221.199.32.0/20  
    218.62.128.0/17           |                221.199.128.0/18 
    218.63.0.0/16             |                221.199.192.0/20 
    218.64.0.0/15             |                221.200.0.0/14   
    218.66.0.0/16             |                221.204.0.0/15   
    218.67.0.0/17             |                221.206.0.0/16   
    218.70.0.0/15             |                221.207.0.0/18   
    218.72.0.0/13             |                221.207.64.0/18  
    218.80.0.0/12             |                221.207.128.0/17 
    219.128.0.0/12            |                221.208.0.0/14   
    219.144.0.0/13            |                221.212.0.0/16   
    219.152.0.0/15            |                221.213.0.0/16   
    219.159.64.0/18           |                221.216.0.0/13   
    219.159.128.0/17          |                222.128.0.0/14   
    220.160.0.0/11            |                222.132.0.0/14   
    221.224.0.0/13            |                222.136.0.0/13   
    221.232.0.0/14            |                222.160.0.0/15   
    221.236.0.0/15            |                222.162.0.0/16   
    221.238.0.0/16            |                222.163.0.0/19   
    221.239.0.0/17            |                222.163.32.0/19  
    221.239.128.0/17          |                222.163.64.0/18  
    222.72.0.0/15             |                222.163.128.0/17 
    222.74.0.0/16             |
    222.75.0.0/16             |
    222.76.0.0/14             |
    222.80.0.0/15             |
    222.82.0.0/16             |
    222.83.0.0/17             |
    222.83.128.0/17           |
    222.84.0.0/16             |
    222.85.0.0/17             |
    222.85.128.0/17           |
    222.86.0.0/15             |
    222.88.0.0/15             |
    222.90.0.0/15             |
    222.92.0.0/14             |
    222.168.0.0/15            |
    222.172.0.0/17            |
    222.172.128.0/17          |
    222.173.0.0/16            |
    222.174.0.0/15            |
    222.176.0.0/13            |
    222.184.0.0/13            |
    222.208.0.0/13            |
    222.216.0.0/15            |
    222.218.0.0/16            |
    222.219.0.0/16            |
    222.220.0.0/15            |
    222.222.0.0/15            |
    222.240.0.0/13            |
                              |

终于解决不能发送邮件到sohu


公司添置一批新服务器到汕头电信机房,我搭建了一台qmail邮件服务器。后来测试发现不能发送邮件到sohu,但可以收到sohu的来信。qmail日志显示如下:
2007-03-06 13:26:07.476335500 starting delivery 16148: msg 146196 to remote cnfx8888@sohu.com
2007-03-06 13:26:07.476354500 status: local 0/10 remote 1/20
2007-03-06 13:26:07.482487500 delivery 16148: deferral: Sorry,_I_wasn't_able_to_establish_an_SMTP_connection._(#4.4.1)/

telnet一下sohu的mx服务器,发现:
[root@web home]# date
Tue Mar  6 13:25:55 CST 2007

[root@web home]# host -t mx sohu.com
sohu.com mail is handled by 10 sohumx.h.a.sohu.com.

[root@web home]# telnet sohumx.h.a.sohu.com 25
Trying 61.135.132.100...
telnet: connect to address 61.135.132.100: Connection timed out
telnet: Unable to connect to remote host: Connection timed out
[root@web home]# 

根本不能连接它的25端口。试了其他10几台机器(同一个IP段内)都是一样。
开始比较忙,没时间去理,怀疑有可可能是电信机房的防火墙拦截了到sohu的25端口连接。但联系电信,,,你知道,他们应该效率比较低,也就没管了。
年后回来,这两天有点时间,就跟sohu沟通了一下,几天后问题解决,哈哈````高兴!!yes
原来是服务器所属IP段曾经发送大量flg反动邮件,故被封了`````晕吧``````faint

-----------------------------------------------------
下面是来往的邮件原文:

您好:
经工程师检查,贵公司IP:125.***.***.xxx-125.***.***.yyy 所属IP段去年发送过大量flg反动邮件,所以IP段被前端设备拒收
所以之前我们在系统中没有查到
现已解除封锁
稍后可测试

谢谢
-----------------------------------------------------

Linux下增加apache的mod_rewrite模块


安装环境:rhel es 4
apache:1.3.37(源码自己编译安装)
gdbm:1.8.3

1. Apache安装rewrite模块的时候需要DBM支持,否则无法编译,表现为:
[nemo@web standard]$ ~/apache/bin/apxs -c mod_rewrite.c
gcc -DLINUX=22 -DHAVE_SET_DUMPABLE -DUSE_HSREGEX -fpic -DSHARED_MODULE -I/home/nemo/apache/include  -c mod_rewrite.c
In file included from mod_rewrite.c:51:
mod_rewrite.h:91:18: ndbm.h: No such file or directory
mod_rewrite.c: In function `lookup_map_dbmfile':
mod_rewrite.c:3035: error: `DBM' undeclared (first use in this function)
mod_rewrite.c:3035: error: (Each undeclared identifier is reported only once
mod_rewrite.c:3035: error: for each function it appears in.)
mod_rewrite.c:3035: error: `dbmfp' undeclared (first use in this function)
mod_rewrite.c:3036: error: `datum' undeclared (first use in this function)
mod_rewrite.c:3036: error: syntax error before "dbmkey"
mod_rewrite.c:3044: error: `dbmkey' undeclared (first use in this function)
mod_rewrite.c:3047: error: `dbmval' undeclared (first use in this function)
apxs:Break: Command failed with rc=1
[nemo@web standard]$ rpm -qa |grep gdbn
[nemo@web standard]$ rpm -qa |grep gdbm
gdbm-1.8.0-24
gdbm-devel-1.8.0-24

所以首先要安装一个GDBM :下载地址:ftp://ftp.gnu.org/gnu/gdbm/
GDBM安装步骤: 进入安装目录,
./configure
make
make install
make install-compat #否则无法编译出ndbm.h头文件.

2. 然后进入到apache源码包解压目录apache_1.3.37/src/modules/standard,用Apache bin目录下的apxs命令安装,注意apxs使用绝对路径:
cd /path/to/apache_1.3.37/src/modules/standard/
/usr/local/apache/bin/apxs -c mod_rewrite.c 
/usr/local/apache/bin/apxs -i -a -n mod_rewrite mod_rewrite.so

然后在http.conf配置文件里加上:
LoadModule rewrite_module libexec/mod_rewrite.so

接下来用
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start

停止apache,然后用再start,千万注意,在这里不能用restart或者graceful参数来重新启动apache,必须先停止,然后再开始,否则rewrite将不起作用。

如果你跟我一样的不幸,遇到dbm_fetch错误问题,那么请按我的尝试来操作:

执行完/usr/local/apache/bin/apxs -i -a -n mod_rewrite mod_rewrite.so后,这个命令已经帮我们复制mod_rewrite.so模块到libexec目录下并且修改好了httpd.conf文件,但测试却出现dbm_fetch错误:
[root@web conf]# ../bin/apachectl configtest
Syntax error on line 16 of /home/nemo/apache/conf/httpd.conf:
Cannot load /home/nemo/apache/libexec/mod_rewrite.so into server: /home/nemo/apache/libexec/mod_rewrite.so: undefined symbol: dbm_fetch

google一下,马上发现一篇文章写有解决方法(本文最后贴出),继续尝试:
到 apache_1.3.37/src/modules/standard 目录,执行一下这个命令:
gcc -shared -o mod_rewrite.so mod_rewrite.o -lgdbm
cp mod_rewrite.so /usr/local/apache/libexec/

重新检查一下:
[root@web conf]# ../bin/apachectl configtest
Syntax error on line 16 of /home/nemo/apache/conf/httpd.conf:
Can't locate API module structure `mod_rewrite_module' in file /home/nemo/apache/libexec/mod_rewrite.so: /home/nemo/apache/libexec/mod_rewrite.so: undefined symbol: mod_rewrite_module

修改 httpd.conf ,将
LoadModule mod_rewrite_module	 libexec/mod_rewrite.so
改为
LoadModule mod_rewrite	 libexec/mod_rewrite.so

检查一下:
[root@web conf]# ../bin/apachectl configtest
Syntax error on line 16 of /home/nemo/apache/conf/httpd.conf:
Can't locate API module structure `mod_rewrite' in file /home/nemo/apache/libexec/mod_rewrite.so: /home/nemo/apache/libexec/mod_rewrite.so: undefined symbol: mod_rewrite

靠!再改:
LoadModule rewrite_module libexec/mod_rewrite.so

检查:
[root@web conf]# ../bin/apachectl configtest
Syntax OK

NND,总算搞定了!
[root@web conf]# ../bin/apachectl restart   
../bin/apachectl restart: httpd restarted

-------------------------------------
google到的解决方法:
http://www.vttoth.com/rewrite.htm
Technical Notes: Undefined symbol 'dbm_fetch' with the Apache server

I tried to include in my Apache Web server's configuration the mod_rewrite module, but when I restarted the server, I received an error:
Cannot load /usr/local/apache/libexec/mod_rewrite.so into server:
/usr/local/apache/libexec/mod_rewrite.so: undefined symbol: dbm_fetch

The problem, as it turns out, is that mod_rewrite.so is compiled incorrectly. It should be linked with a dbm library but it isn't.

If you have an up-to-date set of Apache source files, you can easily solve this problem by manually rerunning the last compilation step of this module, using the correct options. When you execute make mod_rewrite.so in the appropriate directory, it performs this final step:
gcc -shared -o mod_rewrite.so mod_rewrite.lo

Rerun gcc, this time adding a reference to the GNU gdbm library:
gcc -shared -o mod_rewrite.so mod_rewrite.lo -lgdbm

Next, copy the newly created mod_rewrite.so over to /usr/local/apache/libexec or wherever your Apache module files are located.

In my case, this was all that was needed to solve the problem. Your mileage may vary.