Spoofing source address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux