I read the man page of
ip and still do not understand what
src is and I could not find much documentation.
Please, if you can explain it thoroughly or point to some link it a good answer.
When adding a route to a multihomed host, you might want to have control over the source IP address your host is sending from when starting communications using this route. This is what src is for.
A short example: you have a host with two interfaces and the IP addresses 192.168.1.123/24 and 10.45.22.12/24. You are adding a route to 126.96.36.199/24 via 10.45.22.1 and want to make sure you are not sending to 188.8.131.52/24 using the 192.168.1.123 address (maybe because the network 184.108.40.206/24 has no route back to 192.168.1.0/24 or because you do not want your traffic to take this route for one reason or the other):
Note that the src you are giving would only affect the traffic originating at your very host. If a foreign packet is being routed, it obviously would already have a source IP address so it would be passed on unaltered (unless you are using NAT of course, but this is an entirely different matter). Also, this setting might be overridden by a process specifically choosing to bind to a specific address instead of using the defaults when initiating connections (rather rare).
Here is an example to illustrate the use and effect of the
This host can communicate with any of the other 252 addresses on this /24 subnet from either address, but by default it will use 10.1.0.16 when initiating a connection with 10.1.0.32 through 10.1.0.63, and use 10.1.0.2 for all the rest.
If the host is responding, rather than initiating, then it will respond from the destination address of the request. For example, if another host at 10.1.0.32 connects to this host at 10.1.0.2, the response will come from 10.1.0.2 even though that doesn't match the