Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UDP broadcast packets across subnets

Tags:

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.

like image 556
Jon B Avatar asked Dec 18 '08 19:12

Jon B


People also ask

Can UDP across subnets?

UDP is not suitable if: you are using a router in your network to connect across subnets. Remember that we are broadcasting across a single subnet and data packets will not reach DSP units on a different subnet. UDP broadcast method will always take longer than TCP to discover units on the network.

Can you broadcast across subnets?

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.

What is broadcast address in UDP?

A UDP broadcast packet is 'sent' to an IP address with the subnet of the broadcasting device and all 1's in the host portion. For example, if a device has an address 128.253. 109.10 and a subnet mask 255.255. 255.0, it can use the broadcast address 128.253. 109.255.


1 Answers

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.

like image 118
Alnitak Avatar answered Oct 16 '22 20:10

Alnitak