且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Gentoo下搭建DNS中转服务器基本配置

更新时间:2022-09-13 13:34:19

网络环境

Hostname: zhengwing.org; mail.zhengwing.org; pop3.zhengwing.org; smtp.zhengwing.org.

IP add:192.168.254.254/24

Defaultgw:192.168.254.2

DNS server:192.168.254.2 ( Replace IP address to 192.168.254.123 when set completed. )

 

bind&&bind-tools安装       

shell>USE=”dlz” emerge –av bind bind-tools

 

查看named.conf文件(默认配置)

shell> cat  /etc/bind/named.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
acl "xfer" {
* If we have other name servers, place them here.
none;
};
acl "trusted" {
};
options {
listen-on { 127.0.0.1; };
allow-query {
trusted;
};
allow-query-cache {
trusted;
};
allow-recursion {
trusted;
};
allow-transfer {
none;
};
allow-update {
none;
};
forward first;
forwarders {
};
};
logging {
channel default_log {
print-time yes;
print-severity yes;
print-category yes;
};
category default { default_log; };
category general { default_log; };
};
controls {
};
zone "." in {
type hint;
};
zone "localhost" IN {
type master;
notify no;
};
zone "127.in-addr.arpa" IN {
type master;
notify no;
};

 

配置DNS服务器,随便找台可以使用的DNS服务器

shell> echo "nameserver    192.168.254.2" >> /etc/resolv.conf

获取根目录服务器

shell> dig –t NS

Gentoo下搭建DNS中转服务器基本配置

 

拷贝根目录IP添加到/etc/resolv.conf

格式为:

nameserver    198.41.0.4

Nameserver    192.228.79.201

…………………………………

Nameserver    192.36.148.17

 

导入根目录地址到named.cache文件

shell> dig –t NS . > /var/bind/named.cache

shell> cat /var/bind/named.cache 如下图

Gentoo下搭建DNS中转服务器基本配置

配置完成

测试

shell> echo "nameserver    127.0.0.1" > /etc/resolv.conf

shell> /etc/init.d/named restart

shell> host www.gentoo.org

Gentoo下搭建DNS中转服务器基本配置

如图,正向与反向解析成功。

添加域名解析功能

1. 修改DNS配置文件,添加以下内容

shell> vi /etc/bind/named.conf 

1
2
3
4
5
6
7
8
9
10
11
12
zone "zhengwing.org" IN {
type master;
file "pri/zhengwing.zone";
allow-update {none;};
notify no;
};
zone "254.168.192.in-addr.arpa" IN {
type master;
file "pri/192.168.254.zone";
allow-update {none;};
notify no;
};

 

2. 添加解析文件

shell> cd  /var/bind/pri

正向解析

shell> vi zhengwing.zone 

1
2
3
4
5
6
7
8
9
10
11
12
13
$TTL 1W
@       IN SOA  zhengwing.org   root.zhengwing.org. (
2010091808  ; Serial
28800 ; Refresh
14400 ; Retry
604800 ; Expire - 1 week
86400 ) ; Minimum
@       IN NS   zhengwing.org.
@       IN A    192.168.254.254
mail    IN CNAME        zhengwing.org.
smtp    IN CNAME        zhengwing.org.
pop3    IN CNAME        zhengwing.org.
@       IN MX           5       mail.zhengwing.org.

 

反向解析

shell> vi 192.168.254.zone

1
2
3
4
5
6
7
8
9
10
11
12
13
$ORIGIN 254.168.192.in-addr.arpa.
$TTL 1W
@       1D IN SOA       zhengwing.org   root.zhengwing.org. (
2010092204 ; serial
3H ; refresh
15M ; retry
1W ; expiry
1D ); minimum
@       1D IN NS        zhengwing.org.
254     1D IN PTR       zhengwing.org.
254     1D IN PTR       mail.zhengwing.org.
254     1D IN PTR       smtp.zhengwing.org.
254     1D IN PTR       pop3.zhengwing.org.

 

11.3 测试

shell> /etc/init.d/named restart

Gentoo下搭建DNS中转服务器基本配置










本文转自 chengchow 51CTO博客,原文链接:http://blog.51cto.com/chengchow/1209233,如需转载请自行联系原作者