【问题标题】:how do i set up local bind server for dev machine to map to vhosts on server如何为开发机器设置本地绑定服务器以映射到服务器上的虚拟主机
【发布时间】:2015-07-04 13:53:54
【问题描述】:

我试图在一个 Arch linux 机器上设置一个绑定 dns 控制器https://wiki.archlinux.org/index.php/BIND。我需要做的主要事情是,我不再需要在我的 win7 开发框中再次编辑 windows/system32/drivers/etc/hosts 文件,并且可以删除其中的每个自定义条目,并让绑定映射虚拟主机给我的条目。

这是我当前的 /etc/named.conf http://dpaste.com/1XZ8JJR 这是我的 /var/named/falcon.local.zone http://dpaste.com/094JGPR

我正在将我的域名更改为 ld.pvt,因此当您看到对 falcon.local 的引用时,它们正在升级

关于这台机器的更多信息, 主机名:falcon,多个角色;主备份 san zfs 阵列、用于个人内部的专业开发人员的 apache LAMP 堆栈、dns(新)、ssh 等。

我想要的是这台 dns 服务器机器 (falcon) 以提供其所有共享相同子域 (ld.pvt) 的 vhost 资源。
资源可能如下所示:

bleedingedgewebsites.com.ld.pvt (domain mimick, for development)
falcon.ld.pvt (root address, this one will just list directory, so i can easily click into any forgotton resources or resources missing vhost entries)
phpmyadmin.ld.pvt
tickets.ld.pvt
jenkins.ld.pvt

在区域文件中,我更喜欢对内部资源使用通配符,但不必(例如 *.ld.pvt)),然后我不需要单独列出每个,每次我来有了新的东西。 ,我宁愿只将条目添加到 vhost 文件中,然后在开发机器的地址栏中键入它,然后 VIOLA!

这些可以是 A 记录,还是 CNAMES?

(经过最近的研究,我知道通配符可能在虚拟主机中,这里只需要一个条目......)

区域 SOA 应该是 ns1.ld.pvt,还是 <hostname>.ld.pvt,还是前者,但两者都有 A 记录?

在 Arch 网站上还有另一个例子。我夹在这个https://wiki.archlinux.org/index.php/BIND#1._Creating_a_zonefile 之间,它有一个免责声明,它只是一个起点,以及所有其他更适合我需要的东西,但不是特定于拱门的,就像这些https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-ubuntu-14-04 https://help.github.com/articles/tips-for-configuring-an-a-record-with-your-dns-provider/ 一样?

我需要一个很好的例子 /var/named/ld.pvt.zone /etc/named.conf 主条目

我只需要任何一种可行的解决方案即可开始。

【问题讨论】:

  • 这篇文章解决了我的很多问题blog.straylightrun.net/2010/05/10/…
  • 除非您出于某种原因特别需要 BIND,否则我建议您坚持使用 dnsmasq。
  • 我愿意,我想实现一个完整的 dns 服务器,这是我在完整堆栈上唯一没有学到的东西,它会加速我的网络。
  • 我应该帮自己一个忙然后开枪,呃呃呃删除帖子?也许只是停止提问?在底片???????

标签: linux dns bind vhosts


【解决方案1】:

要让绑定正常工作,需要遵循一些规则来正确配置它。

您需要选择一个域,为其添加区域记录,在此区域记录中仅在顶部添加一个主机名条目,否则所有提及的只是域。

在配置文件中,所有域名都以点结尾是个好习惯,例如域.com。

NS名称,可以是域名。

A 记录可以是机器的 ip,而不是 localhost,因为你网络中的其他机器会拉取这个指定的 ip。

一旦你有了记录,你就可以疯狂地添加你的域名,或者你可以使用通配符,这就是我所做的。所以现在所有以我选择的域结尾的域都映射到网络开发的东西。

在你想使用DNS服务的机器上的适配器IP属性中的DNS设置,即客户端,你想将DNS设置为DNS服务器的lan ip。

