免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 940 | 回复: 0
打印 上一主题 下一主题

大型网站集群构建之:DNS配置篇 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-09-18 10:03 |只看该作者 |倒序浏览
看了前面的应该知道,由于访问量大,地域分布广,这里假设使用了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数据文件即可。
2、slavedns配置
  在配置dnsview的时候slavedns的配置要有一些小小的改动。named.conf除了allow-query一般设置any以外没有什么变化。主要是在*.zones中要制定同步用的源地址。
  cnc.zones
  #---------------------------------------#
  zone"."{
  typehint;
  file"/var/named/named.root";
  };
  #---------------------------------------#
  zone"56hr.com"IN{
  typeslave;
  file"cnc/xinyv.com.ndb";
  allow-query{any;};
  allow-transfer{zero-transfer;};
  transfer-source192.168.0.205;
  masters{192.168.0.204;};
  };
  #---------------------------------------#
  cnc.local
  #------------------------------------------#
  zone"58.112.202.in-addr.arpa"IN{
  typemaster;
  file"cnc/xinyv.com.local";
  allow-query{any;};
  allow-update{slave-updata;};
  allow-transfer{zero-transfer;};
  };
  大家可能发现我多了一个zone.conf文件,这个文件是那里来的呢?这个是用一个脚本产生出啦的。
  #!/bin/bash
  #Sourcefunctionlibrary.
  ./etc/init.d/functions
  [!-f/etc/sysconfig/network]&&exit1
  ./etc/sysconfig/network
  ["${NETWORKING}"="no"]&&exit0
  [-z$1]&&{echo"$0cnc$0chinanet";exit1;}
  FILE="/dev/shm/ip_apnic"
  rm-f$FILE
  echo"acl$1{">>_zone.conf
  wgethttp://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest-o/dev/null-O$FILE
  grep'apnic|CN|ipv4|'$FILE|awk-F'|''{print$4""$5}'|whileread_IP_MASK
  do
  MASK=$(cat>/dev/shm/_zone.conf]whois$_IP@whois.apnic.net|grep^netname|uniq|sed-e's/^netname://g'|grep-qi$1&&echo$_IP/$MASK\;>>/dev/shm/_zone.conf[/email]
  done
  echo"};">>_zone.conf
  这样dns服务器就算配置完了.


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/25085/showart_1201069.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP