0

I am opening a TAP device at centos 7, it has the IPv6 addresses fec0::a:1/64 and 2408:8160:a100:2::2. It has the route 3000::/64 via fec0::a:2.

I need to ping 3000::1 at host, use C program to reply neighbor advertisement, wireshark capture packet as follows:

enter image description here

The TAP device uses 2408:8160:a100:2::2 as source IP to send an ICMPv6 ping request.

I find that when I use "IP a" to show infomation of the TAP, 2408:8160:a100:2::1 is in front of fec0::a:1/64, so the source IP is 2408:8160:a100:2::2; if I add fec0::b:1/64 to TAP device, fec0::b:1/64 is in front of fec0::a:1, it will use fec0::b:1/64 as source IP.

"ip a" result as following: [enter image description here

if the TAP only has one IPv6 address fec0::a:1, the source IP will be fec0::a:1.

So how can I use fec0::a:1 as source IP forever when tap device has other IPv6 address?

zhou fang
  • 1
  • 1
  • It should never prefer a site-local address over a global (routable) address. – Cheatah Jan 13 '22 at 09:03
  • I doubt that routing between scopes (e.g. from site-local to global) is a good idea - unless NAT is used: (Even if this is the case in your network) It is not guaranteed that `3000::1` is not inside another network that also uses site-local addresses. The echo reply would be sent to another computer that also has the address `fec0::a:1`. For this reason, I could even imagine that `3000::1` detects the IP packet as "invalid packet". – Martin Rosenau Jan 13 '22 at 09:15
  • yes, global address has higher priority, however what I really concerned is that the source IP will always be the first IP which uses "ip a" to show. The source IP should be `fec0::a:1` which I really want. – zhou fang Jan 13 '22 at 11:35
  • According to the RFCs, the source address with the same "label" shall be selected if available. You can see the "labels" on a Linux machine using the `ip addrlabels` command. If you `ping` machine `fcc0::b:c`, `fcc0::a:1` will be used as source address; if you ping `3000::1`, `2408:8160:a100:2::2` will be used as source address! – Martin Rosenau Jan 13 '22 at 15:16

0 Answers0