如何使用bind9从外部解析域? [英] How to resolve domain externally with bind9?

查看:445
本文介绍了如何使用bind9从外部解析域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前言

我通过家庭网络将Web服务器和DNS服务器托管在同一盒子上.外部IP是动态的.为了解决这个问题,我使用名为no-ip.com的付费服务来自动更新mydnsserver.com的IP(假设外部IP为11.22.33.444).我想使用mydnsserver.com解析mywebsite.com(以及以后的任何其他网站),以便与mywebsite.com的所有外部连接都将由Apache处理.
 

问题

我遇到的无法解决的问题是,当我通过手机(外部连接)访问mywebsite.com时,浏览器解析为localhost.我需要该域来解析(在服务器内部和外部)运行在mydnsserver.com上的Apache,以便从我的服务器呈现网站.我想这样做,而不必输入A记录的服务器IP地址.
 

注册商设置(Godaddy)

mywebsite.com名称服务器设置

ns.mydnsserver.com
ns2.mydnsserver.com

mydnsserver.com名称服务器设置

ns1.no-ip.com
ns2.no-ip.com
ns3.no-ip.com
ns4.no-ip.com
ns5.no-ip.com


解析配置

/etc/resolve.conf

domain mywebsite.com
search mywebsite.com
nameserver 127.0.0.1


Bind9配置

/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";
    dnssec-validation auto;
    auth-nxdomain no;
    listen-on-v6 { any; };
    listen-on port 53 { any; };
};

/etc/bind/named.conf.default-zones

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

zone "mywebsite.com" {
    type master;
    file "/etc/bind/zones/mywebsite.zone";
};

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";
};

/etc/bind/zones/mywebsite.zone

$TTL 1d
@       IN      SOA     mywebsite.com. root.mywebsite.com. (
                       2014112501   ; serial#
                       1h           ; refresh, seconds
                       1h           ; retry, seconds
                       1h           ; expire, seconds
                       1h )         ; minimum, seconds

@               IN      NS      mywebsite.com.
@               IN      A       127.0.0.1
@               IN      MX 0    mail.mywebsite.com.
www     IN      A       127.0.0.1


nslookup

mywebsite.com

Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   mywebsite.com
Address: 127.0.0.1

mydnsserver.com

Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
Name:   mydnsserver.com
Address: 11.22.33.444


我在做什么是不可能的吗?我是否必须使用真实的IP地址来解析?看起来它正在执行的工作就是将我输入的内容完全输入到区域文件中,然后将任何浏览器设置为完全相同.

解决方案

将区域文件移出/etc/bind/zones并更新named.conf.default以在新位置中查找区域解决了该问题./p>

Preface

I am hosting a web server and DNS server on the same box over a home network. The external IP is dynamic. To handle this, I use a paid service called no-ip.com to automatically update the IP of mydnsserver.com (let's say external IP is 11.22.33.444). I want to use mydnsserver.com to resolve mywebsite.com (and any other websites later on) so that all external connections to mywebsite.com will be handled by Apache.
 

Problem

The problem that I am having and can't find a solution to is that when I visit mywebsite.com on my phone (external connection), my browser resolves to localhost. I need the domain to resolve (both internal to the server and externally) to Apache running on mydnsserver.com so that the website will be rendered from my server. I want to do this without having to enter the IP address of the server for the A record.
 

Registrar Settings (Godaddy)

mywebsite.com nameserver settings

ns.mydnsserver.com
ns2.mydnsserver.com

mydnsserver.com nameserver settings

ns1.no-ip.com
ns2.no-ip.com
ns3.no-ip.com
ns4.no-ip.com
ns5.no-ip.com


Resolve Config

/etc/resolve.conf

domain mywebsite.com
search mywebsite.com
nameserver 127.0.0.1


Bind9 Config

/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";
    dnssec-validation auto;
    auth-nxdomain no;
    listen-on-v6 { any; };
    listen-on port 53 { any; };
};

/etc/bind/named.conf.default-zones

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

zone "mywebsite.com" {
    type master;
    file "/etc/bind/zones/mywebsite.zone";
};

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";
};

/etc/bind/zones/mywebsite.zone

$TTL 1d
@       IN      SOA     mywebsite.com. root.mywebsite.com. (
                       2014112501   ; serial#
                       1h           ; refresh, seconds
                       1h           ; retry, seconds
                       1h           ; expire, seconds
                       1h )         ; minimum, seconds

@               IN      NS      mywebsite.com.
@               IN      A       127.0.0.1
@               IN      MX 0    mail.mywebsite.com.
www     IN      A       127.0.0.1


nslookup

mywebsite.com

Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   mywebsite.com
Address: 127.0.0.1

mydnsserver.com

Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
Name:   mydnsserver.com
Address: 11.22.33.444


Is what I am doing is not possible? Do I -have- to use the real IP address to resolve to? It looks like what it's doing is taking exactly what I enter into the Zone File, and setting any browser to exactly that.

解决方案

Moving the zone file out of /etc/bind/zones and updating the named.conf.default to look for zones in the new location fixed the issue.

这篇关于如何使用bind9从外部解析域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