跨子网的 UDP 广播数据包
是否可以通过路由器将UDP广播数据包发送到不同的子网? 我正在编写一个应用程序来发现网络上的某些设备,而 PC 可能与它正在寻找的设备位于不同的子网中。
Is it possible to send a UDP broadcast packet to a different subnet through a router? I'm writing an app to discover certain devices on the network, and the PC might be on a different subnet than the devices it's looking for.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,也不是。
它实际上是可行的,只要介入的路由器没有
no ip direct-broadcasts
或类似的配置。 然而,如今这已成为默认设置,因为允许正常广播穿越路由器会产生 DoS 问题。如果您确实想跨子网广播,那么您应该使用 IP 多播。 这仍然需要适当配置介入路由器,但这是“正确”的方法。
Yes, and no.
It's actually do-able, so long as the intervening routers don't have
no ip directed-broadcasts
or similar configured. However these days that's the default because allowing normal broadcasts to traverse routers is a DoS problem.If you really want to broadcast across subnets then you should be using IP Multicast instead. That still requires that the intervening routers are configured appropriately, but it is the "right" way to do it.
简短回答:
不。
长答案:
或许。 DHCP 以这种方式工作,但路由器配置为允许 DHCP 端口上的 UDP 广播通过。 如果您完全控制网络硬件,您可以打开任何/所有 UDP 端口以允许跨子网广播。 无法控制路由器的配置,请参阅简短的答案。
Short answer:
No.
Long answer:
Maybe. DHCP works this way, but the routers are configured to let the UDP broadcast on the DHCP port through. If you had complete control of the network hardware you could open up any/all UDP ports to allow broadcast across subnets. Without control over the configuration of the routers, see the short answer.
你好,Jon,
Cisco 路由器通常包含 UDP IP Helper 地址模式,您可以使用它来跨子网。
Greetings Jon,
Cisco routers usually contain a UDP IP Helper address mode that you can use to cross the subnet.