Ubuntu中dns泛解析的配置



Ubuntudns泛解析的配置

首先准备一台dns服务器和你需要解析的域名,在这里我们ubuntu服务器的ip地址是

172.16.56.30和需要解析的泛域名为:*.abc.com

首先安装bind9这个软件在服务器上

root@MOPAAS:~# apt-get install bind9

然后就是最重要的配置了

配置文件在/etc/bind

named.conf.local中添加需要dns服务器正方向解析的文件

root@MOPAAS:/etc/bind# vi named.conf.local

//

// Do any local configuration here

//

 

// Consider adding the 1918 zones here, if they are not used in your

// organization

//include "/etc/bind/zones.rfc1918";

zone "56.16.172.in-addr.arpa" {  #此处为你需要解析的ip地址的ip段注意写法。

        type master;

        file "/etc/bind/db.172.16.56";#反向解析的文件

};

zone "abc.com" {

        type master;

        file"/etc/bind/db.abc.com";#正向解析的文件

};

保存退出

配置正向解析文件

root@MOPAAS:/etc/bind# vi db.abc.com

;

; BIND data file for local loopback interface

;

$TTL    604800

@       IN      SOA    abc.com. root.abc.com. (

                             2         ; Serial

                        604800         ; Refresh

                         86400         ; Retry

                       2419200         ; Expire

                         604800)       ; Negative Cache TTL

;

@       IN      NS     abc.com.  #注意后面的.

@       IN      A      172.16.56.30 #ip就是你要解析的ip地址

*.abc.com.  IN      A      172.16.56.30

配置反向解析文件root@MOPAAS:/etc/bind#vi db.172.16.56

;

; BIND reverse data file for local loopbackinterface

;

$TTL   604800

@      IN      SOA     abc.com. root.abc.com. (

                              1         ; Serial

                         604800         ; Refresh

                          86400         ; Retry

                        2419200         ; Expire

                         604800 )       ; Negative Cache TTL

;

@      IN      NS      abc.com.

30     IN      PTR     abc.com.

保存退出

然后重启bind9 服务

root@MOPAAS:/etc/bind#/etc/init.d/bind9  restart

然后在修改下本地的dns服务器配置

root@MOPAAS:/etc/bind# vi /etc/resolv.conf

nameserver 172.16.56.30

保存退出

服务器端配置完成

客户端配置

只需要在etc/resolv.conf中配置下dns服务器的ip即可

root@MOPAAS:# vi /etc/resolv.conf

nameserver 172.16.56.30

然后测试下是否配置成功

root@MOPAAS: # ping sadsad.abc.com

如果能ping通则成功,否则查看你的配置以及你的dns服务器是否使用了代理,如果使用就去掉。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
好的,我可以为您提供大致的步骤。具体细节因环境不同而异,请您根据自己的实际情况适当调整。 1. 安装 DNS 服务器 在 Ubuntu 上安装 DNS 服务器可以使用 BIND9 工具,可以使用以下命令进行安装: ``` sudo apt-get update sudo apt-get install bind9 ``` 2. 配置正向解析 正向解析是指将域名解析为 IP 地址,可以通过以下步骤进行配置: - 编辑 /etc/bind/named.conf.local 文件,添以下内容: ``` zone "example.com" { type master; file "/etc/bind/db.example.com"; }; ``` - 创建 /etc/bind/db.example.com 文件,添以下内容: ``` $TTL 604800 @ IN SOA ns1.example.com. admin.example.com. ( 3 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS ns1.example.com. @ IN A 192.168.0.100 ``` 其,example.com 是您的域名,192.168.0.100 是您的 IP 地址,可以根据实际情况进行修改。 - 重启 BIND9 服务: ``` sudo systemctl restart bind9 ``` 3. 配置反向解析 反向解析是指将 IP 地址解析为域名,可以通过以下步骤进行配置: - 编辑 /etc/bind/named.conf.local 文件,添以下内容: ``` zone "0.168.192.in-addr.arpa" { type master; file "/etc/bind/db.192"; }; ``` - 创建 /etc/bind/db.192 文件,添以下内容: ``` $TTL 604800 @ IN SOA ns1.example.com. admin.example.com. ( 2 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS ns1.example.com. 100 IN PTR example.com. ``` 其,example.com 是您的域名,100 是您的 IP 地址的最后一段数字,可以根据实际情况进行修改。 - 重启 BIND9 服务: ``` sudo systemctl restart bind9 ``` 完成以上步骤后,您的 DNS 服务器就可以进行正反向解析了。您可以通过在其他主机上配置 DNS 服务器为您的 Ubuntu 服务器的 IP 地址,然后在命令行使用 nslookup 命令进行测试。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值