如何configurationbind9为了指向服务器IP到nic?

简单的介绍

我从我的国家域名提供商nic.ir买了一个域名example.irnic.ir买了一个VPS。
我的VPS给了我一个静态IP,让我们想象它是: 170.120.100.140
安装在本地主机127.0.0.1和eth0 170.120.100.140上运行的Web服务器。
我可以通过SSH连接到我的VPS,做任何我想要的,我是一个新手…我的第一个VPS。

我做了什么?

其实安装我的bind9是这样的:

named.conf.local

 zone "example.ir" { type master; file "/etc/bind/db.example.ir"; }; zone "140.100.120.170.in-addr.arpa" { type master; file "/etc/bind/db.170"; }; 

db.example.ir

 $TTL 604800 @ IN SOA example.ir. root.example.ir. ( 2 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS example.ir. @ IN A 170.120.100.140 @ IN AAAA ::1 

db.170

 $TTL 604800 @ IN SOA example.ir. root.example.ir. ( 2 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS example.ir. 170 IN PTR example.ir. 

也永远不会忘记: service bind9 restart

我期望什么?

 root@examplevps$ nslookup example.ir Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: example.ir Address: 170.120.100.140 

这是我得到的

 root@examplevps$ nslookup example.ir ;; Got SERVFAIL reply from 8.8.8.8, trying next server Server: 4.2.2.4 Address: 4.2.2.4#53 ** server can't find example.ir: SERVFAIL 

结论

根据我上面提供的信息,我完全清楚自己想要什么…我想我必须这样做:

  +------------------+ | My VPS | | 170.120.100.140 | +------------------+ | +------------------+ | ns.examplevps.ir | bind 170.120.100.140 > example.ir +------------------+ | +------------------+ | nic.ir | bind ns.examplevps.ir > nic.ir +------------------+ 

我在网上阅读了很多页面,但仍然无法弄清楚它是如何工作的。

您需要允许来自evereywhere的查询。 将以下内容添加到named.conf.local每个区段语句中,以单独允许查询区段或将其添加到named.conf.options以允许查询所有区段:

 allow-query { any; }; 

我build议使用dig来debugging:

 apt-get install dnsutils # for debian/ununtu dig +trace example.ir 

此外,你需要指出你的nic服务器。 这通常是在networking界面完成的,在这里你可以用名称服务器为区域指定每个区域的胶水logging,格式如下:

 ns.example.ir -> 170.120.100.140 

很有可能你还必须提供2个域名服务器。 您可以将它们指向相同的IP,尽pipe您可能会收到一条警告消息,表示不使用2个不同的IP地址。

 ns1.example.ir -> 170.120.100.140 ns2.example.ir -> 170.120.100.140 

您还需要在dns服务器的区域中定义胶水logging:

 @ IN SOA ns1.example.ir. hostmaster.example.ir. ( ... ( @ IN NS ns1 @ IN NS ns2 ... ns1 IN A 170.120.100.140 ns2 IN A 170.120.100.140 ...