单机双线路实现负载均衡+双线备份

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

使用BIND实现电信教育网双线路负载+双线路冗余

环境:

电信网络IP:192.168.1.1(服务器使用)192.168.1.2(测试使用)

教育网IP:192.168.1.51 (服务器使用)192.168.1.52(测试使用)

DNS服务器IP: 192.168.1.100

邮件服务器域名: IP为电信192.168.1.1教育网192.168.1.51

一.DNS服务器配置(实现双线路负载均衡)

1.修改/etc/named.conf

options {

listen-on port 53 { any; };

listen-on-v6 port 53 { ::1; };

directory "/var/named";

dump-file "/var/named/data/cache_dump.db";

statistics-file "/var/named/data/named_stats.txt";

memstatistics-file "/var/named/data/named_mem_stats.txt";

allow-query { any; };

recursion yes;

dnssec-enable yes;

dnssec-validation yes;

dnssec-lookaside auto;

/* Path to ISC DLV key */

bindkeys-file "/etc/named.iscdlv.key";

};

logging {

channel default_debug {

file "data/named.run";

severity dynamic;

};

};

view dns1 {

match-clients { 192.168.1.2; };#定义哪些IP读取/etc/named/named.zones zone "." IN {

type hint;

file "named.ca";

};

include "/etc/named/named.zones";

};

view dns2 {

match-clients { 192.168.1.52; };定义哪些IP读取/etc/named.rfc1912.zones zone "." IN {

type hint;

file "named.ca";

};

include "/etc/named.rfc1912.zones";

};

2.修改/etc/named/named.zones,/etc/named.rfc1912.zones配置

/etc/named/named.zones是不存在的,直接CP一份/etc/named.rfc1912.zones内容,然后修改。

具体配置如下:

(1)/etc/named/named.zones

加入:

zone "" IN {

type master;

file "hulin1.dns";

allow-update { none; };

};

(2)/etc/named.rfc1912.zones

加入:

zone "" IN {

type master;

file "hulin51.dns";

allow-update { none; };

};

3.在/var/named/新建hulin1.dns,hulin51.dns配置文件

(1)hulin1.dns配置如下

$TTL 1D

@ IN SOA . root (

0 ; serial

1D ; refresh

1H ; retry

1W ; expire

3H ) ; minimum

NS .

ns IN A 192.168.1.100

mail IN A 192.168.1.1

IN MX 10

(2)hulin51.dns配置如下

$TTL 1D

@ IN SOA . root (

0 ; serial

1D ; refresh

1H ; retry

1W ; expire

3H ) ; minimum

NS .

Ns IN A 192.168.1.100

mail IN A 192.168.1.51

IN MX 10

4.重启BIND,至此,双线路负载成功

测试:用IP为192.168.1.2的机器解析到IP为192.168.1.1 用IP为192.168.1.52的机器解析到IP为192.168.1.51

二.实现双线路冗余

1.在/root 下新建脚本ping1.sh,ping51.sh脚本内容如下:

(1)ping1.sh

#!/bin/bash

ping -c2 192.168.1.1 &>/dev/null

if [ $? = 1 ]

then/named1.sh&&

mv/root/named1.conf/root/named1.conf.bak&&

echo "192.168.1.1 is down"|mail -s "sos" 408642605@

else mv /root/named1.conf.bak /root/named1.conf&&

cp /root/named.conf /etc/named.conf&&

/etc/init.d/named restart

&&echo "192.168.1.1 is up"|mail -s "sos" 408642605@

fi

(2)ping51.sh

#!/bin/bash

ping -c2 192.168.1.51 &>/dev/null

if [ $? = 1 ]

then/named51.sh&&

mv/root/named51.conf/root/named51.conf.bak&&

echo "192.168.1.51 is down"|mail -s "sos" 408642605@

else mv /root/named51.conf.bak /root/named51.conf

cp /root/named.conf /etc/named.conf&&

/etc/init.d/named restart

&&echo "192.168.1.51 is up"|mail -s "sos" 408642605@

fi

2.在/root下新建named1.sh named51.sh 脚本内容如下

(1)named1.sh

cp -p /root/named1.conf /etc/named.conf&&/etc/init.d/named restart (2)named51.sh

cp -p /root/named51.conf /etc/named.conf&&/etc/init.d/named restart

3.在/root下新建named.conf(直接拷贝/etc/named.conf) named1.conf,namd51.conf 具体

相关文档
最新文档