歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> dns配置高級篇

dns配置高級篇

日期:2017/2/27 9:51:15   编辑:更多Linux
 作者cpss http://cpss.zz.ha.cn歡迎轉載,但必須注明出處和作者名稱。Dns配置高級篇


這裡假設你已經獨立或參考我的《架設dns攻略》將dns服務器成功架設起來,並且dns已經能夠正常運行了。


現在我們dns開始工作了,是不是我們的工作已經OK了呢?不,不,不,named.conf文件還有很多東西需要我們配置呢。

DNS的配置文件named.conf是有非常多的可選項的,這裡只是介紹一點常用的配置。如果你覺得還想繼續研究下去,那也不需要在網上到處找資料的,直接用“man named.conf”就可以得到一個非常非常詳細的說明。

這裡首先感謝我的同事yiming先生對服務器安全性的不懈研究,否則我們也不會經常安裝、配置最新版本的DNS服務器了。而且,這個named.conf是他配置的。好了,言歸正傳,Follow me,我們繼續。





1.Options 我們通過options可以定制一個性能更優、安全性更高的dns服務器。

Version “I am cpss”;

別人想探測我們dns版本,然後根據該版本的漏洞來攻擊我們。休想!配置了這條命令後,別人再探測的版本後就是“I am cpss”了,呵呵。

Allow-transfer {192.168.1.1;192.168.1.4;};

如果沒有配置這一條命令,任何人都可以通過nslookup工具來得到你域裡面的zone文件,也就是說他得到了你的主機列表,然後再分析,再……。當然,slave dns需要你允許它能夠傳送,否則它就得不到master dns上的zone文件,也就沒辦法工作了。這裡假設192.168.1.1和192.168.1.4是該dns服務器的slave服務器,在 master服務器上配置了如上命令。

Listen-on{192.168.1.2;};

增加上這條命令,啟動dns時就不會監聽所有網絡接口的53端口了,只監聽指定網絡接口的53端口。

Blackhole {hatenets;};

我們不想讓某些網段使用我們的dns服務器,就用這條命令吧。不過還需要配置一個acl來定義匹配的網段,如下所示:

acl hatenets {

1.0.0.0/8;

2.0.0.0/8;

};
這兩個網段的地址是無法使用我們的dns了。





2.logging 通過該選項,我們可以生成我們想要的日志。通過日志,我們可以更好地維護dns服務器。

Logging {

Channel syslog_info {

File “/var/log/bindall.log” versions 20 size 2m;

Print-category yes;

Print-time yes;

Severity notice;

};

category default {

syslog_info;

};

};
上例中我們建立了一個安全級別為notice的日志,dns的報錯信息都會存放在“/var/log/bindall.log”日志文件了,分析該文件,我們就能輕松找出dns工作不正常的原因了。

Logging裡面的安全級別很多,大家可以根據自己需要來制定一個或多個logging。下面是logging的語法:

logging {

[ channel channel_name {

( file path_name

[ versions ( number unlimited ) ]

[ size size_spec ]

syslog ( kern user mail daemon auth syslog lpr

news uUCp cron authpriv FTP

local0 local1 local2 local3

local4 local5 local6 local7 )

null );



[ severity ( critical error warning notice

info debug [ level ] dynamic ); ]

[ print-category yes_or_no; ]

[ print-severity yes_or_no; ]

[ print-time yes_or_no; ]

}; ]



[ category category_name {

channel_name; [ channel_name; ... ]

}; ]

...

};




3. 這裡是我們named.conf樣本,希望能對你有所幫助。

4.最新版本(2002年11月5日)的named.ca文件。


我們named.conf的樣本

acl hatenets {




1.0.0.0/8;

2.0.0.0/8;

};



options {

files 10000;

# boot file for name server

#

Directory "/var/named";

version "I am cpss";

notify no;

datasize 300m;

allow-transfer {192.168.1.1;

192.168.1.4;

};



blackhole { hatenets; };

interface-interval 0;

cleaning-interval 120;

listen-on {192.168.1.2;

};

statistics-interval 60;





logging {

channel syslog_query {

file "/var/log/bindquery.log" ;

severity notice;

};



channel syslog_info {

file "/var/log/bindall.log" versions 20 size 2m;

print-category yes;

print-time yes;

print-severity yes;

severity notice;

};



channel syslog_manitenance {

file "/var/log/bindmaint.log" versions 10 size 2m;

severity notice;

};



channel syslog_secu {

syslog local6;

severity info;

};



channel syslog_xfer {

file "/var/log/bindxfer.log" versions 20 size 2m;

print-category yes;

print-time yes;

print-severity yes;

severity notice;

};







channel syslog_os {

syslog local3;

severity info;

};



channel syslog_panic {

syslog local4;

severity info;

};



channel syslog_stat {

syslog local5;

severity info;

};



channel syslog_config {

file "/var/log/bind_config.log" versions 20 size 2m;

print-category yes;

print-time yes;

print-severity yes;

severity info;

};

category "xfer-in" {

syslog_xfer;

};





category default {

syslog_info;

};



category security {

syslog_secu;

};





category os {

syslog_os;



};



category panic {

syslog_panic;

};



category statistics {

syslog_stat;

};



category config {

syslog_config;

};



category maintenance {

syslog_manitenance;

};





category lame-servers {null; };



category cname {null; };



};



#

# type domain source host/file

#

zone "." {

type hint;

file "/var/named/named.ca";

};



zone "0.0.127.IN-ADDR.ARPA" {

type master;

file "local.rev";

};



}; category "xfer-in" { syslog_xfer; }; category default { syslog_info; }; category security { syslog_secu; }; category os { syslog_os; }; category panic { syslog_panic; }; category statistics { syslog_stat; }; category config { syslog_config; }; category maintenance { syslog_manitenance; }; category lame-servers {null; }; category cname {null; }; }; # # type domain source host/file # zone "." { type hint; file "/var/named/named.ca"; }; zone "0.0.127.IN-ADDR.ARPA" { type master; file "local.rev"; };



syslog_xfer; }; category default { syslog_info; }; category security { syslog_secu; }; category os { syslog_os; }; category panic { syslog_panic; }; category statistics { syslog_stat; }; category config { syslog_config; }; category maintenance { syslog_manitenance; }; category lame-servers {null; }; category cname {null; }; }; # # type domain source host/file # zone "." { type hint; file "/var/named/named.ca"; }; zone "0.0.127.IN-ADDR.ARPA" { type master; file "local.rev"; };



Copyright © Linux教程網 All Rights Reserved