同一域名基于源ip地址分配给不同ip的dns配置--bind9.8.2

1、安装bind。略。

 

2、/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.
//
include "/etc/named.root.key";
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";

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

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

#zone "." IN {
#    type hint;
#    file "named.ca";
#};

view "beijing" {
    match-clients {
        192.168.11.103/32;
    };
    zone "test1.com" IN {
        type master;
        file "test1.com.bj.zone";
    };
};

view "jiangsu" { 
        match-clients {
                192.168.11.102/32;
        };
        zone "test1.com" IN {
                type master;
                file "test1.com.js.zone";
        };
};

view "shanghai" {
    match-clients {
        192.168.11.101/32;
    };
    zone "test1.com" IN {
        type master;
        file "test1.com.sh.zone";
    };
};


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

 

3、/var/named/test1.com.js.zone配置文件。

$TTL 86400
@    IN SOA     test1.com. root (
                    201603101838    ; serial
                    1D    ; refresh
                    1H    ; retry
                    1W    ; expire
                    3H )    ; minimum
@    IN NS        js.test1.com.
js    IN A         192.168.100.100
www    IN A         192.168.100.200
*      IN CNAME    js.test1.com.

 

4、通过host或者nslookup命令测试。

你可能感兴趣的:(同一域名基于源ip地址分配给不同ip的dns配置--bind9.8.2)