网站服务器集群构建之:DNS配置篇(1)


本文章主要讲解大型网站构建,全部采用开源软件和开源的操作系统,构架采用 LAMP Linux+Apache+Mysql+Php)模式实现。

看了前面的应该知道,由于访问量大,地域分布广,这里假设使用了3加运营商介入,分别是网通,电信,还有一个其他接入方式。先分析一下网络情况,现在我们是3根线路接入,网络用户分别来自不同的地方,不同地方的线路速度是不同的,如果电信的用户一定要从网通的线路来访问我的站点那就会变得非常缓慢,所以第一个目的就是让电信的用户通过电信线路,网通的用户通过网通线路来访问,用户访问只是通过在浏览器中输入域名来访问,没有办法处理线路上的问题,而数据发出后经过N多路由到达我们的网站,路由会自动选择最经济路由,我们也没办法处理,那我们只有在域名上想想办法了。这里使用bind的view功能,配置也不复杂,作用就是根据ip的来源不同解析到不同的ip上去。

1、named.conf文件的配置

配置named.conf,因为涉及到隐私问题,这里就不写实际地址了,用伪地址代替,下面涉及到的一些查询权限,zone传输,slave服务器配置等大家使用的时候根据实际情况修改。

named.conf


//
//Samplenamed.confBINDDNSserver'named'configurationfile
//fortheRedHatBINDdistribution.
//
//SeetheBINDAdministrator'sReferenceManual(ARM)fordetails,in:
//file:///usr/share/doc/bind-*/arm/Bv9ARM.html
//AlsoseetheBINDConfigurationGUI:/usr/bin/system-config-bindand
//itsmanual.
//
options
{
/*makenameduseport53forthesourceofallqueries,toallow
*firewallstoblockallportsexcept53:
*/
query-sourceaddress*port53;
//query-source-v6port53;

//Putfilesthatnamedisallowedtowriteinthedata/directory:
directory"/var/named";//thedefault
dump-file"data/cache_dump.db";
statistics-file"data/named_stats.txt";
memstatistics-file"data/named_mem_stats.txt";
datasize100M;
allow-query{192.168.0.0/24;2xx.1xx.2xx.0/24;1xx.1xx.1xx.192/24;};
};
logging
{
/*Ifyouwanttoenabledebugging,eg.usingthe'rndctrace'command,
*namedwilltrytowritethe'named.run'fileinthe$directory(/var/named).
*Bydefault,SELinuxpolicydoesnotallownamedtomodifythe/var/nameddirectory,
*soputthedefaultdebuglogfileindata/:
*/
channeldefault_debug{
file"data/named.run";
severitydynamic;
};
};
//
//AllBIND9zonesareina"view",whichallowdifferentzonestobeserved
//todifferenttypesofclientaddresses,andforoptionstobesetforgroups
//ofzones.
//
//Bydefault,ifnamed.confcontainsno"view"clauses,allzonesareinthe
//"default"view,whichmatchesallclients.
//
//Ifnamed.confcontainsany"view"clause,thenallzonesMUSTbeinaview;
//soitisrecommendedtostartoffusingviewstoavoidhavingtorestructure
//yourconfigurationfilesinthefuture.
//
acl"zero-transfer"{192.168.0.0/24;2xx.1xx.2xx.0/24;1xx.1xx.1xx.192/24;};
acl"slave-updata"{192.168.0.0/24;2xx.1xx.2xx.0/24;1xx.1xx.1xx.192/24;};
include"/etc/zone.conf";

#-----------------------------------------#
view"internal"{
match-clients{127.0.0.1;};
recursionno;
zone"localhost"{
typemaster;
file"localhost.zone";
};
zone"0.0.127.IN-ADDR.ARPA"{
typemaster;
file"named.local";
};
};
#-----------------------------------------#
view"cnc"{
match-clients{CNC;};
match-destinations{any;};
recursionyes;
include"/etc/cnc.zones";
include"/etc/cnc.local";
};
view"telecom"{
match-clients{CHINANET;};
match-destinations{any;};
recursionyes;
include"/etc/telecom.zones";
include"/etc/telecom.local";
};
view"other"{
match-clients{any;};
match-destinations{any;};
recursionyes;
include"/etc/other.zones";
include"/etc/other.local";
};
#-----------------------------------------#

include"/etc/rndc.key";

zone.conf:
acl"CNC"{
117.8.0.0/13;
……
123.112.0.0/12;
};
acl"CHINANET"{
222.222.0.0/15
……
222.86.0.0/15
};
*.zones为正向解析配置文件,*.local为反向解析文件,同dns的标准配置。
#-------------------------------------------#
zone"."{
typehint;
file"/var/named/named.root";
};
#------------------------------------------#
zone"56hr.com"IN{
typemaster;
file"cnc/xinyv.com.ndb";
allow-query{any;};
allow-transfer{zero-transfer;};
allow-update{slave-updata;};
};
#-----------------------------------------#
然后分别在不同的文件夹建立相应的ndb数据文件即可。


相关内容