forward udp broadcast packets on same subnet /interface with diff source

Antony Stone
Wed, 14 Jul 2004 10:01:27 +0100

On Wednesday 14 July 2004 6:02 am, Tom Thumb wrote:

> Hi,
> Can I use iptables to forward UDP broadcast packets on the same subnet and
> interface but just change the source IP?

These broadcast packet questions are starting to get weird now :)

> That is, the forwarding machine is, with mask and
> has a single NIC.
> A machine with IP with the same mask sends a UDP broadcast to
> The forwarding machine receives this packet. Can it be configured to resend
> it out on the same interface that it received it on (its only interface) and
> just change the source IP to be a 3rd address, like, but also as
> a UDP broadcast to

I don't see how you could, because as you're not changing the destination 
address, there's no way to get the pack forwarded through the netfilter 
machine, and it needs to get forwarded so that it can reach the POSTROUTING 
nat table, where you could do the SNAT and change the source address.

Why, please, do you want to do this???

> Is there any way to do this without adding a physical NIC?  Do I need to add
> a "virtual" NIC to do it? How?

My recommendation would be to write a simple program (Perl would do the job if 
you don't like C etc) which listens for UDP broadcasts and then generates a 
new packet with the destination IP = local subnet broadcast address, and a 
faked source IP (, even though the machine it's running on is

Why do you want to do this?


If at first you don't succeed, destroy all the evidence that you tried.

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