20

       先前曾经简单介绍过在CentOS5.2下搭建实现DNS服务器,可查看这里

       现在就再简单大致记录介绍三款常用于检查测试调试DNS服务器搭建是否成功的工具吧~即Dig、Host、Nslookup,介绍:

      
Shell方式可以使用3种工具来查询DNS数据库:nslookup、dig和host,在BIND的软件发布中包括nslookup和dig。
Nslookup是这三个工具中最老的,而且总是随同BIND一起发布;dig是域信息的探索程序,最初由SteveHotz编写,后来
MichaelSawy针对BIND 9将它重新编写,它也和BIND一起发布;host由Eric
Wassenaar编写,是另一个开放源代码的工具,其特点是输出对用户很友好,功能是可检查区文件的语法。另外三者使用的解析器库不同:dig和
host使用BIND的解析器,而nslookup有其自身的解析器。

       (1)、Dig命令

Usage:  dig [@global-server] [domain] [q-type] [q-class] {q-opt}
            {global-d-opt} host [@local-server] {local-d-opt}
            [ host [@local-server] {local-d-opt} [...]]

      
以上是关于dig用法参数列表,可以通过man dig 或者 dig –h | more 查看其命令相应的帮助信息~ 参数可接IP
address或domain name来获得name server所提供的相关讯息,提供不同资料记录型态,例如A、MX…等等

      (2)、Host命令

[root@yanqx ~]$ host -h              
host: illegal option — h
Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]
            [-R number] hostname [server]
       -a is equivalent to -v -t *
       -c specifies query class for non-IN data
       -C compares SOA records on authoritative nameservers
       -d is equivalent to -v
       -l lists all hosts in a domain, using AXFR
       -i IP6.INT reverse lookups
       -N changes the number of dots allowed before root lookup is done
       -r disables recursive processing
       -R specifies number of retries for UDP packets
       -t specifies the query type
       -T enables TCP/IP mode
       -v enables verbose output
       -w specifies to wait forever for a reply
       -W specifies how long to wait for a reply
       -4 use IPv4 query transport only
       -6 use IPv6 query transport only

       默认情况下,只是简单使用host+欲查询域名得到只是简单一些A记录或MX记录等,想了解全部信息需加上 –a 参数查看 如:

[root@yanqx ~]$ host qingxianyan.cn
qingxianyan.cn has address 74.220.219.76
qingxianyan.cn mail is handled by 0 qingxianyan.cn.

   (3)、Nslookup命令

       在linux或win下
入nslookup命令后,会看到 > 提示符号,之后就可输入查询指令。一般会输入IP address或是domain
name来做反向及正向的解析。而nslookup不仅提供上述2种解析,亦像dig提供DNS中其它的资料记录型态,例如A、MX、NS…等等,可在提
示符号直接输入”?”来获得所有可以使用的参数或资料型态。

Commands:   (identifiers are shown in uppercase, [] means optional)
NAME            – print info about the host/domain NAME using default server
NAME1 NAME2     – as above, but use NAME2 as server
help or ?       – print info on common commands
set OPTION      – set an option
    all                 – print options, current server and host
    [no]debug           – print debugging information
    [no]d2              – print exhaustive debugging information
    [no]defname         – append domain name to each query
    [no]recurse         – ask for recursive answer to query
    [no]search          – use domain search list
    [no]vc              – always use a virtual circuit
    domain=NAME         – set default domain name to NAME
    srchlist=N1[/N2/.../N6] – set domain to N1 and search list to N1,N2, etc.
    root=NAME           – set root server to NAME
    retry=X             – set number of retries to X
    timeout=X           – set initial time-out interval to X seconds
    type=X              – set query type (ex. A,ANY,CNAME,MX,NS,PTR,SOA,SRV)
    querytype=X         – same as type
    class=X             – set query class (ex. IN (Internet), ANY)
    [no]msxfr           – use MS fast zone transfer
    ixfrver=X           – current version to use in IXFR transfer request
server NAME     – set default server to NAME, using current default server
lserver NAME    – set default server to NAME, using initial server
finger [USER]   – finger the optional NAME at the current default host
root            – set current default server to the root
ls [opt] DOMAIN [> FILE] – list addresses in DOMAIN (optional: output to FILE)
    -a          -  list canonical names and aliases
    -d          -  list all records
    -t TYPE     -  list records of the given type (e.g. A,CNAME,MX,NS,PTR etc.)
view FILE           – sort an ‘ls’ output file and view it with pg
exit            – exit the program

     参考资料:http://docsrv.sco.com/NET_tcpip/dnsC.nslook.html