只需要调整 /etc/named.conf、/var/named/ld.pvt.zone 和我刚才提到的 IP 属性。

这里是配置文件,享受吧!

/etc/named.conf

// vim:set ts=4 sw=4 et:

acl "trusted" {
        192.168.1.0/24;
        127.0.0.0/8;
};

options {
    directory "/var/named";
    pid-file "/run/named/named.pid";
    listen-on { trusted; };
    listen-on-v6 { any; };
    allow-query { trusted; };
    allow-transfer { none; };
    allow-update { none; };
    forwarders {
        8.8.4.4;
        8.8.8.8;
    };
    query-source address * port 53;
    version none;
    hostname none;
    server-id none;
};

logging {
    channel default_file {
        file "/var/log/named/default.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel general_file {
        file "/var/log/named/general.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel database_file {
        file "/var/log/named/database.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel security_file {
        file "/var/log/named/security.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
channel config_file {
        file "/var/log/named/config.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel resolver_file {
        file "/var/log/named/resolver.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel xfer-in_file {
        file "/var/log/named/xfer-in.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel xfer-out_file {
        file "/var/log/named/xfer-out.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel notify_file {
        file "/var/log/named/notify.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel client_file {
        file "/var/log/named/client.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel unmatched_file {
        file "/var/log/named/unmatched.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel queries_file {
        file "/var/log/named/queries.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel network_file {
        file "/var/log/named/network.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel update_file {
        file "/var/log/named/update.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel dispatch_file {
        file "/var/log/named/dispatch.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    channel dnssec_file {
        file "/var/log/named/dnssec.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
channel lame-servers_file {
        file "/var/log/named/lame-servers.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
    };
    category default { default_file; };
    category general { general_file; };
    category database { database_file; };
    category security { security_file; };
    category config { config_file; };
    category resolver { resolver_file; };
    category xfer-in { xfer-in_file; };
    category xfer-out { xfer-out_file; };
    category notify { notify_file; };
    category client { client_file; };
    category unmatched { unmatched_file; };
    category queries { queries_file; };
    category network { network_file; };
    category update { update_file; };
    category dispatch { dispatch_file; };
    category dnssec { dnssec_file; };
    category lame-servers { lame-servers_file; };
};

zone "ld.pvt" IN {
    type master;
    file "ld.pvt.zone";
};

/var/named/ld.pvt.zone

$TTL 7200
@               1D IN SOA       ld.pvt. root.ld.pvt. (
                                        2007011622      ; Serial
                                        3H              ; Refresh
                                        15M             ; Retry
                                        1W              ; Expire - 1 week
                                        1D )            ; Minimum

                IN      NS      ld.pvt.
ld.pvt.         IN      A       192.168.1.10
*.ld.pvt.       IN      CNAME   ld.pvt.

你可能需要

# mkdir /var/db/nscd
# touch /etc/netgroup
# systemctl restart named

使用 journalctl -xn 查找错误。

一旦它开始运行,您应该可以 ping 任何东西。ld.pvt,现在您的虚拟主机将知道该怎么做!

现在在您的客户端计算机上,您需要调整 DNS,并刷新 dns 解析器缓存。 nscd -K 然后 nscd 或对于 Winbox,ipconfig /flushdns,然后尝试在 LAN 上 ping 新的anything.ld.pvt。

要将您的客户端框放在地图上,您需要添加一条 A 记录,指向其 ip,例如 automated-pooper-scooper.ld.pvt. IN A 192.168.1.44

【讨论】:

  • 人很顺利...但它代表了很多尝试和错误。
猜你喜欢
  • 2019-02-08
  • 2013-03-16
  • 2015-08-06
  • 2016-02-02
  • 1970-01-01
  • 2014-04-07
  • 1970-01-01
  • 2020-04-14
  • 2014-07-06
相关资源
最近更新 更多