Any knowledge for sysctl?

HI folks. I am developing a protocol and I need to bind to an IP address that is not configured to my machine. The problem is with bind(). The sysctl system call seamed to overcome the problem of bind if you set the proc/sys/net/ipv4/ip_nonlocal_bind flag. Although I tryed to set the flag either from command line by writing sysctl -w net.ipv4.ip_nonlocal_bind=1, or echo 1>proc/sys/net/ipv4/ip_nonlocal_bind, or programmatically by using the command sysctl(), or by seting its value from the /etc/sysctl.conf file, bind still generates an error. Does anybody have any idea of why this is happening? Is there any other way to bind to a non local IP address?

PS. In the kernel configuration the sysctl support(CONFIG_SYSCTL) is enabled together with the /proc file system support (CONFIG_PROC_FS).

CORRECTION
I am using raw sockets. Because with tcp or udp sockets bind() does not cause a problem. However for raw socket bind returns EADDRNOTAVAIL.

Sounds like a very interesting problem.... however I did not fully understand what you are trying to do. Using RAW sockets requires a lot of work to set up the correct client-server socket parameters and data structures. If you are using IP, you need to look at the fields in the IP header and make sure you are building IP packets that can be properly processed on both ends.

What am I missing?

What I am trying to do is to develop a micromobility protocol, i.e. a protocol that will allow users to move from one place to another while containing all the already active connections. From the TCP/IP protocol stuck point of view the protocol I am developing lyies on top of IP so I couldn't use either TCP sockets or UDP sockets only RAW sockets. RAW sockets is not a problem from the communication point of view, I already have accomplished a big part of the protocol. The problem is that a damn message requires the source IP field of the IP packet to be set to zero. Now if you try to set the address to zero (INADDR_ANY) the kernel will set the source IP address to the IP address of the outgoing interface, that applies even if you set the IP_HDRINCL socket option and try to build the IP header from scrutch. In order to prevent the kernel from changing the source IP address I tryed to set the proc.sys.net.ipv4.ip_nonlocal_bind flag as I described but still this doesn't seam to work.
To conclude I am quite sure that the code is OK and the problem is defenitelly some kernel configurations because I saw an implementation of the DHCP, which also requires the source IP address of the first message to be set to zero, and the code was the same as mine.

For what its worth.... the linux kernal has configuration flags that allow the source address of the outgoing packet to be specified. It is a well known problem that most flavors of UNIX force the IP address of the source address to be that of the sending interface. I'm not sure about other UNIX variants, but linux has a specific kernal-build flag to 'address' this problem.

Exactly. As far as I know this flag is the ip_nonlocal_bind, however when I set it bind returns an error. Do you know if there is any other flag that could overcome the problem? I forgot to mention that I am using red hat 7.1.

Isn't there something about IP MASQUERADE (or something like that) when you do a make config to build a linux kernel? Did you try setting these dependencies during the kernel configuration script?

There is a small utility called "papasmurf", which send IP [at least ICMP] with spoofed addresses, it myght be interesting to read it's source