written by Yousri \\ tags: , , , ,

19

        Ubuntu操作系统安装完成后网络管理默认是用DHCP自动获取IP地址的,之前在自己住宿就一两台机使用反正也没啥差就懒得改为静态固定IP,但是最近在公司使用vm虚拟机下安装了台Ubuntu8.10玩一玩,有时基本使用SecureCRT软件SSH远程登陆使用,但是由于公司使用都是内部动态 IP地址,而且机器较多所以导致IP地址经常性更换,有点烦所以自己决定试图修改成使用静态IP,可是那个可恶的NetworkManager总是在重启后又变成默认的DHCP自动获取IP。。。故决定删除彻底NetworkManager

    sudo apt-get –purge remove network-manager
    sudo apt-get –purge remove network-manager-gnome

        手动设置静态IP地址:编辑修改网络接口配置文件/etc/network/interfaces

    sudo vim /etc/network/interfaces
    auto lo
    iface lo inet loopback
    auto eth0
    iface eth0 inet static
            address 172.17.4.170
            netmask 255.255.255.0
            network  172.17.4.1
            gateway 172.17.4.3

        修改设置DNS服务器配置文件/etc/resolv.conf

    sudo vim /etc/resolv.conf
    nameserver 202.101.103.54
    nameserver 202.101.103.55
    nameserver 172.17.4.1

        最后重启网络服务

sudo /etc/init.d/networking restart

        这样上网基本就没什么问题啦/// 如果你之前没有删除NetworkManager网络管理的话,重启后/etc/resolv.conf里面的配置文件又会被修改为

# Generated by NetworkManager

        导致又是使用DHCP动态分配IP地址的。

written by Yousri \\ tags: , ,

11

      Nagios的功能是监控服务和主机,但是他自身并不包括这部分功能的代码,所有的监控、检测功能都是有插件来完成的。再说报警功能,如果监控系统发现问题不能报警那就没有意义了,所以报警也是Nagios很重要的功能之一。但是,同样的,nagios自身也没有报警部分的代码,甚至没有插件,而是交给用户或者其他相关开源项目组去完成。类似这样细致的工作,被Nagios的开发人员称为dirty work(脏活)。其实脏活不脏,只是太细致了,对于nagios——一个负责监控工作的老板来说,细致的工作必然是交给他的员工去搞定啦。

      这里只小分享下关于Nagios安装,只是指基本平台,也就是Nagios软件包的安装。它是监控体系的框架,也是所有监控的基础。后续系列文章会再更多的分享

     在Nagios官方的文档,会发现Nagios基本上没有什么依赖包,只要求系统是linux或者其他nagios支持的系统。不过如果你没有安装Apache(http web服务),那么就没办法直观的界面来了解信息,所以apache可以算是一个前提条件。关于apache的安装,网上相关文档多得是,找Google老师~

      官方网站下载最新的nagios软件包,这里使用的是nagios-3.0.4.tar.gz版本下实现的 。建议先阅读官方文档相关帮助信息。

      1、 创建Nagios用户

adduser nagios
mkdir /usr/local/nagios
chown nagios.nagios /usr/local/nagios

     2、 建立Nagios组

grep "^User" /etc/httpd/conf/httpd.conf
/usr/sbin/usermod -G nagcmd apache #apache的用户名
/usr/sbin/usermod -G nagcmd nagios

     3、 解压

tar xzf nagios-3.0.4.tar.gz

     4、 编译

./configure --prefix=prefix --with-nagios-user=someuser  \\
--with-nagios-group=somegroup --with-command-group=cmdgroup
#变量prefix 为安装目录,例如/usr/local/nagios
#变量someuser 为nagios的用户,例如nagios
#变量somegruop 为nagios属于的组,例如nagios
#变量cmdgroup 为nagios命令行属组,例如nagcmd

    5、 安装

make all
make install
make install-config
make install-init

     6、 检查

ls /usr/local/nagios/
bin  etc  libexec  sbin  share  var
bin  etc  sbin  share  var
#看到这5个目录就ok了

    7、 生成http用户验证文件,用户名为Nagios

/usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios

    8、 将Nagios的信息加到apache中,打开/etc/apache2/apache2.conf文件,在文件最后添加如下代码:

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
 
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
 
Alias /nagios /usr/local/nagios/share
 
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
;

      9、 重启apache服务

/etc/init.d/apache2 restart

      10、 测试Nagios基本平台实现:http://localhost/nagios/

written by Yousri \\ tags: ,