2010年12月1日 星期三

CentOS5之安裝與管理-DNS

CentOS5之安裝與管理
一、安裝
二、升級
三、Server設定
1.DNS
rpm -qa |grep bind
rpm -qa |grep caching-nameserver
yum -y install bind bind-chroot bind-libs bind-utils caching-nameserver system-config-bind
yum -y update bind bind-chroot bind-libs bind-utils caching-nameserver system-config-bind
ls -al /etc/sysconfig/named.rpmnew
rm -f named ; mv named.rpmnew named
cat /etc/sysconfig/named 看有無 ROOTDIR=/var/named/chroot ,若無,加在最後一行
相關設定全移至 /var/named/chroot/
ls -al /var/named/chroot/etc/
ls -al /var/named/chroot/var/named/
chcon system_u:object_r:named_conf_t /etc/rndc.conf

wget http://ftp.kh.edu.tw/APPL/dns-config/dns-conf.tar.bz2
tar jxvf dns-conf.tar.bz2 -C /var/named/chroot

vim /var/named/chroot/etc/named.conf
internal及external兩個view
//內部正反解表設定檔引入
include "/etc/named.zones.slave";

//外部正反解表設定檔引入
include "/etc/named.zones.slave";
vim /var/named/chroot/etc/named.zones.slave

// secondaries (slave) dns server的IP設定,將自己及市網的三台DNS IP設在這個acl之中
acl secondaries {
localhost;
163.28.136.14/32;
163.28.136.10/32;
163.28.136.2/32;
2001:288:8201:1::14/128;
2001:288:8201:1::2/128;
2001:288:8201:1::10/128;
};

// 內部網段的宣告,將內部使用的網段逐條列在這個acl中。
acl trusted {
localhost;
163.32.202.0/24;
2001:288:8288:1::/64;
};

// 內部網段的宣告,將內部使用的網段逐條列在這個acl中。
// acl trusted {
// 244.0.0.0/24;
// };
acl drop {};
//
// Sample named.conf BIND DNS server 'named' configuration file
// for the Red Hat BIND distribution.
//
// See the BIND Administrator's Reference Manual (ARM) for details, in:
// file:///usr/share/doc/bind-*/arm/Bv9ARM.html
// Also see the BIND Configuration GUI : /usr/bin/system-config-bind and
// its manual.
//
options
{
// Those options should be used carefully because they disable port
// randomization
// query-source port 53;
// query-source-v6 port 53;
listen-on { any; }; //開啟IPv4服務
listen-on-v6 { any; }; //開啟IPv6服務

// Put files that named is allowed to write in the data/ directory:
directory "/var/named"; // the default
dump-file "data/cache_dump.db";
statistics-file "data/named_stats.txt";
memstatistics-file "data/named_mem_stats.txt";
transfer-format many-answers;
max-transfer-time-in 60;
interface-interval 0;
forward only; //cache only
// 開放給secondaries DNS Server做全table的dump(cache only不需)
//allow-transfer {
// secondaries;
//};

// 若記憶體內找不到的正反解表,直接到市網的三台IP去查詢。
forwarders {
163.28.136.10;
163.28.136.2;
163.28.136.14;
};

// 將查詢預設值設定為僅開放給內部的IP查詢,至於外部查詢,再從外部的view去設定。
allow-query {
trusted;
};

// 黑名單一律不做任何回應
blackhole {
drop;
};
};

