我如何为开发机器设置本地绑定服务器以映射到服务器上的虚拟主机

how do i set up local bind server for dev machine to map to vhosts on server

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

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

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

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

我想要的是这台 DNS 服务器机器 (falcon) 提供共享相同子域 (ld.pvt) 的虚拟主机资源。
资源可能如下所示:

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 that has a disclaimer that its just a starting point, and all the others that are more for what i need, but arent specific to arch, like these 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 主条目

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

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

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

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

NS名称,可以是域名。

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

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

在你要使用DNS服务的机器上,即客户端的适配器的IP属性中的DNS设置,你要设置DNS为DNS服务器的局域网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 anything.ld.pvt,现在您的 vhost 知道该做什么了!

现在在您的客户端机器上,您需要调整 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