virtualmin-在 VPS 上设置私有名称服务器

virtualmin-在 VPS 上设置私有名称服务器

我正在尝试在我的 VPS 上设置自己的名称服务器,例如 ns1.example.com

我已经在 Namecheap.com 中设置了我的域名的名称服务器(ns1 和 ns2,指向我的 VPS 的 IP 地址)。我似乎无法让它工作。打开 example.com 没有显示任何内容:

$ curl example.com
curl: (7) Failed to connect to example.com port 80: No route to host

请注意,Apache 运行良好,因为我可以使用 VPS IP 打开它。这是我的服务器配置

/etc/主机名

ns1

/etc/hosts

127.0.0.1   localhost.localdomain localhost
172.31.1.100    ns1.example.com ns1
172.31.1.100    ns2.example.com ns2

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
2a01:4f8:c17:1eeb::2  ns1.example.com ns1
2a01:4f8:c17:1eeb::2  ns2.example.com ns2

/etc/bind/named.conf

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

/etc/bind/named.conf.options

options {
    directory "/var/cache/bind";
    recursion no;
    allow-transfer { none; };

    dnssec-validation auto;

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

/etc/bind/named.conf.local

zone "example.com" {
    type master;
    file "/var/lib/bind/example.com.hosts";
    allow-transfer {
        127.0.0.1;
        localnets;
        172.31.1.100;
        };
    };

/etc/bind/named.conf.默认区域;

zone "." {
    type hint;
    file "/etc/bind/db.root";
};

zone "localhost" {
    type master;
    file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
    type master;
    file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
    type master;
    file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
    type master;
    file "/etc/bind/db.255";
};

/var/lib/bind/example.com.hosts

$ttl 38400
@   IN  SOA example.com. root.example.com. (
            1486054499
            10800
            3600
            604800
            38400 )
example.com.        IN  NS  ns1.example.com.
example.com.        IN  NS  ns2.example.com.
ns1.example.com.    IN  A   172.31.1.100
ns2.example.com.    IN  A   172.31.1.100
example.com.        IN  A   172.31.1.100
www.example.com.    IN  A   172.31.1.100
ftp.example.com.    IN  A   172.31.1.100
m.example.com.      IN  A   172.31.1.100
localhost.example.com.  IN  A   127.0.0.1
mail.example.com.   IN  A   172.31.1.100
example.com.        IN  MX  5 mail.example.com.
example.com.        IN  TXT "v=spf1 a mx a:example.com ip4:172.31.1.100 ip6:2a01:4f8:c17:1eeb::2 ?all"

答案1

谢谢迈克尔·汉普顿

问题是我使用的是私有 IP 而不是公共 IP。

将所有私有 IP 更改为我的 VPS 公共 IP,现在一切正常。

相关内容