How to restore link-local IPv6 address in Linux
If by any chance you’ve lost your IPv6 link local address, a simple interface up/interface down wouldn’t restore link local address to you.
Before providing a magical code to restore that address, here is the way to loose it:
ip -6 addr flush dev enxa44cc8aa52bd scope link
(enxa44cc8aa52bd is the ugly name of my Ethernet interface, attached through a thunderbolt dock station to my laptop).
To restore it you need to trigger kernel code for generating that address:
net.ipv6.conf.enxa44cc8aa52bd.addr_gen_mode = 0
net.ipv6.conf.enxa44cc8aa52bd.addr_gen_mode = 1
(I repeat, enxa44cc8aa52bd
is an interface name, like old-good eth0
)
The addr_gen_mode
may have more than one possible value, check docs for available options. The key thing here is to change this value (f.e. set it to 2, and then set to 3 would work the same way). Do if you need 0, change to 1 and back to 0.