Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
You don't know what "source" means in the context of IP communication? You don't need server Fault - you need the Stevens book... –  voretaq7 Nov 23 '12 at 17:46

2 Answers 2

up vote 2 down vote accepted

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 and You are adding a route to via and want to make sure you are not sending to using the address (maybe because the network has no route back to or because you do not want your traffic to take this route for one reason or the other):

ip route add via src

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).

share|improve this answer

The src attribute is a hint that is used by the address selection algorithm. It is significant when a host has multiple IP addresses, which is usually, but not always, when it has multiple interfaces. While there are other rules that influence address selection, and a network application can also override the selection algorithm by using system calls like bind(), the src attribute is a way to use a routing-table lookup to answer the question, "If I want to initiate a connection to host X, which of my addresses should I use?"

Here is an example to illustrate the use and effect of the src attribute. To make the point that this is related to addresses and routes, not strictly to interfaces, this example host has only one network interface but two addresses. Furthermore, both addresses are on the same subnet to emphasize the fact that there is no other obvious way to choose which one to use.

$ ip -4 addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet brd scope global eth0
    inet scope global secondary eth0
$ ip route list dev eth0  scope link  src  proto kernel  scope link  src

This host can communicate with any of the other 252 addresses on this /24 subnet from either address, but by default it will use when initiating a connection with through, and use 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 connects to this host at, the response will come from even though that doesn't match the src attribute of the return route.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.