AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1297425
Accepted
Alpcap
Alpcap
Asked: 2020-12-05 04:28:50 +0800 CST2020-12-05 04:28:50 +0800 CST 2020-12-05 04:28:50 +0800 CST

服务器找不到:SERVFAIL & Bind9 DNS 服务器设置

  • 772

我正在尝试在 VPS 服务器上部署 Web 应用程序。该应用程序使用 Django 构建,目前正在尝试使用 Apache2 提供文件。我在使用 DNS 设置(bind9)时遇到问题。我使用的公司对此没有帮助。

你能帮我解决这个我处理了 3 天的问题吗?

操作系统:

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.7 LTS
Release:        16.04
Codename:       xenial

_

nslookup example.com

;; Got SERVFAIL reply from 8.8.8.8, trying next server
Server:         8.8.4.4
Address:        8.8.4.4#53

** server can't find example.com : SERVFAIL

_

nslookup example.com 185.106.209.113

Server:         185.106.209.113
Address:        185.106.209.113#53

Name:   
Address: 185.106.209.113

当我访问http://185.106.209.113/地址时,我可以看到 Apache2 默认页面。如果我输入http://example.com/会抛出DNS_PROBE_FINISHED_NXDOMAIN错误。

|-- [-rwxr-xr-x bind    ]  bind.keys
|-- [-rwxr-xr-x bind    ]  db.0
|-- [-rwxr-xr-x bind    ]  db.127
|-- [-rwxr-xr-x bind    ]  db.255
|-- [-rwxr-xr-x bind    ]  db.empty
|-- [-rwxr-xr-x bind    ]  db.local
|-- [-rwxr-xr-x bind    ]  db.root
|-- [-rwxr-xr-x bind    ]  named.conf
|-- [-rwxr-xr-x bind    ]  named.conf.default-zones
|-- [-rwxr-xr-x bind    ]  named.conf.local
|-- [-rwxr-xr-x bind    ]  named.conf.local.back
|-- [-rwxr-xr-x bind    ]  named.conf.options
|-- [-rwxr-xr-x bind    ]  rndc.key
|-- [drwxr-sr-x bind    ]  zones
|   |-- [-rwxr-xr-x bind    ]  db.185.106
|   `-- [-rwxr-xr-x bind    ]  db.example.com
`-- [-rwxr-xr-x bind    ]  zones.rfc1918

命名的.conf.options:

acl "trusted" {
        185.106.209.113;
};



