是否可以分层收集 .local 域 IP 地址以构建基于 dhcp 的 dns?

发布于 2024-10-21 02:55:08 字数 595 浏览 3 评论 0原文

假设您处于正常的 dhcp 环境中,

您将获得如下 IP 地址:

  • 192.168.0.101 对于网段 A 上的 linuxpc1.localdomain
  • 192.168.1.102 对于网段 B 上的 linuxpc2.localdomain

我想通过仅在这些 linuxpc 上安装 avahi 来查找它们设置了主机名。

所以在192.168.2.103 linuxpc3.localdomain上运行

ping linuxpc1.local

就可以了。

实现这一点而不影响 dhcp 服务器设置的最简单方法是什么?

或者,如果这很困难,至少我想知道从 linuxpc3.localdomain 主机运行脚本的名称的 IP 地址。

getipbyname-avahi.py linuxpc1.local
-> returns 192.168.0.101

我不想设置 NIS 或 LDAP 或 SQL ... 我认为重用 avahi 解析 dhcped IP 地址的能力是一个很好的开始。

Suppose you are in normal dhcp environment,

You'll get an ip address like:

  • 192.168.0.101 for linuxpc1.localdomain on segment A
  • 192.168.1.102 for linuxpc2.localdomain on segment B

I want to look them up by only installing avahi on those linuxpcs with hostname set.

So on 192.168.2.103 linuxpc3.localdomain, running

ping linuxpc1.local

would work.

What is the easiest way realizing this not affecting the dhcp server settings?

Or if this is difficult, at least I would want to know the ip address for the name running a script from linuxpc3.localdomain host.

getipbyname-avahi.py linuxpc1.local
-> returns 192.168.0.101

I don't want to setup NIS or LDAP or SQL ...
I thought reusing avahi capability of resolving dhcped ip address is good to start.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风尘浪孓 2024-10-28 02:55:08

为什么不在 DHCP 中启用 DNS 更新?

类似

ddns-updates                on;
ddns-update-style           interim;
ddns-domainname             "network.athome.";
ddns-rev-domainname         "in-addr.arpa.";

dhcpd.conf 中的内容(我假设您使用 ISC),它将更新 DNS。

如果您无法更改 dhcp 配置,您可以在客户端中使用 nsupdate脚本挂钩。

Why don't you just enable DNS updates in DHCP ?

Something like

ddns-updates                on;
ddns-update-style           interim;
ddns-domainname             "network.athome.";
ddns-rev-domainname         "in-addr.arpa.";

in your dhcpd.conf (I'm assuming you use ISC's) and it will update the DNS.

If you can't change the dhcp configuration probably you can use nsupdate in a client script hook.

野鹿林 2024-10-28 02:55:08

可能的解决方案(或者我应该说是拼凑)。
我能看到实现这一点的唯一方法是将所有 linuxpc 机器的网络掩码扩展到 255.255.0.0(B 类网络掩码)。
但是,您必须在 DHCP 服务器上执行此操作,以与配置 linuxpc1 eth0 mac 地址相同的方式将分配 IP 地址 192.168.0.101。
这意味着将所有 C 类私有子网合并到单个 B 类块中。

详情
否则,我认为您无法直接使用开箱即用的 avahi 来做到这一点。这就是原因。

Avahi 使用 mDNS 来公开主机名。

具体来说,事情是这样的:
作为其处理逻辑的一部分,您的 linuxpc3 的 avahi 守护进程将在 IP 地址 224.0.0.51 的端口 5353(?)上发送 DNS UDP 数据报。
该地址是为 Zeroconf 保留的多播地址之一(请参阅 iana 多播地址)。

假设linuxpc3地址是192.168.2.103(遵循你的命名约定),并假设标准C类网络掩码为255.255.255.0,那么只有那些地址在192.168.2.1和192.168.2.254之间的盒子才会收到相应的dns A更新记录(我指的是在这些框中运行的其他 avahi/bonjour 守护进程)。

因此,linuxpc1 和 linuxpc2 都不会知道 linuxpc3.local 主机名/地址对。

相反,如果所有这些盒子的网络掩码都扩展到 255.255.0.0,那么广播范围将扩展到包括 192.168/16 网络中的所有地址。

RFC1918专用网络明确允许将 192.168.0.0 块配置为单个 B 类子网。

更新
看了你们的评论。

第一个结论。 Avahi 无法满足您的多种需求。
Avahi 依赖于子网广播。

在 avahi 也不适用的类似情况下,我曾经通过检测连接事件更改来自动更新 /etc/hosts 文件和 DNS 记录。

所有 PC 都可以看到互联网并检测连接变化(NetworkManager 调度程序挂钩中的 Linux - Windows 通过订阅系统事件通知服务)。

所有计算机都通过 www.dropbox.com 中的消息报告其连接状态和 IP 地址,并从各自的本地 dropbox 文件夹中获取更新。

如果您想改为实现此解决方案或类似的解决方案,我必须警告您这是一项相当大的工作。

Possible solution (or kludge should I say).
The only way I can see of achieving this is to extend the network mask to 255.255.0.0 (class B network mask) for all the linuxpc boxes.
You will have to do that, however, on the DHCP server, in the same way you configure that linuxpc1 eth0 mac address will be assigned ip address 192.168.0.101.
This means merging all your Class C private sub-networks into a single class B chunk.

Detail
Otherwise, I don't think you can do that with avahi straight out of the box. Here is why.

Avahi uses mDNS to publicize hostnames.

In detail, things work like this:
As part of it's processing logic, your linuxpc3's avahi daemon will send a DNS UDP datagram on port 5353 (?) on ip address 224.0.0.51.
This address is one of the multicast addresses reserved for zeroconf (see iana multicast addresses).

Assuming linuxpc3 address is 192.168.2.103 (following your naming convention), and assuming a standard class C network mask of 255.255.255.0, then only those boxes with addresses between 192.168.2.1 and 192.168.2.254 will receive the corresponding dns A update record (by which I mean the other avahi/bonjour daemons running in these boxes).

As a result, neither linuxpc1 nor linuxpc2 will be made aware of the linuxpc3.local hostname/address pair.

If instead the network mask of all these boxes is extended to 255.255.0.0 then the broadcast range will be extended to include all addresses in the 192.168/16 network.

RFC1918, the standard for private networks explicitly allows the 192.168.0.0 block to be configured as a single class B subnetwork.

Update
Having seen your comments.

First conclusion. Avahi has no solution for your combination of requirements.
Avahi relies on subnetwork broadcast.

In a similar context in which avahi was not applicable either, I once resorted to automate the update of /etc/hosts files and DNS records through the detection of connection events changes.

All PCs could see the internet and were detecting conection changes (Linux in NetworkManager dispatcher hooks - Windows through subscription to the System Event Notification Service).

All machines were reporting their connectivity status and ip addresses through messages in www.dropbox.com and were getting their updates from their respective local dropbox folder.

If you want to implement this in stead, or a similar solution, I have to warn you this is quite a bit of work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文