如何向 named.conf 添加第二个域?

如何向 named.conf 添加第二个域?

我在注册商处注册了两个域名,并在托管服务提供商处注册了一个 VPS(分开)。

我可以通过将以下内容添加到 /etc/named.conf 来访问其中一个域:

zone "domain1.com" in {
        type master;
        file "/var/named/domain1.com.zone";
};

但是,我无法添加另一个?我在托管服务提供商处有两个 IP 地址。

我尝试添加这个,但没有效果:

zone "domain2.com" {
        type slave;
        file "/var/named/domain2.com.zone";
        masters { 12.34.56.78; };
};

按照使用 named.conf 配置两个 DNS 区域我也尝试过这个:

zone "domain1.com" in {
        type master;
        file "/var/named/domain1.com.zone";
        allow-transfer {12.34.56.78;12.34.56.79;};
};

zone "domain2.com" {
        type master;
        file "/var/named/domain2.com.zone";
        allow-transfer {12.34.56.78;12.34.56.79;};
};

这是 CentOS。


編輯1

# /etc/init.d/named restart
Stopping named:                                            [  OK  ]
Starting named:
Error in named configuration:
/var/named/domain1.com.zone:2: no TTL specified; using SOA MINTTL instead
zone domain1.com/IN: loaded serial 2010082500
dns_rdata_fromtext: /var/named/domain2.com.zone:2: near eol: unexpected end of input
/var/named/domain2.com.zone:4: unknown RR type '600'
zone domain2.com/IN: loading master file /var/named/domain2.com.zone: unexpected end of input
_default/domain2.com/IN: unexpected end of input
                                                           [FAILED]

答案1

一个字符的位置不对就导致了这次爆发!注意左括号!

在domain2.com.zone中,我有:

; domain2.com
@                       IN SOA           ns1.domain2.com www.someotherdomain.com.
(
        2010082500      ; serial
        3600            ; refresh every 8 hours
        600             ; retry every 4 hours
        86400           ; expire 1000 hours
        3600            ; minimum 24 hours
)
...

而它应该是:

; domain2.com
@                       IN SOA           ns1.domain2.com www.someotherdomain.com. (
        2010082500      ; serial
        3600            ; refresh every 8 hours
        600             ; retry every 4 hours
        86400           ; expire 1000 hours
        3600            ; minimum 24 hours
)

它与named.conf设置配合良好:

zone "domain1.com" in {
        type master;
        file "/var/named/domain1.com.zone";
        allow-transfer {12.34.56.78;12.34.56.79;};
};

zone "domain2.com" {
        type master;
        file "/var/named/domain2.com.zone";
        allow-transfer {12.34.56.78;12.34.56.79;};
};

相关内容