As one of the many problems I had trying to get IPV6 routing to work, I found that I could run a configuration script, and it would all work successfully (including a ping) – then a few seconds later, a manual ping would not work.
I had a shell script to display all my IP configuration information, to display the route information all in one line… including
option="-6 -o" echo "==ROUTE" ip $option route |awk '{ print "ROUTE", $0 } '
When it worked, my route was
ROUTE ::1 dev lo proto kernel metric 256 pref medium ROUTE 2001:db8::/64 dev enp0s31f6 proto ra metric 100 pref medium ROUTE 2001:db8::/64 dev enp0s31f6 proto kernel metric 256 expires 86395sec pref medium ROUTE 2001:db99::/64 dev enp0s31f6 proto ra metric 100 pref medium ROUTE 2a00:23c5:978f:6e01::/64 dev wlp4s0 proto ra metric 600 pref medium ROUTE fe80::/64 dev enp0s31f6 proto kernel metric 100 pref medium ROUTE fe80::/64 dev wlp4s0 proto kernel metric 600 pref medium ROUTE default via fe80::966a:b0ff:fe85:54a7 dev wlp4s0 proto ra metric 600 pref medium ROUTE default via fe80::a2f0:9936:ddfd:95fa dev enp0s31f6 proto ra metric 1024 expires 132sec hoplimit 64 pref medium ROUTE default via fe80::a2f0:9936:ddfd:95fa dev enp0s31f6 proto ra metric 20100 pref medium
Some interesting information in this display (see the man page here)
ROUTE 2001:db8::/64 dev enp0s31f6 proto ra metric 100 pref medium
- 2001:db8::/64, this is the prefix of length 64 bits so 2001:db8:0:0. It is the address range 2001:0db8:0000:0000…. where …. is 0000:0000:0000:0000 to ffff:ffff:ffff:ffff
- dev enp0s31f6 is the device (also known as the interface)
- proto ra. The protocol was installed by Router Discovery protocol
- metric 100. When there is a choice of valid routes, the lower the metric, the more it is favoured.
- pref medium. Preference medium (out of high, medium, low).
Another interesting one is
ROUTE default via fe80::a2f0:9936:ddfd:95fa dev enp0s31f6 proto ra metric 20100 pref medium
- If no other routes are found use the default, route, via enp0s31f6, installed by router discovery protocol(ra).
- The metric is 20100 – so a low priority value.
A short while later, when ping failed, there was an additional route
ROUTE default via fe80::966a:b0ff:fe85:54a7 dev wlp4s0 proto ra metric 600 pref medium
With this the metric is 600 – which is lower than 20100 from before, so packets were sent to the wireless interface – which did not know what to do with them, and dropped them!
Solution
I used
sudo ip -6 route replace default via fe80::a2f0:9936:ddfd:95fa dev enp0s31f6 proto ra metric 200 pref medium
where the metric value was lower than the metric value for the wireless connection, and ping worked.
The above solution worked, but the IP v6 address changed from day to day. The following worked better as it has a permanent global address.
sudo ip -6 route replace default via 2001:db8::2 dev enp0s31f6 proto ra metric 200 pref medium
where 2001:db8::2 is the IP address of the connection on the remote, server, machine. This was done using
sudo ip addr add 2001:db8::2/64 dev eno1