0

I read that when kernel determines a source ipv6 address for the packet, it takes into consideration what interface will be used to send the packet,

(http://www.rfc-editor.org/rfc/rfc3484.txt, Section 5) Rule 5: Prefer outgoing interface. If SA is assigned to the interface that will be used to send to D and SB is assigned to a different interface, then prefer SA. Similarly, if SB is assigned to the interface that will be used to send to D and SA is assigned to a different interface, then prefer SB.
*D = Destination Address

But how is the interface itself determined? Let's take tcp handshake as an example:

  • Host A has one interface and one ip address 1:0:0:0:0:0:0:a
  • Host B has two interfaces eth0 with ip 1:0:0:0:0:0:0:b0 and eth1 with ip 1:0:0:0:0:0:0:b1
  • A sends SYN to B's 1:0:0:0:0:0:0:b0. B responds with SYN-ACK. It should set src ip in Ipv6 header.

As I understand(correct me if I am wrong!) it will choose between 1:0:0:0:0:0:0:b0 and 1:0:0:0:0:0:0:b1 based on rules in the rfc I linked above, but I can't wrap my mind around them, especially the rule 5 as I can't find out how the interface is chosen at the first place.

4
  • 1
    The reply would be from the IP address that was originally contacted. It would not be a valid connection otherwise! Aug 17, 2015 at 3:34
  • @MichaelHampton counter to the example given above, although to the spirit of the question, how would Host B determine which of its 2 interfaces to use to contact Host A?
    – pete
    Aug 17, 2015 at 3:49
  • upon rereading that rule over and over, it sounds like a really wordy, rfc-way of simply saying, "use the IP assigned to the interface we are using"
    – pete
    Aug 17, 2015 at 4:00
  • If you're sending a letter to someone in Sweden, and you could use a return address in Italy or a return address in Sweden, which do you think you'd use? Aug 17, 2015 at 6:12

1 Answer 1

1

Your example is not relevant to section 5 ("Source Address Selection").

When, in your example, Host B is responding to the SYN packet from Host A it has no choice of which address to use. A TCP connection is defined by the address:port + address:port combination, which was selected already by Host A.

Another strange thing in your example is that Host B in your example has the addresses 1:0:0:0:0:0:0:b0 and 1:0:0:0:0:0:0:b1 on different interfaces. Reasonably, these two addresses look like they would belong on the same interface (same prefix?).


What would be relevant would be something along the lines of this:

Host A has multiple addresses that could potentially be used as the source address.

When Host A is creating a new connection (ie, it will be sending the initial TCP SYN) to some specified address, in the source address selection process it will apply Section 5 Rule 5 (just one of several rules that are all applied in the selection process), which ensures that whichever address Host A selects, it will prefer addresses assigned to the interface that will be used (according to the routes) to send to the specified destination address over other addresses.

Ie, whichever interface that the routing table says to use for the destination address will affect which address to select as the source address.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .