On 2007-11-15 05:31:51 -0800, Mali Findik <(E-Mail Removed)> said:
> [...]
> I've got two network interfaces, let us say for example:
> interface_1 with ip 192.168.0.1
> interface_2 with ip 10.1.0.1
>
> Now, if I sniff on the interface_1 I got the correct source ip
> 192.168.0.1, but I sniff on the second interface, i got 192.168.0.1 as
> source ip, anyway 
>
> Does somebody know, how to fix that problem?
Not really. You don't have control over how data is sent from your
application; only in how it's received. You can bind to a specific IP
address to make the socket only receive on that address, but when
sending the network driver will determine what it thinks is the best
route for the data, and that's how the data will be sent.
There are ways to manipulate the routing, but IMHO it's not a good idea
to do so and I'm not aware of anything in .NET that allows that
directly anyway.
One possible workaround would be to use multicast instead of broadcast.
If I recall correctly (and I might not), you can configure the
multicast group on a specific adapter to ensure the source IP address
is as you desire.
But if you really need broadcast datagrams, I don't think there's a
good way to change the behavior the way you want to.
Pete