ubuntu搭建dns(正反向解析)

首先安装bind9

进入安装目录

查看是否有相应文件

先编辑named.conf.default-zones文件

添加下面两个内容

wyn.com可以自定义,例如xxx.com

240.165.10IP地址和你的电脑IP地址是反的

file对应的文件需要创建

创建文件

编辑文件

内容如下

创建文件

编辑文件

编辑文件

options {
        directory "/var/cache/bind";
        listen-on port 53 {127.0.0.1;10.165.240.100; };
        allow-transfer { none; }; 
        recursion yes;    
        // If there is a firewall between you and nameservers you want
        // to talk to, you may need to fix the firewall to allow multiple
        // ports to talk.  See http://www.kb.cert.org/vuls/id/800113

        // If your ISP provided one or more IP addresses for stable 
        // nameservers, you probably want to use them as forwarders.  
        // Uncomment the following block, and insert the addresses replacing 
        // the all-0's placeholder.

        // forwarders {
        //      0.0.0.0;
        // };

//========================================================================
        // If BIND logs error messages about the root key being expired,
        // you will need to update your keys.  See https://www.isc.org/bind-keys
        //========================================================================
        dnssec-validation auto;

        auth-nxdomain no;    # conform to RFC1035
        listen-on-v6 { any; };
};
     

最后一步。编辑resolv.conf文件

这里需要设置为自己的IP地址

解析

如果只想解析wyn.com添加最下面那一行

即可

  • 3
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 9
    评论
好的,我可以为您提供大致的步骤。具体细节因环境不同而异,请您根据自己的实际情况适当调整。 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 命令进行测试。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

C9ccc00

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值