logging
{
/* If you want to enable debugging, eg. using the 'rndc trace' command,
* named will try to write the 'named.run' file in the $directory (/var/named).
* By default, SELinux policy does not allow named to modify the /var/named directory,
* so put the default debug log file in data/ :
*/
channel default_debug {
file "data/named.run";
severity dynamic;
};
category lame-servers { null; };
};
//
// All BIND 9 zones are in a "view", which allow different zones to be served
// to different types of client addresses, and for options to be set for groups
// of zones.
//
// By default, if named.conf contains no "view" clauses, all zones are in the
// "default" view, which matches all clients.
//
// If named.conf contains any "view" clause, then all zones MUST be in a view;
// so it is recommended to start off using views to avoid having to restructure
// your configuration files in the future.
//
view "localhost_resolver"
{
/* This view sets up named to be a localhost resolver ( caching only nameserver ).
* If all you want is a caching-only nameserver, then you need only define this view:
*/
match-clients { localhost; };
match-destinations { localhost; };
recursion yes;
# all views must contain the root hints zone:
include "/etc/named.root.hints";

/* these are zones that contain definitions for all the localhost
* names and addresses, as recommended in RFC1912 - these names should
* ONLY be served to localhost clients:
*/
include "/etc/named.rfc1912.zones";
};
view "internal"
{
/* This view will contain zones you want to serve only to "internal" clients
that connect via your directly attached LAN interfaces - "localnets" .
*/
match-clients { trusted; };
match-destinations { trusted; };
recursion yes;
additional-from-auth yes;
additional-from-cache yes;
// all views must contain the root hints zone:
include "/etc/named.root.hints";

// include "named.rfc1912.zones";
// you should not serve your rfc1912 names to non-localhost clients.

// These are your "authoritative" internal zones, and would probably
// also be included in the "localhost_resolver" view above :

//內部正反解表設定檔引入
include "/etc/named.zones.slave";

// 教育部公告中繼站列表
include "/etc/malice.zones";

// 以下為系統預設值, 本範例不採用
/*
zone "my.internal.zone" {
type master;
file "my.internal.zone.db";
};
zone "my.slave.internal.zone" {
type slave;
file "slaves/my.slave.internal.zone.db";
masters { 127.0.0.1; } ;
// put slave zones in the slaves/ directory so named can update them
};
zone "my.ddns.internal.zone" {
type master;
allow-update { key ddns_key; };
file "slaves/my.ddns.internal.zone.db";
// put dynamically updateable zones in the slaves/ directory so named can update them
}; */
};
key ddns_key
{
algorithm hmac-md5;
secret "hNrymuc1T5PKCyaWBqpLfyctfvkq4P9Rh7QhMq4QOOsFWaDtcVHTraSXAWb5";
};
view "external"
{
/* This view will contain zones you want to serve only to "external" clients
* that have addresses that are not on your directly attached LAN interface subnets:
*/
match-clients { any; };
match-destinations { any; };
recursion no;
additional-from-auth no;
additional-from-cache no;
allow-query { any; };

//recursion no;
// you'd probably want to deny recursion to external clients, so you don't
// end up providing free DNS service to all takers

allow-query-cache { trusted; };
// Disable lookups for any cached data and root hints

// all views must contain the root hints zone:
include "/etc/named.root.hints";

// These are your "authoritative" external zones, and would probably
// contain entries for just your web and mail servers:

//外部正反解表設定檔引入
include "/etc/named.zones.slave";

// 以下為系統預設值, 本範例不採用
/*
zone "my.external.zone" {
type master;
file "my.external.zone.db";
};
*/
};

view tighten-chaos chaos {
/*
The "chaos" type is used among others, to request the version
information from bind. This release of bind allows for you to
set what it should report as version, but I prefer just to deny
(and therefore log) it. In order to do this we need our own
chaos view, which is matched by everyone.
*/

match-clients { any; };
recursion no;

zone "." chaos {
type hint;
file "/dev/null";
};

zone "bind" chaos {
type master;
file "master/bind.chaos";
allow-query { none; };
allow-transfer { none; };
};
};


vim /var/named/chroot/etc/named.zones.slave

// masters IP: 163.28.136.14 為DNS代管主機, 若DNS自建者, 請將IP改為校內Master DNS IP
//貴單位網域之正查資料設定([domain]字串請換成貴校核定之Domain Name)
zone "chkops.kh.edu.tw"{
type slave;
// file "slave/named.chkops";
file "slaves/named.chkops";
masters{
163.28.136.14;
};
};

//貴單位IPv4反查資料設定(xxx字串請換成貴校核定網段之第三碼,如核定網段為163.32.36.0,則須表示成36.32.163.in-addr.arpa)
zone "202.32.163.in-addr.arpa"{
type slave;
// file "slave/named.rev";
file "slaves/named.rev";
masters{
163.28.136.14;
};
};

//貴單位IPv6反查資料設定(xx字串請換成貴校核定IPv6 /48之最末兩碼,如核定網段為2001:288:8234::/48,則須表示成4.3.2.8.8.8.2.0.1.0.0.2.ip6.arpa)
//
zone "8.8.2.8.8.8.2.0.1.0.0.2.ip6.arpa" {
type slave;
// file "slave/named.rev.ipv6";
file "slaves/named.rev.ipv6";
masters{
163.28.136.14;
};
};


named-checkconf -t /var/named/chroot etc/named.conf
service named start

沒有留言: