bind配置高可用

本文详细描述了如何在Linux系统中配置BINDDNS服务器,包括设置主服务器和从服务器,管理区域文件(如jin.com域),以及使用named-checkconf和named-checkzone工具进行配置检查。
摘要由CSDN通过智能技术生成

bind从192.168.126

[root@localhost yum.repos.d]#  yum -y install bind bind-utils

[root@slavenamed slaves]# which named-checkconf

/usr/sbin/named-checkconf

[root@localhost yum.repos.d]# rpm -qf `which named-checkconf`

bind-9.16.23-14.el9.x86_64

bind从192.168.8.126

[root@slavenamed slaves]# cat /etc/named.conf

//

// named.conf

//

// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS

// server as a caching only nameserver (as a localhost DNS resolver only).

//

// See /usr/share/doc/bind*/sample/ for example named configuration files.

//

options {

listen-on port 53 { 127.0.0.1; 192.168.8.126; };

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";

secroots-file "/var/named/data/named.secroots";

recursing-file "/var/named/data/named.recursing";

allow-query     { localhost; 192.168.8.0/24; };  #限制客户端的查询

/*

 - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.

 - If you are building a RECURSIVE (caching) DNS server, you need to enable

   recursion.

 - If your recursive DNS server has a public IP address, you MUST enable access

   control to limit queries to your legitimate users. Failing to do so will

   cause your server to become part of large scale DNS amplification

   attacks. Implementing BCP38 within your network would greatly

   reduce such attack surface

*/

recursion yes;

dnssec-validation yes;

managed-keys-directory "/var/named/dynamic";

geoip-directory "/usr/share/GeoIP";

pid-file "/run/named/named.pid";

session-keyfile "/run/named/session.key";

/* https://fedoraproject.org/wiki/Changes/CryptoPolicy */

include "/etc/crypto-policies/back-ends/bind.config";

};

logging {

        channel default_debug {

                file "data/named.run";

                severity dynamic;

        };

};

zone "." IN {

type hint;

file "named.ca";

};

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

include "/etc/named.root.key";

#zone "jin.com" IN {

 #       type master;

  #      file "jin.com.zone";  

#};

zone "jin.com" IN {          #配置bind高可用

type slave;

file "slaves/jin.com.zone";

masters {  192.168.8.118; };

masterfile-format text;

};

检查区域配置文件

[root@masternamed named]# named-checkzone jin.com jin.com.zone

检查配置文件

[root@masternamed named]# named-checkconf /etc/named.conf

(2)部署bind master

bind主192.168.8.118

[root@localhost yum.repos.d]#  yum -y install bind bind-utils

[root@masternamed named]# pwd

/var/named

[root@masternamed named]# touch jin.com.zone

[root@masternamed named]# chown -R named. jin.com.zone

[root@masternamed named]# cat jin.com.zone

$TTL 7200

jin.com. IN SOA jin.com. admin.jin.com. (

2024012302

1H

10M

1W

1D )

jin.com. IN NS ns1.jin.com.

jin.com. IN NS ns2.jin.com.

ns1.jin.com. IN A 192.168.8.118

ns2.jin.com. IN A 192.168.8.126

www.jin.com. IN A 192.168.8.118

www.jin.com. IN A 192.168.8.126

ftp.jin.com. IN A 192.168.8.5

ftp.jin.com. IN A 192.168.8.6

[root@masternamed named]# cat /etc/named.conf

//

// named.conf

//

// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS

// server as a caching only nameserver (as a localhost DNS resolver only).

//

// See /usr/share/doc/bind*/sample/ for example named configuration files.

//

options {

listen-on port 53 { 127.0.0.1; 192.168.8.118;};

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";

secroots-file "/var/named/data/named.secroots";

recursing-file "/var/named/data/named.recursing";

allow-query     { localhost; 192.168.8.0/24; };

/*

 - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.

 - If you are building a RECURSIVE (caching) DNS server, you need to enable

   recursion.

 - If your recursive DNS server has a public IP address, you MUST enable access

   control to limit queries to your legitimate users. Failing to do so will

   cause your server to become part of large scale DNS amplification

   attacks. Implementing BCP38 within your network would greatly

   reduce such attack surface

*/

recursion yes;

dnssec-validation yes;

managed-keys-directory "/var/named/dynamic";

geoip-directory "/usr/share/GeoIP";

pid-file "/run/named/named.pid";

session-keyfile "/run/named/session.key";

/* https://fedoraproject.org/wiki/Changes/CryptoPolicy */

include "/etc/crypto-policies/back-ends/bind.config";

};

logging {

        channel default_debug {

                file "data/named.run";

                severity dynamic;

        };

};

zone "." IN {

type hint;

file "named.ca";

};

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

include "/etc/named.root.key";

#zone "jin.com" IN {

# type master;

# file "jin.com.zone";

#};

zone "jin.com" IN {

type master;

file "jin.com.zone";       #配置bind主的配置

also-notify { 192.168.8.126;};

allow-transfer {  192.168.8.126;};

allow-update { none; };

notify yes;

};

修改bind主的区域配置文件

[root@masternamed named]# cat jin.com.zone

$TTL 7200

jin.com. IN SOA jin.com. admin.jin.com. (

2024012303 

1H

10M

1W

1D )

jin.com. IN NS ns1.jin.com.

jin.com. IN NS ns2.jin.com.

ns1.jin.com. IN A 192.168.8.118

ns2.jin.com. IN A 192.168.8.126

www.jin.com. IN A 192.168.8.118

www.jin.com. IN A 192.168.8.126

ftp.jin.com. IN A 192.168.8.5

ftp.jin.com. IN A 192.168.8.6

ftp.jin.com. IN A 192.168.8.7

重启服务

[root@masternamed named]# systemctl restart named

查看bind从slaves

[root@slavenamed slaves]# cat jin.com.zone

$ORIGIN .

$TTL 7200 ; 2 hours

jin.com IN SOA jin.com. admin.jin.com. (

2024012303 ; serial

3600       ; refresh (1 hour)

600        ; retry (10 minutes)

604800     ; expire (1 week)

86400      ; minimum (1 day)

)

NS ns1.jin.com.

NS ns2.jin.com.

$ORIGIN jin.com.

ftp A 192.168.8.5

A 192.168.8.6

A 192.168.8.7

ns1 A 192.168.8.118

ns2 A 192.168.8.126

www A 192.168.8.118

A 192.168.8.126

[root@slavenamed slaves]# pwd

/var/named/slaves

  • 40
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现高可用的HAProxy配置,需要使用一种叫做“负载均衡器”的工具。下面是一个基本的HAProxy高可用配置示例: 1. 首先,您需要在两个服务器上安装HAProxy。这些服务器将被称为“主”和“备份”。 2. 在主服务器上,创建一个HAProxy配置文件。该文件应该包含您想要使用HAProxy进行负载均衡的所有服务和端口。例如: ``` global log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners stats timeout 30s user haproxy group haproxy daemon defaults log global mode http option httplog option dontlognull timeout connect 5000 timeout client 50000 timeout server 50000 frontend main bind *:80 default_backend web_servers backend web_servers balance roundrobin server web1 10.0.0.1:80 check server web2 10.0.0.2:80 check ``` 这个例子假设您正在负载均衡两个Web服务器,它们的IP地址分别为10.0.0.1和10.0.0.2。 3. 将配置文件复制到备份服务器上。 4. 在主服务器上,安装并配置Heartbeat,这是一个开源的高可用软件。Heartbeat将监控主服务器的HAProxy进程,并在主服务器故障时将其切换到备份服务器上。 5. 在备份服务器上,安装并配置Heartbeat,以便在主服务器故障时自动接管HAProxy进程。 6. 测试配置。在主服务器上启动HAProxy,并尝试访问负载均衡器的服务。然后,关闭主服务器的HAProxy进程,并检查负载均衡器是否自动切换到备份服务器上。 这只是一个基本的HAProxy高可用配置示例。您可以根据自己的需要进行调整和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值