Nginx

為什麼使用我的域地址無法訪問我的網站?

  • June 24, 2020

我使用以下文件創建了一個 DNS 伺服器,將我的域地址映射sudia.com到我的 VPS 伺服器,但它不起作用,我無法使用我的域地址訪問我的伺服器。還必須說有一個 NginX 正在執行ttp://136.243.197.164:3200

/etc/named.conf:目錄“/var/named”;轉儲文件“/var/named/data/cache_dump.db”;統計文件“/var/named/data/named_stats.txt”;memstatistics-file “/var/named/data/named_mem_stats.txt”; secroots-file “/var/named/data/named.secroots”; 遞歸文件“/var/named/data/named.recursing”;允許查詢{本地主機;136.243.197.164;};

       /*
        - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
        - If you are building a RECURSIVE (caching) DNS server, you need to enable
          recursion.
        - If your recursive DNS server has a public IP address, you MUST enable access
          control to limit queries to your legitimate users. Failing to do so will
          cause your server to become part of large scale DNS amplification
          attacks. Implementing BCP38 within your network would greatly
          reduce such attack surface
       */
       recursion yes;

       dnssec-enable yes;
       dnssec-validation yes;

       managed-keys-directory "/var/named/dynamic";

       pid-file "/run/named/named.pid";
       session-keyfile "/run/named/session.key";

       /* https://fedoraproject.org/wiki/Changes/CryptoPolicy */
       include "/etc/crypto-policies/back-ends/bind.config";
};

logging {
       channel default_debug {
               file "data/named.run";
               severity dynamic;
       };
};

zone "." IN {
       type hint;
       file "named.ca";
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

//forward zone
zone "sudia.com" IN {
       type master;
       file "fwd.sudia.com.db";
       allow-update { none; };
       allow-query  { any; };
};

//backward zone
zone "197.243.136.in-addr.arpa" IN {
       type master;
       file "sudia.com.rev";
       allow-update { none; };
       allow-query  { any; };
};

/var/named/fwd.sudia.com.db:

$TTL 86400
@   IN  SOA     ns1.sudia.com. root.sudia.com. (
                                             3           ;Serial
                                             3600        ;Refresh
                                             1800        ;Retry
                                             604800      ;Expire
                                             86400       ;Minimum TTL
)

;Name Server Information
@       IN  NS      ns1.sudia.com.

;IP address of Name Server
ns1       IN  A       136.243.197.164

;A - Record HostName To Ip Address
www     IN  A       136.243.197.164

;CNAME record
ftp     IN CNAME        www.sudsuz.com.

/var/named/sudia.com.rev:

$TTL 86400
@   IN  SOA     ns1.sudia.com. root.itzgeek.local. (
                                      3           ;Serial
                                      3600        ;Refresh
                                      1800        ;Retry
                                      604800      ;Expire
                                      86400       ;Minimum TTL
)

;Name Server Information
@         IN      NS         ns1.sudia.com.

;Reverse lookup for Name Server
164        IN  PTR     ns1.sudia.com.

;PTR Record IP address to HostName
164      IN  PTR     www.sudia.com

編輯:這是結果host www.sudia.com

www.sudia.com has address 136.243.197.164

但是host sudia.com(沒有www)不起作用!

您的區域文件沒有 www.sudia.com 的正確記錄。將此添加到您的區域。例如,通過更改此文件/var/named/fwd.sudia.com.db或通過 nsupdate:

方法一(更新文件/var/named/fwd.sudia.com.db,別忘了更新串口):

@    IN    A    136.243.197.164

方法 2 (nsupdate) 例如:

[root@ns1 ~]# nsupdate -k /etc/rndc.key
> server localhost
> zone sudia.com.
> update add sudia.com. 3600 IN A 136.243.197.164
> send
[root@ns1 ~]#

然後您的名稱伺服器可以將根域(例如 sudia.com)解析為正確的 IP 地址。

引用自:https://serverfault.com/questions/1022459