新浦京81707con > 首页 > 澳门葡京真人网址Linux下源码搭建Bind服务器,快

原标题:澳门葡京真人网址Linux下源码搭建Bind服务器,快

浏览次数:59 时间:2019-11-02

第一步、安装bind-9.7.2-P3

安装bind前先安装gcc,配置好yum源,yum -y install gcc,假如有run.pid报错,直接rm -rf /var/run/yum.pid (废除yum-updatesd服务正运营的景况)

生机勃勃、编写翻译安装bind
[root@ www.linuxidc.com tmp]# tar xvf bind-9.6.1.tar.gz
[root@ www.linuxidc.com tmp]# cd bind-9.6.1
[root@ www.linuxidc.com bind-9.6.1]# ./configure?--prefix=/usr/local/named?--enable-threads
//开启八线程管理本事
[root@ www.linuxidc.com bind-9.6.1]#make
[root@ www.linuxidc.com bind-9.6.1]#make install
//由于安装程序不会自行成立主配置文件所以大家要手动创设
//进入/usr/local/named 建立etc目录
[root@ www.linuxidc.com bind-9.6.1]#cd /usr/local/named
[root@ www.linuxidc.com named]# mkdir etc
 //从rndc.conf文件中领到named.conf用的key
root@linux?named]#?cd?sbin
[root@ www.linuxidc.com sbin]# ./rndc-confgen | tail -10 | head -9 | sed s/# //g > /usr/local/named/etc/named.conf
//自动在/usr/local/named/etc生成named,conf文件

更新yum源:

下载 bind9.6到/root/Desktop,先进至目录里,然后wget ftp://ftp.isc.org/isc/bind9/9.6.0-P1/bind-9.6.0-P1.tar.gz

二、改革bind配置文件
[root@ www.linuxidc.com etc]# vi /usr/local/named/etc/named.conf
//参预以下代码
options { 
#named区文件目录
directory "/var/named"; 
#进程id文件名 
pid-file "named.pid";
}; 
controls {     
   inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN {        
    type hint;       
    file "named.root";
};
zone "localhost" IN {
    type master;     
    file "localhost.zone";     
    allow-update { none; };
};
# 钦定 named 作为127.0.0网段地址调换主服务器。
# named.local 文件中蕴含了 127.0.0.* 情势之处到域名的调换数据。
#(127.0.0网段地址是局域网接口的中间 loopback 地址)
zone "0.0.127.in-addr.arpa" IN {   
    type master;       
    file "named.local";      
    allow-update { none; };
};
# 钦点 named 作为 linuxidc.com 域的主域名服务器。
# linuxidc.zone 文件中含有全体 *.linuxidc.com 方式的域名调换数据。
zone "linuxidc.com" IN {  
    type master;      
    file "linuxidc.zone";      
    allow-update { none; };
};
#内定 named 作为 192.168.1 网段地址转换主服务器。
# linuxidc.local文件中含有了富有 192.168.1.* 情势之处到域名的转变数据。
zone "1.168.192.in-addr.arpa" IN {   
    type master;      
    file "linuxidc.local";        
    allow-update { none; };
};

rm -rf /etc/yum.repos.d/*.repo

解压bind-9.6.0-P1.tar.gz

三、创设区文件目录
[root@ www.linuxidc.com etc]# mkdir /var/named
//进入/var/named
[root@ www.linuxidc.com etc]# cd /var/named/
//建立localhost.zone文件
[root@ www.linuxidc.com named]# vi localhost.zone
$TTL    86400 $ORIGIN localhost.
@                       1D IN SOA       @ root (                                         42              ; serial (d. adams)                                         3H              ; refresh                                         15M             ; retry                                         1W              ; expiry                                         1D )            ; minimum                         1D IN NS        @                        
                        1D IN A         127.0.0.1 

wget -O /etc/yum.repos.d/CentOS-Base.repo

# tar zxvf bind-9.6.0-P1.tar.gz

//建立named.local文件
[root@ www.linuxidc.com named]# vi named.local
$TTL    86400
@       IN      SOA     localhost. root.localhost.  (                                       1997022700 ; Serial                                       28800      ; Refresh                                       14400      ; Retry                                       3600000    ; Expire                                       86400 )    ; Minimum               IN      NS      localhost.
1       IN      PTR     localhost.
//dig命令直接生成named.root文件
[root@ www.linuxidc.com named]# dig > named.root

yum安装openssl-devel :

进入 bind-9.6.0-P1.gz文件夹

//创建linuxidc.com域名正向拆解解析文件
[root@ www.linuxidc.com named]# vi linuxidc.zone
$ttl    1D
@               IN SOA  linuxidc.com.  root.linuxidc.com. (                                        1053891162                                    
                                       3H                                       
                                       15M                                     
                                       1W                                    
                                       1D )                   
                IN NS          linuxidc.com.                       
                IN MX    5     linuxidc.com.
www             IN A           192.168.1.107

yum -y install openssl-devel

# cd bind-9.6.0-P1

//建设构造linuxidc.com域名反向深入深入分析文件
[root@ www.linuxidc.com named]# vi linuxidc.local
$TTL 86400
@ IN SOA linuxidc.com. root.linuxidc.com.(
20031001;
7200;
3600;
43200;
86400);
@ IN NS linuxidc.com.
82 IN PTR dns.linuxidc.com.

跻身有时安装目录:

开创安装目录,我是设置在 /opt/bind

四、启动bind服务器
[root@ www.linuxidc.com named]/usr/local/named/sbin/named -c /usr/local/named/etc/named.conf &
5642

cd /opt

# mkdir /opt/bind

五、测试DNS
[root@ www.linuxidc.com named]# host 192.168.1.107
107.1.168.192.in-addr.arpa domain name pointer dns.linuxidc.com.
//如上显得表示DNS反向分析正常
[root@ www.linuxidc.com named]# ping www.linuxidc.com PING www.linuxidc.com (192.168.1.107) 56(84) bytes of data. //如上呈现表示正向深入剖析符合规律
//DNS配置实现。

获取bind版本:

编写翻译,指虞诩装目录,开启二十四线程协助

澳门葡京真人网址 1

wget

#./configure --prefix=/opt/bind --enable-threads --disable-openssl-version-check --disable-ipv6

安装bind-9.7.2-P3

#Make 大概供给几分钟,只要不报错就继续下去。

tar -zxvf bind-9.7.2-P3.tar.gz

# make

cd bind-9.7.2-P3

#Make install 安装

./configure --enable-largefile --enable-threads --prefix=/usr/local/named
make

# make install

make install

从未有过报错,就象征安装成功了。

转移密钥:

开班配置bind,接下去的历程是让rndc来管理bind9.6

cd /usr/local/named/etc
/usr/local/named/sbin/rndc-confgen > /usr/local/named/etc/rndc.conf

始建 rndc.conf文件,用bind自带程序生成

tail -n10 rndc.conf |head -n9 |sed -e s/#//g > named.conf

进入/opt/bind/etc,将rndc.conf及named.conf生成

mkdir -p /usr/local/named/data

# cd /opt/bind/etc

下载named.root

# /opt/bind/sbin/rndc-confgen > /opt/bind/etc/rndc.conf

cd /usr/local/named/

把rndc.conf 中的key音讯输出到 named.conf 中

wget ftp://ftp.rs.internic.net/domain/named.root

# tail -10 rndc.conf | head -9 | sed -e s/# //g > named.conf

设置进程可由脚本达成,脚本内容如下,保存为install_bind.sh:

此处重申一下,rndc.conf与named.conf的key值必须完全同样,况且并无需生成rndc.key,这些难题郁结了自个儿大致3个小时

#!/bin/bash
rm -rf /etc/yum.repos.d/*.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo
yum -y install openssl-devel
cd /opt
wget
tar -zxvf bind-9.7.2-P3.tar.gz
cd bind-9.7.2-P3
./configure --enable-largefile --enable-threads --prefix=/usr/local/named
make
make install
cd /usr/local/named/etc
/usr/local/named/sbin/rndc-confgen > /usr/local/named/etc/rndc.conf
tail -n10 rndc.conf |head -n9 |sed -e s/#//g > named.conf
mkdir -p /usr/local/named/data
cd /usr/local/named/
wget ftp://ftp.rs.internic.net/domain/named.root
exit 1

# vim named.conf

执行sh脚本;

key "rndc-key" {

其次步、改革配置文件

algorithm hmac-md5;

named.conf、rndc.conf那多个布局文件地方为:/usr/local/named/etc

secret "WeHHAt0lui 9WihUW6HdsQ==";

域名相关的陈设文件地点为:/usr/local/named

};

2-1、修改named.conf

controls {

修改后内容如下:

inet 127.0.0.1 port 953

options {
        directory "/usr/local/named";
        pid-file "named.pid";
        listen-on port 53 {any;};
        allow-query {any;};
        dump-file "/usr/local/named/data/cache_dump.db";
        statistics-file "/usr/local/named/data/named_stats.txt";
        forward only;               //扩充转发功用
        forwarders {
                202.106.0.20;       //新加坡网通DNS服务器地址
                139.175.10.20;
        };

allow { 127.0.0.1; } keys { "rndc-key"; };

};

};

key "rndc-key" {
        algorithm hmac-md5;
        secret "jhdbq u4cE6KJdrJ6m6yAA==";  //注意“”号中的内容供给和rndc.conf中生成的key值相像;
};
 
controls {
        inet 127.0.0.1 port 953
                allow { 127.0.0.1; } keys { "rndc-key"; };
};
 
zone "."  IN {
        type hint;
        file "named.root";
};

options {

zone "localhost" IN {
         type master;
         file "localhost.zone";
         allow-update { none; };
};

directory "/opt/bind/var/named";

zone "0.0.127.in-addr.arpa" IN {
         type master;
         file "localhost.rev";
         allow-update { none; };
};

};

zone "linuxidc.com" IN {
         type  master;
         file "linuxidc.com.zone";
         allow-update { none; };
};

zone "." IN {

zone "1.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.1.zone";
        allow-update { none; };
};

type hint;

2-2、生成域名的布局文件

file "named.ca";

cd /usr/local/named

};

修改localhost.zone文件:

zone "localhost" IN {

vi localhost.zone

type master;

内容如下:

file "localhost.zone";

$TTL 3600
@    IN SOA  @    root (
                  20100923       ;serial (d. adams)
                  3H             ;refresh
                  15M            ;retry
                  1W             ;expiry
                  3600)          ;minimum
     IN NS   @
     IN A    127.0.0.1

};

修改localhost.rev文件:

zone "0.0.127.in-addr.arpa" IN {

vi localhost.rev

type master;

内容如下:

file "named.local";

$TTL 3600
@   IN SOA   localhost.   root.localhost. (
             20100923      ; serial
             3600          ; refresh every hour
             900           ; retry every 15 minutes
             3600000       ; expire 1000 hours
             3600)         ; minimun 1 hour
     IN NS  localhost.
1    IN PTR localhost.

allow-update { none; };

改过linuxidc.com.zone域名深入深入分析文件:

};

vi linuxidc.com.zone

zone "linuxidc.com" IN {

内容如下:

type master;

$TTL    86400
@               IN SOA dns.linuxidc.com.  root.linuxidc.com. (
                                        420000          ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                      IN NS           dns.linuxidc.com.
dns                 IN  A           192.168.1.107
www              IN  A           192.168.1.107
linuxidc.com.    IN  MX      5    mail.linuxidc.com.
bbs                IN  CNAME        www
mail               IN  A           192.168.1.6

file "linuxidc.zone";

改过反向解析文件192.168.1.zone

};

vi 192.168.1.zone

zone "88181.com" IN {

内容如下:

type master;

$TTL    86400
@               IN SOA dns.linuxidc.com. root.linuxidc.com. (
                                        1997022700      ; serial (d. adams)
                                        28800           ; refresh
                                        14400           ; retry
                                        3600000         ; expiry
                                        86400)         ; minimum
                IN NS                   dns.linuxidc.com.
107             IN PTR                  dns.linuxidc.com.
107             IN PTR                  www.linuxidc.com.
6               IN PTR                  mail.linuxidc.com.

file "88181.zone";

第三步 测试

};
创建named文件夹:

启动bind

# mkdir /opt/bind/var/named

/usr/local/named/sbin/named -gc /usr/local/named/etc/named.conf &

进入named文件夹

nslookup形式测验
 
正向查询
#nslookup
>www.linuxidc.com
Server:               192.168.1.107 
Address: 192.168.1.107#53    

# cd /opt/bind/var/named/

Name:      www.linuxidc.com 
Address: 192.168.64.128 

写入以下内容

反向查询
>192.168.1.107
Server:               192.168.1.107 
Address: 192.168.1.107#53    
107.1.168.192.in-addr.arpa name = www.linuxidc.com.  

# vi localhost.zone

别称询问
> set type=CNAME
>bbs.linuxidc.com
Server:               192.168.1.107 
Address: 192.168.1.107#53    
bbs.linuxidc.com      canonical name = www.linuxidc.com.  

写入以下内容:

查询SOA
>set type=SOA
>linuxidc.com
Server:               192.168.1.107 
Address: 192.168.1.107#53    
linuxidc.com          
    origin = dns.linuxidc.com          
    mail addr = root.linuxidc.com          
    serial = 420000          r
    efresh = 10800         
    retry = 900         
    expire = 604800         
    minimum = 86400 

$TTL 86400

查询NS
>set type=NS
>linuxidc.com
Server:               192.168.1.107 
Address: 192.168.1.107#53    
linuxidc.com     mail exchanger = 5 mail.linuxidc.com. 
> set type=NS    
> linuxidc.com  
Server:               192.168.1.107 
Address: 192.168.1.107#53    
linuxidc.com     nameserver = dns.linuxidc.com. 

$ORIGIN localhost.

查询MX
>set type=MX
>linuxidc.com
 
Server:               192.168.1.107 
Address: 192.168.1.107#53    
linuxidc.com     nameserver = dns.linuxidc.com. 
> set type=MX      
> linuxidc.com 
Server:               192.168.1.107 
Address: 192.168.1.107#53       
linuxidc.com     mail exchanger = 5 mail.linuxidc.com.

@ 1D IN SOA @ root (

澳门葡京真人网址 2

42 ; serial (d. adams)

3H ; refresh

15M ; retry

1W ; expiry

1D ) ; minimum

1D IN NS @

1D IN A 127.0.0.1

将跟服务器的信息导入到/opt/bind/var/named/named.ca文件中

# dig -t NS . >/opt/bind/var/named/named.ca

创立文件named.local

#vi named.local

本文由新浦京81707con发布于首页,转载请注明出处:澳门葡京真人网址Linux下源码搭建Bind服务器,快

关键词: 新浦京81707con

上一篇:日志设置

下一篇:没有了