DNS服务器配置
DNS 是域名系统 (Domain Name System) 的缩写,是因特网的一项核心服务,它作为可以将域名和IP地址相互映射的一个分布式数据库,能够使人更方便的访问互联网,而不用去记住能够被机器直接读取的IP数串
服务器环境:
操作系统:
Red Hat Enterprise Linux Server 5.4 内核版本: 2.6.18-164.el5
需要的软件:
bind-9.3.6-4.P1.el5.i386.rpm 主程序软件
bind-chroot-9.3.6-4.P1.el5.i386.rpm 安全软件
caching-nameserver-9.3.6-4.P1.el5.i386.rpm 生成caching-only只做缓存的服务器,以及生成配置文件named.conf的模版
网络参数:
IP: 192.168.1.177/28 netmask:255.255.255.240 Gateway:192.168.1.190
配置步骤:
[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost ~]# cd /mnt/cdrom/Server/
[root@localhost Server]# rpm -ivh bind-9.3.6-4.P1.el5.i386.rpm
warning: bind-9.3.6-4.P1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:bind ########################################### [100%]
[root@localhost Server]# rpm -ivh bind-chroot-9.3.6-4.P1.el5.i386.rpm
warning: bind-chroot-9.3.6-4.P1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:bind-chroot ########################################### [100%]
[root@localhost Server]# rpm -ivh caching-nameserver-9.3.6-4.P1.el5.i386.rpm
warning: caching-nameserver-9.3.6-4.P1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:caching-nameserver ########################################### [100%]
查看已经安装的软件:
[root@localhost ~]# rpm -qa |grep bind
ypbind-1.19-12.el5
bind-utils-9.3.6-4.P1.el5
bind-chroot-9.3.6-4.P1.el5
bind-9.3.6-4.P1.el5
bind-libs-9.3.6-4.P1.el5
[root@localhost ~]# rpm -qa |grep caching
caching-nameserver-9.3.6-4.P1.el5
[root@localhost Server]# cd /var/named/chroot/etc/
[root@localhost etc]# cp -p named.caching-nameserver.conf named.conf
[root@localhost etc]# ll
total 20
-rw-r--r-- 1 root root 405 Aug 2 21:30 localtime
-rw-r----- 1 root named 1230 Jul 30 2009 named.caching-nameserver.conf
-rw-r----- 1 root named 1230 Jul 30 2009 named.conf
-rw-r----- 1 root named 955 Jul 30 2009 named.rfc1912.zones
-rw-r----- 1 root named 113 Aug 3 16:05 rndc.key
[root@localhost etc]# vim /var/named/chroot/etc/named.conf
options {
listen-on port 53 { any; }; 监听所有网卡的53端口上
listen-on-v6 port 53 { ::1; };
directory "/var/named"; 根目录
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; }; 允许所有主机查询解析
allow-query-cache { any; }; 允许所有主机查询解析并将结果缓存
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
acl inside_pc { 192.168.1.0/24;192.168.10.0/24; };定义变量inside_pc,指定其代表192.168.1.0/24和192.168.10.0/24的主机,即内网和分支机构的所有主机
view inside_pc { 定义一个视图inside_pc
match-clients { inside_pc; }; 匹配名称为inside_pc的主机
recursion yes; 允许该主机递归查询
zone "bht.com" IN { 区域声明。声明bht.com区域
type master; 该dns服务器为该区域的主dns服务器
file "bht.com.local.zone"; inside_pc的主机对应的数据库文件
};
zone "10.168.192.in-addr.arpa" IN { 反向解析,用于不同的区域互发邮件
type master;
file "192.168.10.zone";
allow-update { none; };
};
};
view localhost_resolver {
match-clients { any; }; 匹配任意视图
match-destinations { any; }; 匹配任意地址
recursion yes; 允许主机递归查询
include "/etc/named.rfc1912.zones"; 所有主机进行解析时查看区域声明文件
};
编辑区域声明文件,将下列字段加入该文件
[root@localhost etc]# vim /var/named/chroot/etc/named.rfc1912.zones
zone "bht.com" IN { 区域声明
type master; 该dns服务器为该区域的主dns服务器
file "bht.com.zone"; 数据库文件名
allow-update { none; }; 动态更新
};
下面要创建上述两个步骤中声明的数据库文件:bht.com.local.zone bht.com.zone 192.168.10.zone
[root@localhost chroot]# cd /var/named/chroot/var/named/
[root@localhost named]# ll
total 36
drwxrwx--- 2 named named 4096 Aug 26 2004 data
-rw-r----- 1 root named 198 Jul 30 2009 localdomain.zone
-rw-r----- 1 root named 195 Jul 30 2009 localhost.zone
-rw-r----- 1 root named 427 Jul 30 2009 named.broadcast
-rw-r----- 1 root named 1892 Jul 30 2009 named.ca
-rw-r----- 1 root named 424 Jul 30 2009 named.ip6.local
-rw-r----- 1 root named 426 Jul 30 2009 named.local
-rw-r----- 1 root named 427 Jul 30 2009 named.zero
drwxrwx--- 2 named named 4096 Jul 27 2004 slaves
[root@localhost named]# cp -p localhost.zone bht.com.zone拷贝模板
SNMP代理配置:
安装net-snmp软件,使该主机成为agent。由于安装需要依赖lm_sensors软件,所以使用yum工具解决依赖关系
配置yum服务器:
[root@localhost named]# cat /etc/yum.repos.d/rhel-debuginfo.repo
[rhel-server]
name=Red Hat Enterprise Linux server
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
[root@localhost ~]# yum install net-snmp -y
编辑配置文件/etc/snmp/snmpd.conf 。将第62 行的read字段对应的值改为all,表示可以访问所有的mib库;第85行定义“all”对应的mib是哪些;并设置配置沟通密码(团体名);设置陷阱,将陷阱信息发送至NMS(网络管理工作站)
[root@localhost ~]# vim /etc/snmp/snmpd.conf
62 access notConfigGroup "" any noauth exact all none none
85 view all included .1 80
50 rocommunity public
51 rwcommunity private
79 com2sec mynetwork 192.168.1.193/28 public
保存退出
启动snmp服务,并将snmp服务设置为开机自启动
[root@localhost ~]# service snmpd start 启动服务
Starting snmpd: [ OK ]
[root@localhost ~]# chkconfig snmpd on
查看snmp服务的端口号,有两个端口号:199和169
[root@localhost ~]# netstat -tupln |grep snmp
tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN 12052/snmpd
udp 0 0 0.0.0.0:161 0.0.0.0:* 12052/snmpd
日志转发:
编辑系统日志配置文件/etc/syslog.conf,将需要转发的日志发送到指定的日志服务器上。咋日志类型后面加 @日志服务器的地址 即可将日志发送到指定的日志服务器上。
[root@mail ~]# vim /etc/syslog.conf
*.info;mail.none;authpriv.none;cron.none @192.168.1.194
重启日志服务
[root@mail ~]# service syslog restart
Shutting down kernel logger: [ OK ]
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
Starting kernel logger: [ OK ]
本文转自 gjp0731 51CTO博客,原文链接:http://blog.51cto.com/guojiping/1160593