Iptables not allowing raw sockets to send IP packets with non local IP
Hi
I need to generate UDP packets with non-local source IP address in IP header. These UDP packets have destination UDP port as 5060. For this I am using raw sockets with IP_HDRINCL option. I am running my program with root previledges and it runs fine.
However, I also need to route those packets differently. For this
I have inserted an iptables rule in mangle table output chain so as to
mark all these UDP packets with dst UDP port 5060 with mark 2.
The command used is:
iptables -t mangle -A OUTPUT -p UDP --dport 5060 -j MARK --set-mark 2
The moment I insert this rule, the sendto() call in my program starts
returning failure with error code "Operation not permitted".
I have ip_forwarding ON in kernel.
One other observation is that if I put local IP address in source IP in
IP header of the packet, then the program starts working fine even
with iptables rule inserted.
I feel iptables rule is somehow not allowing to send packet with non-local
source IP address.
Can someone help in this?
Thanks in advance
Vakul
|