Hi again, Gabor, : But what I don't get is how can the route be looked up to assign a src : address if no src address is assigned yet to the socket and there is a : rule that should match the src address. I sense circular logic here. Either we know the source address of the outgoing packet, or we do not. story for source address known: ------------------------------- We perform rule and route lookups according to the known source and destination address. Source address is known, so no problems here. story for source address unknown: --------------------------------- We perform rule and route lookups according only to the known destination. If there is no src parameter on the selected route, at least we know the exit interface. Now, we select an address on that interface according to these rules: IP searches for the first valid address with a scope wider than the scope of the destination but it prefers addresses which fall to the same subnet as the nexthop of the route to the destination. Unlike IPv6, the scopes of IPv4 destinations are not encoded in their addresses but are supplied in routing tables instead (the scope parameter to the ip route command [ ... ] ). [0] : I saw that 'ip -6 route show table main' shows not only the routes in : table "main" but in other tables also (not the "local" thou). Does it : have anything to do with src address selection? Try "ip route show table all" for IPv4 addresses. : Thansk for the links, although I've already read them. They describe : only how the RPDB is traversed to look up a route, and how a src addr : is selected when the route is already found. But not how the route is : found for src addr selection. See my remarks above. If we don't know the source address, we have to find out what route we'll take to reach the destination before we return a source address to the higher layer. Make sense? -Martin [0] http://linux-ip.net/gl/ip-cref/node155.html This text is snipped out of the IP command reference by Alexey Kuznetsov. -- Martin A. Brown --- SecurePipe, Inc. --- mabrown@xxxxxxxxxxxxxx - : send the line "unsubscribe linux-net" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html