I\'ve two pc using VRRP for redundancy. So every PC (Linux) has a physical and a Virtual IP address.
I\'ve a software (C++) with a client/server architecture with UD
When the kernel needs to send something through a socket it performs these steps
So you need to bind(2) your socket to your desired address. For more information: Source Address Selection.
i'm not sure i understand entirely your question, but in terms of writing C/C++ code on linux at low level, you can import the ip.h header from the linux kernel headers which gives you access to the low level IP packet structure. (UDP works on top of IP)
#include <linux/ip.h>
and then look at struct iphdr
which is the header for every IP packet sent and that contains a saddr
member which you can set programmatically to be the source address.