options {
        directory "/var/cache/bind";

        // If your ISP provided one or more IP addresses for stable
        // nameservers, you probably want to use them as forwarders.

        forwarders {
                185.106.209.113;
        };

        dnssec-validation auto;

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

命名.conf.local:

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

zone "example.com" {
        type master;
        file "/etc/bind/zones/db.example.com";
        allow-transfer { 185.106.209.113; };
        also-notify { 185.106.209.113; };
};

zone "209.106.185.in-addr.arpa" {
        type master;
        file "/etc/bind/zones/db.185.106";
        allow-transfer { 185.106.209.113; };
        also-notify {185.106.209.113; };
};

db.example.com:

;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     ns1.example.com. root.example.com. (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
; NS records
@       IN      NS      ns1.example.com.
@       IN      NS      ns2.example.com.
@       IN      A       185.106.209.113

; A records
ns1.example.com.    IN      A       185.106.209.113
ns2.example.com.    IN      A       185.106.209.113

db.185.106

;
; BIND reverse data file for local loopback interface
;
$TTL    604800
@       IN      SOA     ns1.example.com. root.example.com. (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
; name servers - NS records
        IN      NS      ns1.example.com.
        IN      NS      ns2.example.com.

; PTR Records
113.209 IN      PTR     ns1.example.com.    ; 185.106.209.113
113.209 IN      PTR     ns2.example.com.    ; 185.106.209.113

和防火墙状态:

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
80/tcp                     ALLOW       Anywhere
Apache Full                ALLOW       Anywhere
8000                       ALLOW       Anywhere
53                         ALLOW       Anywhere
22 (v6)                    ALLOW       Anywhere (v6)
80/tcp (v6)                ALLOW       Anywhere (v6)
Apache Full (v6)           ALLOW       Anywhere (v6)
8000 (v6)                  ALLOW       Anywhere (v6)
53 (v6)                    ALLOW       Anywhere (v6)
server dns 16.04 bind
  • 2 2 个回答
  • 16053 Views

2 个回答

  • Voted
  1. Діма Ліщинський
    2022-06-24T02:18:04+08:002022-06-24T02:18:04+08:00

    更改您的文件named.conf.options:

    dnssec-验证号;

    acl "trusted" {
            185.106.209.113;
    };
    
    options {
            directory "/var/cache/bind";
    
            // If your ISP provided one or more IP addresses for stable
            // nameservers, you probably want to use them as forwarders.
    
            forwarders {
                    185.106.209.113;
            };
    
            dnssec-validation no;
    
            auth-nxdomain no;    # conform to RFC1035
            listen-on-v6 { any; };
    };
    
    • 2
  2. Best Answer
    Reza Azimi
    2020-12-05T11:48:00+08:002020-12-05T11:48:00+08:00

    所以按照这些步骤,它对我有用,我相信它对你有用。

    1.将您的主机名设置为您的服务器名称之一,例如:

    server.example.com


    2.配置/etc/network/中的接口,如:

    iface ens3 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    

    不要忘记重新启动“网络”。

    现在让我们配置绑定。你不需要编辑所有的数据库,就像下面这样:

    打开 /etc/bind/named.conf.local 在文件末尾添加:

    zone "example.com" IN {
    type master;
    file "/etc/bind/forward.example.com";
    };
    
    zone "1.168.192.in-addr.arpa" IN {
    #1.168.192 is the reverse of 192.168.1 wit out the last part "10"
    type master;
    file "/etc/bind/reverse.example.com";
    }
    

    现在在 /etc/bind

    cp db.local  forward.example.com
    

    现在编辑 forward.example.com

    ;
    ; BIND data file for local loopback interface
    ;
    $TTL    604800
    @       IN      SOA     server.example.com. root.server.example.com. ( //Important dot(.) after domain names
                                  2         ; Serial
                             604800         ; Refresh
                              86400         ; Retry
                            2419200         ; Expire
                             604800 )       ; Negative Cache TTL
    ;
    @       IN      NS      server.example.com.
    @       IN      A       xxx.xxx.xxx.xxx #your public static ip adress if you- 
    server  IN      A       xxx.xxx.xxx.xxx #did you portforwards in NAT if you - 
    host    IN      A       xxx.xxx.xxx.xxx #didn't import the static private ip-
    client  IN      A       xxx.xxx.xxx.xxx #address.
    www     IN      A       xxx.xxx.xxx.xxx
    
    @       IN      NS      ns1.example.com.
    @       IN      A       xxx.xxx.xxx.xxx
    ns1     IN      A       xxx.xxx.xxx.xxx
    
    @       IN      MX      10 admin.example.com.
    @       IN      A       xxx.xxx.xxx.xxx
    admin   IN      A       xxx.xxx.xxx.xxx
    
    #this config contains email server configure too.
    

    现在在同一个目录中cp forward.example.com reverse.example.com

    现在编辑反向区域,如下所示:

    ;
    ; BIND data file for local loopback interface
    ;
    $TTL    604800
    @       IN      SOA     server.example.com root.server.example.com. (
                                  2         ; Serial
                             604800         ; Refresh
                              86400         ; Retry
                            2419200         ; Expire
                             604800 )       ; Negative Cache TTL
    ;
    @       IN      NS      server.example.com.
    @       IN      PTR     exapmle.com.
    server  IN      A       xxx.xxx.xxx.xxx
    host    IN      A       xxx.xxx.xxx.xxx
    client  IN      A       xxx.xxx.xxx.xxx
    www     IN      A       xxx.xxx.xxx.xxx
    10      IN      PTR     server.exapmle.com.
    11      IN      PTR     client.exapmle.com.
    
    @       IN      NS      ns1.exapmle.com.
    ns1     IN      A       xxx.xxx.xxx.xxx
    10      IN      PTR     ns1.exapmle.com.
    
    @       IN      MX      10 admin.exapmle.com.
    admin   IN      A       xxx.xxx.xxx.xxx
    10      IN      PTR     admin.exapmle.com.
    #the ten in above of hashtag is the end number of your ip 192.168.1.(10)
    or xxx.xxx.xxx.(xxx)
    

    现在配置正向和反向区域。遵循命令:

    sudo named-checkconf -z /etc/bind/named.conf
    sudo named-checkconf -z /etc/bind/named.conf.local
    sudo named-checkzone forward /etc/bind/forward.example.com
    sudo named-checkzone reverse /etc/bind/reverse.example.com
    

    输出应显示区域已加载并且没有错误。

    现在重新启动绑定。如果出现错误,只需使用journalctl -xe并多次查看详细信息,这只是一个错字和类似的错误。

    现在做这些:

    sudo chown -R bind:bind /etc/bind
    sudo chmod -R 755 /etc/bind
    sudo systemctl restart bind9
    sudo systemctl enable bind9
    
    
    ufw allow bind9
    ufw allow 53
    ufw allow 53/tcp
    ufw allow 53/udp
    

    再次转到 /etc/network/interfaces 在文件末尾添加:

    dns-search example.com
    dns-nameserver 192.168.1.10
    

    之后重新启动网络sudo systemctl restart networking

    现在纳米这个文件:/etc/resolv.conf

    在文件末尾添加这些:

    nameserver 192.168.1.10
    search example.com
    

    重启网络重启 NetworkManager

    现在 ping/nslookup/dig ns.example.com 或 server.example.com

    现在它正在工作

    • 1

相关问题

  • 使用 dpkg 手动安装软件包是否会阻止未来的升级路径?

  • 如何从命令行刻录双层 dvd iso

  • 如果在服务器机器上运行 Ubuntu 桌面版,性能损失是多少?

  • 将桌面版剥离为服务器版的最简单方法是什么?

  • 如何与无头服务器进行图形交互?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve