网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > 代码交流
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

代码交流 ASP,PHP,JSP等网站源代码下载与交流。

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 61.139.126.97
Old 2006-10-15, 06:57 AM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default 南征北战 双线路网站解决办法

最近遇到了头大问题,一个网站为提高访问速度,分别拉了电信、网通两条线路,想实现电信从电信访问、网通用户从网通访问。

  最初的方案是分别建立两个相同的站,一个www1.xxx.com(电信)一个www2.xxx.com(网通),然后分别解析www1.xxx.com的A记录为电信的ip,www2.xxx.com为网通IP。

  这样做看上去没错,可是麻烦事又来了,该站后台使用mysql数据库,数据库必须是同一个,否则还得另外设置两个服务器的mysql保持同步。

  mysql倒是小事,原来的网页内的链接都是www.xxx.com/xxx....的,要都重新改成分别的www1和www2,还得保持同步,这麻烦就大了。

  记过仔细分析,最终采用了我们的方案,使用DNS的view功能,只使用一个www.xxx.com的域名,就很简单地解决了这个问题。

  Bind9有个特殊功能view(视图),使用该功能能够对不同的访问对象返回不同的IP。比如电信用户试图解析www.xxx.com,就返回电信的IP,而网通用户则返回网通的IP。这样根本不需要多个域名,只需要一个www.xxx.com就可以了。原有网站中的页面都不需要更改。

  下面是个named.conf示例:

  以下是引用片段:

Quote:
#---/etc/named.conf---#
  options {
  directory "/var/named";
  };
  view "cnc" {
  match-clients { 60.0.0.0/13;60.8.0.0/15;60.10.0.0/16;60.12.0.0/16;60.13.0.0/18;60.13.128.0/17;
  60.16.0.0/12;60.208.0.0/13;60.216.0.0/15;60.220.0.0/14;61.48.0.0/13;61.133.0.0/17;61.135.0.0/16;
  61.136.64.0/18;61.137.128.0/17;61.138.0.0/17;61.138.128.0/18;61.139.128.0/18;61.148.0.0/15;
  61.156.0.0/16;61.158.128.0/17;61.159.0.0/18;61.161.0.0/18;61.161.128.0/17;61.167.0.0/16;
  61.168.0.0/16;61.176.0.0/16;61.179.0.0/16;61.180.128.0/17;61.181.0.0/16;61.182.0.0/16;
  61.189.0.0/17;202.96.0.0/18;202.96.64.0/19;};
  recursion yes;
  zone "xxx.com" {
  type master;
  file "/var/named/xxx.com.cnc.hosts";
  };
  };
  view "other" {
  match-clients { any; };
  recursion no;
  zone "xxx.com" {
  type master;
  file "/var/named/xxx.com.hosts";
  };
  };
从这里可以看到,xxx.com的域名解析同时包含在视图cnc和other区域中。视图cnc负责网通用户的解析。当match-clients中注明的网通网段用户发送的DNS解析请求,则从/var/named/xxx.com.cnc.hosts文件中返回www.xxx.com的网通IP。否则则由视图other处理,从"/var/named/xxx.com.hosts“文件中返回电信的IP。

这样就实现了对不同用户返回了不同的IP。

  (这只是个示例,match-clients中的网通IP表段不全。)

  其他的就很简单了。

  最终用户采用了Quick Enterpeise Linux 4.0,仅在一台服务器上就实现了双线路接入、策略路由、双IP网站访问、防火墙等全部功能。
Reply With Quote
 


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 11:08 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.