Indeed in the moment that I configure on the box a dummy interface with the same IP of the received datagrams, these datagrams are logged as martians and thus discarded. Is there a way to bypass the rp_filter? Or, even better, manage to succesfully use the 'sendto' with a socket bound to a non local address? I would rather solve it programmatically than use a tool like NAT. Thanks, Luca. ---------- Initial Header ----------- >From : linux-net-owner@vger.kernel.org To : "bit.gossip@libero.it" bit.gossip@libero.it Cc : "linux-net linux-net" linux-net@vger.kernel.org Date : Mon, 27 Oct 2003 09:43:33 +1100 Subject : Re: Spoofing source address > You're probably getting stuck on the rp_filter (packets coming in on a > different interface than the reply would go out of). You can test this by > enabling log_martians and disable it if you wish. > > Are you actually modifying the packets? If not, I'd suggest using netfiler > with the DNAT target. > > Hope this helps, > > On Sun, Oct 26, 2003 at 10:54:58PM +0100, bit.gossip@libero.it wrote: > > I am developing in C on RH9 with kernel 2.4.20-20.9 > > I want to write a program that receives an UDP stream and send it to another > > destination with the same source IP as it is received. This obviously means > > spoofing the source IP address. > > Issuing: > > echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind > > I am able to bind the socket to the foreign address (socket(AF_INET, SOCK_DGRAM, > > IPPROTO_UDP)) > > But then the sendto fails with an 'invalid argument' error. > > > > I have tried the following hack: > > create a dummy interface with the address to be spoofed, for instance lo:1 > > in this case the sendto works correctly sending datagrams with the spoofed source IP > > > > ... but the recvfrom stops working and doesn't receive any datagram from that > > same address :-( > > > > Any suggestion on how can I do it? > > Thanks, > > Luca. > > > > - > > : send the line "unsubscribe linux-net" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > -- > Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > > "All that is needed for the forces of evil to triumph is for enough good > > men to do nothing." - Edmond Burke > > "The penalty good people pay for not being interested in politics is to be > > governed by people worse than themselves." - Plato > - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html