Skip to contentSkip to conversation

Filter out broadcast messages

DISCUSSION Gabby James 3 participants 4 messages Jan 7, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

I would like to filter out all broadcast messages. The packets could come from 255.255.255.255 or multiple other addresses of the form 10.*.*.255. What kind of syntax do I use to DROP these packets? The line below will filter out packets from 255.255.255.255 but I'm not sure what syntax to use to DROP the other adresses.

iptables -A INPUT -d 255.255.255.255 -p udp -j DROP

Regards,
GJ

_________________________________________________________________
Worried about inbox overload? Get MSN Extra Storage now! http://join.msn.com/?PAGE=features/es

#1 lore raw
Quoted 7 lines · Gabby James

Hi,

I would like to filter out all broadcast messages. The packets could come from 255.255.255.255 or multiple other addresses of the form 10.*.*.255. What kind of syntax do I use to DROP these packets? The line below will filter out packets from 255.255.255.255 but I'm not sure what syntax to use to DROP the other adresses.

Should be quite simple really - all you need to know is how many ethernet interfaces are on your firewall, and the broadcast address for each (unless you've got more than one subnet bound to a single ethernet port, ugh).

Remember that broadcast packets do not get routed, therefore you only ned to be concerned with subnets which are local to your firewall.

Unless you have an unusual setup, I'll bet that's no more than three.

It wouldn't be at all hard to script automatically, either. Start with
something like:

for a in /sbin/ifconfig | grep Bcast | tr -s ':' ' ' | cut -d' ' -f6 do
iptables -A INPUT -d $a -j DROP
done

Regards,

Antony.

Signature · 6 lines
Anyone that's normal doesn't really achieve much.

 - Mark Blair, Australian rocket engineer

                                                     Please reply to the list;
                                                           please don't CC me.
#3 lore raw
In reply to Gabby James
Quoted 7 lines · Gabby James

Hi,

I would like to filter out all broadcast messages. The packets could come from 255.255.255.255 or multiple other addresses of the form 10.*.*.255. What kind of syntax do I use to DROP these packets? The line below will filter out packets from 255.255.255.255 but I'm not sure what syntax to use to DROP the other adresses.

Second idea:

If you mean what you say, and the other broadcasts fit the pattern 10.*.*.255, you could always use the little-known but perfectly valid netmaslk 255.0.0.255 in a rule such as:

iptables -I INPUT -s 10.0.0.255/255.0.0.255 -j DROP

This will do exactly what you asked - match packets where the source IP's first byte=10 and the last byte=255, with the middle two bytes being anything, and drop them.

Antony.

Signature · 7 lines
Perfection in design is achieved not when there is nothing left to add, but 
rather when there is nothing left to take away.

 - Antoine de Saint-Exupery

                                                     Please reply to the list;
                                                           please don't CC me.